2d rendering structure - how to make it fast?

Started by
4 comments, last by agaudreau 15 years, 1 month ago
i made a mario-like game. in my PC, i can say that it has some speed problem. its not that bad/too slow,but you can recognize/feel it. BUT why is that other 2d games i play in my PC does have that problem(mario,diablo1,diablo2,trickster,etc.) i would like to learn the right way(the best way) or the best structure of rendering for games. i searched the net but got no luck. first is I dont know the keywords to search on. any help would be much appreciated.thanks!
Advertisement
You aren't going to get much, if any real help, because you didn't specify anything that we can help you with. What language?, Which rendering library?, code snippets. You've gotta supply details if you want help.
Don't load the sprites from disk every frame. Load them once at the beginning and keep them around.
Use "instancing" for your sprites and you will gain a big boost because you wont be storing multiple copies of the same stuff in your video memory.

plus "culling" will give you performance based on the amount of stuff you cull off because you wont be drawing what isnt on the screen.
sorry..
im using C++ / directx9
(using D3DXSPRITE)

what is instancing? culling??

any structure how to make my game faster? pseudo code will do.
Instancing: Is using the same object in multiple places as different objects. A good example is textures, if you had a tree texture and you wanted 100 trees, you wouldnt want to load the texture 100 times. You load it 1 time and point the 100 tree objects to the texture.



Culling: In a broad sence culling is, not drawing what you cannot see. In your case if you are using a tile based system or not you should have some basic information about what your drawing with directX ie: the position of your sprites compaired to the position of your viewing screen. If you do a collision check between the sprite and your viewing rectangle (your screen) and only call draw on what is colliding you will increase performance unless everything is on screen at once.

This topic is closed to new replies.

Advertisement