PDA

View Full Version : 2D platform game design



Mikael
05-03-2004, 11:53 AM
I am working on a simple platform game. The game is going to have some platforms that the player (and monsters) can walk and jump on and so on. I am wondering how I should render the platforms?

I am using a sprite class for the player, monsters and stuff like that. Should I use sprites for the platforms as well? Or is there some smarter way to do it? Perhaps a background image (with painted platforms on, rendered just before the level/stage starts) and some data structure to calculate collisions is advisable?

One problem I see is bad performance if I use sprites for platform graphics. If I have a screen with many platforms that is painted by using 32x32 sprites, I roughly need to use 300-400 sprites. Tests shows that my ?¢_ogame/graphic engine?¢__ can handle 500-600 32x32 sprites with smooth moving sprites and no performance hit, but I hate the idea that more that half of my sprites are used just to paint platforms.

Any help is very appreciated

Useless Hacker
05-03-2004, 12:25 PM
You could split the map into a grid and use a couple of 2-D arrays, one to hold the index of the image you want to draw at each position, and another to hold whether or not they are 'solid'. If you have moveable platforms, then these should probably be sprites. Since each grid position will be static, you can optimise your drawing methods to only draw the part of the grid that is visible.

Hope this helps.

Mikael
05-03-2004, 01:21 PM
Sound like a good idea - but your solution still forces me to paint an image for each visible grid cell in every application loop. That could still result in up to 300-400 images.

I am not sure if painting images is quicker than painting sprites. In my game engine the difference between images and sprites are close to nothing. I will need to test that.

Traveler
05-03-2004, 09:31 PM
Have a look on my website. (http://www.gameprogrammer.net) There's a tutorial about creating a platform game. Might be just what you're looking for.

WILL
05-03-2004, 10:50 PM
Hi Mikael, I'm glad people are still interested in these types of games. Being one that grew up on them, I do enjoy playing them thoroughly when I have the chance.

I found a really nice article on GameDev.net about Difficulty in Dextartiry-Based Platform Games (http://www.gamedev.net/reference/design/features/platformdiff/). I hope you find it useful. Hopefully we will eventually see such articles on this site in the near future.

Good luck with your game. :)

Mikael
08-03-2004, 07:07 AM
Nice web-site Traveler! I have read your fine tutorial about making platform games. I have never done any DelphiX programming, but your tutorial still gave me some ideas for my upcoming platform game. Thanks a lot!

Great article, Will! The article addresses many aspects of making platform games. I have learned a lot of it. Thanks!