Cripes 2.0: Some all-around refactoring.

Published February 22, 2009
Advertisement
I decided to create an IDrawable abstract class and have Entity inherit from it, and did some fixing up so that the EntityMap uses IDrawable instead. I had to use pointers instead of letting the EntityMap own the actual Entities, so now I think I'll be making some kind of manager class that will actually own the entities. I also gave the Entity class a virtual Update() method that takes a DWORD frame_delta that it can use to decide if it's time to change its appearance or move or whatnot. The basic Entity doesn't do anything, while the Missile - which, yes, I've successfully made without much effort - will move itself based on what its aim COORD is.

I'm actually kind of torn between using virtual methods or passed-in functors here. One problem is that the entity Update() method doesn't have any context in the world, so it can't check itself for collision as it moves, or wrap itself around the map (because it doesn't know the width and height, so it doesn't know when or where to set its value to the other side). That's one of the reasons I'm starting to lean heavily towards a passed-in functor... I might actually do that, because it's the only solution that sounds sensible.

I'm also considering doing something with my MazeGen along the lines of splitting it into an object that actually comes up with the maze, and one that takes its output and converts it into entities. The latter might be incorporated into the World as another method... perhaps it could take a MapLoader* - MazeGen's parent abstract class - as a parameter. MapLoader's been pretty much unused, actually - just forward-thinking design - but this might be the time to use it. Hmm.


As a short footnote, my Keyboard class design - or more correctly, my keypress management algorithm - is growing on me, and I'm not even using it! I think, with tweaking, it could be used in a normal application too, though at high update-rates you kind of lose the benefits of the three-state: you're checking fast enough that with human reflexes the chances of a tap going unnoticed are slim. In Snipes, though, I've locked it at one frame every 150ms, which is ample time for a tap to be missed.


That's three topics there (plus a footnote): IDrawable, Entity update functors, and MazeGen abstraction/decoupling. Thoughts?

~Jonathan
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement