Hopefully, I won't be to busy after hours to work on my new game.
I've been stuck trying to build my own simple sprite engine. For some reason, I am determined to code this in plain C only. This results however in engines that are not very flexible and I end up re-writing. I am also trying to achieve simplicity in design(which is also very difficult).
So far my sprite management looks like this:
/* Handlers initialize a sprite's data on the 1st call, then updates logic */typedef void ( *SPRITEHANDLER )( struct sprite_t *sprite )struct sprite_t{ float px, py, dx, dy; BITMAP *sprite; void *extra; SPRITEHANDLER update; struct sprite_t *next;};/* Creates Sprite Object and add to sprite list */struct sprite_t *spawn_sprite( SPRITEHANDLER sprite_handler, int x, int y ); /* Removes sprite from the list and de-allocates it */void kill_sprite( struct sprite_t *sprite );/* Invokes the sprite handlers to update logic (at a low internal FPS ) */void update_sprites( );/* Moves all sprites one step based on its velocity, invoked once per frame */void move_sprite( );/* Draws all sprites to bitmap object, invoked once per frame */void draw_sprites( BITMAP *video_surface );
The "sprite handler" functions as a sort of class for each sprite. I would have a handler function for each type of sprite.
I'm afraid however that this design may be too restrictive. I haven't considered how I would display multi-sprite objects, or how they would communicate with each other.
I really need to think the design through. I just need more time.
Your first sketch was pretty cool too! Hope to see more of that.
Good luck with the game!