Thanks for the critique!
sdw wrote:
Why is Animation so lonely?

Animation is an anti-social problem-child
Animation should have been inside the Entity object. The entity has a vector of possible animations, and a currentAnimation that points to which one to play.
Quote:
What's the difference between a Map and a Level?
Map was going to be just the tile grid, with functions for path-finding, etc. Level was going to be the container for everything in the level, the map (tile grid) and all entities.
Quote:
Can you merge Tile, Map, Level, and ImpManager all into one box and call it Map or Level?
I wasn't too sure about the ImpManager, but I needed something to handle the imps spawning and pathfinding. Functionally, I could indeed merge Tile, Map, Level, and ImpManager. I would end up with a pretty bulky class though, with a large majority of the games logic happening there. Not sure if that would be a Bad Thing? It
would simplify the communication between those components, though.
In its previous incarnation, Tile was just a struct to store map tile information. I was going to do the same thing again.
Code:
-::Tile.h::-
struct Tile{
int tileX; //x co-ord on the tileset for this tile
int tileY; //y co-ord
//int mapX; //self-aware tiles, as it were...
//int mapY;
bool blocking; //tile is impossible to pass
bool exitTile; //is this an exit tile?
bool collectTile; //is this a coffee collection tile? i.e. the imp can start gathering and stop path-
int cost; //this amount should not be changed, it is set at start up
int costNow, costHeuristic; //the cost to get here so far and the cost heuristic from this tile
int costDragon; //the cost due to dragon proximity
inline int costTotal() const{return costNow+costHeuristic+costDragon;}
sf::Vector2i prev; //what tile brought us here?
bool visited; //if this has already been popped, don't add it again
bool operator>(const Tile& rhs){
return (costTotal() > rhs.costTotal());
}
Tile():tileX(-1),tileY(-1),blocking(false),exitTile(false),collectTile(false),costNow(INT_MAX),costHeuristic(0),costDragon(0),visited(false){}
};
-::Map.h::-
class Map{
//.........
public:
std::vector< std::vector<Tile> > map; //to be allocated on map.load(file)
//.........
};
Quote:
Why can't you just walk the tree (rooted at Game), drawing things that need to be drawn?
I wanted the draw list so that things would be drawn in increasing y-order. This way, sprites that were lower on the screen would be drawn after ones above it. Is there a better way to accomplish this without maintaining a list of all things that want to be drawn, and then sorting it before painting the frame?
Quote:
Why does Drawer need to be a singleton?
I wanted to make it a singleton because there would only ever be one of it, and I wanted a global point of access to it. The idea was to have all Drawable items make a call to the Drawer on construction, and add themselves to the drawList. They could make another call on destruction to remove themselves.
Quote:
Why is ConcreteState a singleton?
I'm following the tutorial here:
http://gpwiki.org/index.php/State_pattern . It said the concrete states should be singletons. I'm not sure of the correct reason for this, but I imagine its for reasons of saving memory. The states don't contain any state attributes, only actions to perform when in that state.
I could probably get away with using enum and switch but I thought this way would make the code more managable. I want to be able to force some states to change directly after their animation ends. (The dragon is able to jump over walls. To do this, I teleport him over the wall and then play an animation of him jumping over. When the animation ends, the state should change and allow the player to move again.)
The Message is basically a game event. In the state pattern tutorial above, there is a different Message for each kind of event. Like a Jump event or a CastSpell event.
Quote:
Would it be beneficial to create some sort of Serializable interface?
I'm not sure. At the moment I only need to be able to load the data. And it simple enough that I can handmake the files. When I make the level editor it would be a useful addition.