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.

AppGameKit Classic Chat / [SOLVED] Sprites add to memory or just images

Author
Message
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 13th Nov 2022 15:40
Now i know Loaded images add to program memory.

But if I load one image and make 100 sprites is this counted as more images loaded to add to memory?

I ask becouse if I load in one big sprite sheet for all my program images and just make sprites this will make my program 100 percent faster and better.

The author of this post has marked a post as an answer.

Go to answer

PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 13th Nov 2022 18:35
it is recommended that you use a sprite sheet yes but not necessarily for the sake of memory although it helps that to, main reason is it cuts down on draw calls, if you load 100 separate images the GPU has to look up and render them all, if you use a spritesheet it only has to look up 1 image thus cutting render times ..... if you can, yes use a spritesheet

sprites do add to memory yes but not the image, once loaded the image takes no more memory no matter how many times its used but sprites, objects, text etc all have a linked list attached to them but this is measured in bytes so you probably never need to worry about it, but trying to render thousands of sprites will cause a bottle neck, this is not a memory issue its a GPU limitation.

HTH
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 13th Nov 2022 18:48
Quote: "thousands of sprites will cause a bottle neck"


Ok so is there a basic amount that should be counted or used at one time before the bottle neck?

This should be accounted for in some programs.

So this way I know when I am about to come close to a slowdown.

Thank you for your help on this.
Zappo
Valued Member
20
Years of Service
User Offline
Joined: 27th Oct 2004
Location: In the post
Posted: 14th Nov 2022 12:29
You will only really know the limits by testing on your target platforms. It will depend on many things, including the size of the images/sprites, your framerate, the target platform (Windows, Android, iOS), the target device specifications (memory available, GPU available, CPU available), what other software is running in the background etc. It is basically impossible to tell before running it on real devices. Even emulators won't give you the full picture although they are great starting point.
This is why testing your applications and games on as many real target devices as possible is incredibly important before release. I hope that helps.
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 14th Nov 2022 16:02
Quote: "Zappo"


Phone applications usually work stand along as long as people close there other APS but the target device is for phones.

It is not about testing on my device and then saying this is for all devices, and not everyone is lucky enough to test on a lot of devices. So there should be a standard.

Quote: "(memory available, GPU available, CPU available)"


That is also well, not so as I have a top of the line laptop with lots of ram and it plays anything, But when my programs lag on my laptop, they do not lag on my phone as some how phones are way better at handling frame rates.

But for now I am in the process of testing and so far on this laptop the limit is 156 sprites all loaded in place standing still with sprite animations before a slow down.

There needs to be a standard for others to know, or at least if there is every other code described and some with examples , it is odd how there is nothing about how many sprites each device can handle.



Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 14th Nov 2022 18:27
If all your sprites reference the same image, then only 1 copy of that image is maintained in memory. Now, each sprite will of course use some memory but they don't contain any image data. For instance think of a tile map. Might have 100x100 sprites on screen (10k sprites) but they all reference a single image. Most hardware should handle this with absolutely no problem. Even if each sprite took up 1kb of memory (most likely its far less), that's 10mb of ram. As parttimecoder said, a bottleneck is much more likely to happen with the gpu and not your system ram.

Quote: "But for now I am in the process of testing and so far on this laptop the limit is 156 sprites all loaded in place standing still with sprite animations before a slow down."


That's not very many sprites. How big are they? Your code isn't in a loop reloading them all constantly is it? What Gpu is in your laptop? If you have a code example we can run maybe we can figure something out. It's also possible your laptop has a driver issue or something else causing the slowdown. If Win11 who knows what the issue might be. I've seen MS updates before that have completely halted machines.

Quote: ", it is odd how there is nothing about how many sprites each device can handle."

Because there is no standard, it depends on the specific hardware and to some degree the code itself in terms of what else is being processed.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda
Pixel-Perfect Collision

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 14th Nov 2022 18:55
Quote: " How big are they? Your code isn't in a loop reloading them all constantly is it? "


My sprites are sprite sheets and diffrent sizes but nothing to big.


they range from 1168,1248 but contain the sprite frames. there are 11 diffrent sheets all loaded at the same time.

my code is set to repeat to untill.

I am guessing this might be to using 11 dirrent sprite sheets?
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 15th Nov 2022 03:18
All games and software have "Minimum system Requirements" that is the closest thing to any standard.

11 x 1k sprite sheets is nothing ... you should be able to run more than 156 sprites, maybe something in your code is slowing the game down

remember, every loop is a delay, if you have 20 heavy for loops in your main loop your frame rate will suffer, if that's the case then make the loops run in separate frames ... just a thought!


and funny you mention the phone being faster than the laptop, I also get that ... just goes to show how dam powerful modern phones really are
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 15th Nov 2022 15:48
Quote: "PartTimeCoder"


I cut my sprite sheet size down by half and also changed the size of my levels and restuctred them and it brought by frame rate up to over 50 frames per sec.

But it makes you wonder, If i can run some programs with 1000 sprites with no slow down at all and my frame rates are 2000 but with my program the rates are 50s 60s.

I also am making a tween for every sprite created so i wonder if this takes down frame rates.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 15th Nov 2022 16:30
Ah ... there you go, 156 tweens running in a single frame is going to tank your fps for sure, so its not a graphical issue its a processing issue

what are the tweens doing, is there another way to achieve the same goal, are the tweens vital to gameplay, what can you lose and still achieve the intended goal? ... are all questions every dev has to ask themselves with every aspect of the project ... if its not vital to gameplay but effects performance then shelve it/ or find another way
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 17th Nov 2022 21:52 Edited at: 17th Nov 2022 21:53
This post has been marked by the post author as the answer.
PartTimeCoder

I tracked the slow down on frame rates down.

It had nothing to do with sprite size or tweens.

I was checking for a event in the loop on every loop when all i needed to do was ask.

if GetSpriteExists()=1

So becouse the sprite did not exist it gave me a slow down.

Now my frames are at max 700 to 1000

Login to post a reply

Server time is: 2024-11-21 12:27:19
Your offset time is: 2024-11-21 12:27:19