Archived

This topic is now archived and is closed to further replies.

jammyt

How to draw a platform game?

Recommended Posts

jammyt    122
I am writing a simple 2D platform game in the style of Chuckie Egg as my first experiment with DirectX. It displays a single screen at a time and I have a question regarding how is the best way to draw the graphics to the screen. I have created levels using a simple tile editor that I wrote in Delphi and exported the levels to a file so I can read them in. How would people go about displaying the graphics in the game? Does this sound reasonable? Any improvements would be appreciated. Initilisation: 1) At start of game load the tiles into a Direct Draw surface. 2) Create a primary, back and level buffer, direct draw surfaces. 3) Read the level data from the file. 4) Copy the appropriate tile bitmap to the correct position on the level buffer. Main loop: repeat 5) Read input 6) Move the character as relating to the current input and occupied tile 7) Calculate AI moves 8) Copy the level surface to the back surface 9) Copy the tiles relating to the characters to the back surface in the correct position 10) Copy the back surface to the primary surface Any comments very much appreciated. Jam

Share this post


Link to post
Share on other sites
BlackGhost    116
That sounds nice. My only advice is that you prepare a surface containing all the sprites in all possible positions (the "character tiles", as you call them), and copy them as needed from there to the back surface. If you create a new surface from a bitmap each frame, it will become very slow eventually.

Share this post


Link to post
Share on other sites
emreture    122
before blitting any surfaces you should check whether they''re lost or not. if they''re lost you have to reload them. refer to directx7 sdk for further details.

===============================================

What we do in life, echoes in eternity!

Share this post


Link to post
Share on other sites