Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Best practices in using sprites?

Author
Message
Iuzidal
15
Years of Service
User Offline
Joined: 25th Jun 2009
Location:
Posted: 25th Jun 2009 09:47
I'm having some performance issues with a top down rpg I just started. My assumption is that I'm just using the API wrong.

I have a 20x10 tileset of 64px square frames and I'm creating a 60x60 tile map with 3 layers. The 1st layer is fully populated, the 2nd and 3rd are sparse. I load the tileset as a bitmap and chop it up.

In my first attempt I called dbSprite() for every tile giving it a unique sprite ID. I wanted to use the setSpritePriority to order things as I looped over the rows and cols in the map. For a small map this worked great, but when I loaded up the 60x60 (3700+ sprites) everything stopped.

I experimented with dbPasteSprite, but I lose the functionality of dbSetSpritePriority. I changed the sprites in the bottom layer to just use dbPasteImage. This fixed all performance issues, but I can no longer see my sprites. I switched to dbDrawSpriteLast and now I can no longer see my debug console text.

Right now my render loop is (psuedocode):


I also have sheets loaded for the mobile animations, but that doesn't seem to affect the fps if I comment them out.

So, what I'm hoping for is some general guidelines on the best way to use the API for what I am trying to do.

Thanks!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 25th Jun 2009 15:33
There have been changes made to the sprite system in the current DBPro 7.4 beta that removes all speed issues with priorities, and in fact, renders sprites even faster than before.

Eventually this will trickle through to the GDK.

If you can't wait for that, then I'd suggest putting together an image-based system and doing it all yourself - sorting by priority and pasting them as you do now.

Iuzidal
15
Years of Service
User Offline
Joined: 25th Jun 2009
Location:
Posted: 29th Jun 2009 05:29
I'm still struggling with performance issues. If anyone has the time, please take a look at this example. I've pulled out the general structure of my render loop and made it work with the default 2d game wizard for MSVS 2008. With my setup I can just paste this into main.cpp and it will execute. It uses the media that is provided by the wizard; a 1024x1024 'background.bmp' and 512x512 'sprite.bmp'.

The idea is that with a 100x100 map of 32px tiles and a viewport of 800 x 600 I get about 12 fps with 2 layers of sprites. The demo allows you to change the viewport with 'w' and 's' and move the map around with arrows. If you shrink the viewport to 600x400 ish things speed up nicely.

Is there an issue in my loop or is this just the performance to expect from multiple layers of sprites?

Login to post a reply

Server time is: 2024-10-01 06:01:09
Your offset time is: 2024-10-01 06:01:09