my 2D graphics engine - am I doing this fundimentally wrong?

Started by
2 comments, last by tls284 21 years, 6 months ago
Hi all, Sorry if this is somewhat vague.. This is my first graphical game, a 2D RPG that you can play online (NOT massive multiplayer blah blah): Screenshot Currently, all the graphics you see on the pic are stored in a giant linked-list which sorts them by Z-plane order (sprites are also sub-sorted by Y position if they are on the same plane). Each game cycle I just iterate through the list and draw everything that falls within view of where the character is standing. I get about 160+ fps on my system, 1400mhz/512ram/Radeon, but obviously this drops way down to 30 or less on lower end systems.. Is this fine or should I be checking to see if only parts of the screen should be updated - IE not blitting the menus unless they change, etc? Any suggestions would be very appreciated! Ty Edit: I R not good at links! [edited by - tls284 on October 21, 2002 8:53:09 PM] [edited by - tls284 on October 21, 2002 8:53:33 PM]
Advertisement
Well, it depends. How big is your world? And do you load EVERYTHING and iterate through that list or do you separate things into what could be considered different ''levels''? A room in a building could be considered a level. Same with the outdoors.

If you separate the game so that there are different portals between the levels and don''t load every single one, that would be one solution. Another would be to use a two dimensional array that keeps track of the map coordinates with the array locations. Then, use a shifting point to determine what should be drawn and what should not be. It''s possible that your algorithm to blit isn''t as efficient as it could be.

ex: int map[1000][1000];
int upperLeftX,upperLeftY;

Blit()
int x = upperLeftX;
for( x;x < upperLeftX +20;x++)
blitTile

etc...

you get the idea. That would blit the topmost row of tiles. Just write a loop to do the same thing for the next row. Your map keeps track of what goes where. Your loop decides what gets blitted. You could use a list just as easily. I don''t think I''d use a single long list though.

Heh... you could use a list of lists to dynamically resize it.

Looking for an honest video game publisher? Visit www.gamethoughts.com
Shameless plug: Game Thoughts
I'd love to see some replies in this thead as well (thanks mtaber). I had done the same thing that tls284 did in a previous 2D engine I made. I planned on looking at the problem of sorting sprites in a tilebased engine again when I started my next project. Is there a better way to sort everything so that it can be drawn in the proper order?

edit - damn typos

***********************
          

[edited by - Big Sassy on October 22, 2002 1:24:12 AM]
you should change it when the display is being changed.
also how did you get those FF pics for your game?

Beginner in Game Development?  Read here. And read here.

 

This topic is closed to new replies.

Advertisement