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.

Newcomers AppGameKit Corner / Question Regarding FPS and Sprite Counts

Author
Message
boldpaste2
5
Years of Service
User Offline
Joined: 4th Apr 2019
Location:
Posted: 7th Jul 2020 04:47 Edited at: 7th Jul 2020 04:53
Hello Everyone,

Got a bit of a strange question. I was curious as to why offscreen sprites would cause the overall performance to decrease (especially if these sprites are not being called by a function or anything, and they all share 1 image ID. they simply just exist off screen). The project I am working on is all based on a tile grid (Think RPG Maker) and I was hoping to simply make 1 seamless world. I attempted to manually cull out off screen sprites by unloading them but the bigger the map the more processing time it seams to take to complete the task (and even greater memory requirement). Though, I am going nowhere near my computers hardware limitations.

Here is a snip when 0 sprites are rendered showing high FPS and Low pixel draw


Here is another screenshot when I load lots of sprites but still maintaining a low pixel draw count


Some insight would be most appreciated.
dandrews
3
Years of Service
User Offline
Joined: 26th Jun 2020
Location:
Posted: 15th Jul 2020 01:33
Do you have the entire map loaded or are you repositioning tiles as they leave view? And are there animations with the offscreen sprites?
Virtual Nomad
Moderator
18
Years of Service
Recently Online
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 15th Jul 2020 03:16 Edited at: 15th Jul 2020 03:24
this discussion might offer some insight.

otherwise, you said:
Quote: "I load lots of sprites"

are you actually using LoadSprite() (for each sprite) including some with the same image (not recommended) vs ThisImg = LoadImage("this.png") along with CreateSprite(ThisImg) and/or CloneSprite()?
boldpaste2
5
Years of Service
User Offline
Joined: 4th Apr 2019
Location:
Posted: 15th Jul 2020 04:20
Thanks for the feedback. I use the "ThisImg = LoadImage("this.png") along with CreateSprite(ThisImg)" to build the map as it is more efficient. I think the slow down is occurring because from what I was able to dig up. AppGameKit keeps a "List" of loaded sprites and on each passthrough it goes through those list to see if the sprite has to have special properties, adjust positions, animations, etc. which seams to waste processing time.

I built a method that tracks the center of the screen and if the center crosses a certain threshold, all the sprites become unloaded and then gets reloaded based on the position of the crossed threshold. (the map data stays loaded in memory) It seems to work as I was able to load up 100,000 sprites and maintain over 3000 fps.

Unfortunately, I encountered a bug where playing sprites become out of sync causing them to be played at incorrect intervals (so when a cull occurs, if an animation was on frame 3 of 5, it jumps back to 1 and this is very noticeable). For this, I plan to create "Parent" sprites that stay loaded in at all times and playing but not visible and manually set the other sprites with animations with SetSpriteFrame based on the parent its related to.

Virtual Nomad
Moderator
18
Years of Service
Recently Online
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 15th Jul 2020 04:37 Edited at: 15th Jul 2020 04:38
Quote: " I plan to create "Parent" sprites that stay loaded"

sounds like a good plan. and, thanks for sharing your work.

Quote: "100,000 sprites and maintain over 3000 fps"

good stuff. and, i want to make sure you know that these benchmarking commands exist while it sounds like you've already accounted for whatever they would have offered, otherwise:
GetManagedSpriteCount ()
GetManagedSpriteDrawCalls ()
GetManagedSpriteDrawnCount ()
GetManagedSpriteSortedCount ()

Login to post a reply

Server time is: 2024-04-19 21:54:17
Your offset time is: 2024-04-19 21:54:17