• Advertisement
Sign in to follow this  

Some graphics / rendering questions

This topic is 3673 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm writing a pacman clone, and was wondering how would you typically implement the sprites? Just as ordinary bitmap files (1 per different movement?) I also have a 2 dimensional array of Images to represent the map(each one is a tile, is that a stupid way to implement it?). How is the draw/undraw code going to be? Invalidate the nearby tiles, redraw the sprites? I'm using C# btw.

Share this post


Link to post
Share on other sites
Advertisement
For your sprites you can use one sprite per animation frame/direction, i.e. (<, >), ... . You could also use a few sprites and rotate/flip them accordingly, but I guess you'll gona have only small ones and a few characters, so having more sprites isn't that much a waste of memory.

I'd represent the map as a 2D array of some structure that describes the map. Since you'll certainly reuse many of the tiles you could just have a tile pool that contains every tile image once, store the id of or a reference to the image in your tile structure and get the tile from the pool for rendering.

As for your draw code: I don't know what API you will be using, but if you just use the OS functionality or some 2D library like GTK your approach is fine: redraw only the tiles that have changed. If you are using some 3D library like DirectX or OpenGL the easiest way is to render each tile as a quad every frame.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement