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 / LoadImage and memory storage

Author
Message
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 11th May 2017 11:22
is it better to keep images loaded in your game if they will be used frequently (loaded only once of course) or should i be deleting them and reloading the desired images to free up memory for images in case a system has a low memory cap?
my normal approach is to simply create my sprites and images once and keep them throughout the game if they will be recalled even more than once as i see it as a bad idea to keep loading and unloading images (if they are 1 use only then naturally i delete them) but i'm curious if i'm wrong and this would mean people with a low memory cap would crash?
especially for animations and large files, should i prioritize deleting and reloading these when not needed?
life\'s one big game
spec= 2.6ghz, 1gb ram, 512mb gpu, directx 9.0c, dbpro and classic
Funnell7
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 11th May 2017 16:59
I tend to load all images up front, and create/delete sprites on the fly - I dislike hiding or moving sprites off screen... I never delete/unload images
Using AppGameKit V2 Tier 1
29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 11th May 2017 18:10
Unlike Funnell, I load everything in and then hide what's not currently being used. It's not really about right or wrong but about what works for your game, whatever causes the least problems. I suspect that it's more to do with what you think is easier to manage, hiding stuff or deleting it.

However, I don't literally load in everything at once (this really will cause problems). My general approach is to look for the natural breaks in the game - such as transitioning from the main menu to the start of the level - and this is where you can delete and load media, as the player will expect a bit of a pause anyway.

Normally I split the media up in the following way:

intro media - deleted when the player exits the intro and goes to the main menu
main menu media - deleted when the player starts playing the game
media that is used throughout the entirety of the game (bullets, explosion sound effects) - is only deleted when the player exits the game and goes back to the main menu
level specific media (map, npcs) - deleted when the level is over

You might have to experiment a bit to find what works. Personally, I'm quite flexible with how I approach each project and do whatever creates the least amount of work.
Hover Car Race Challenge! - available now on Google Play
Invaders of the 29th Dimension - available now on Google Play
Find me on indieDB
Funnell7
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 12th May 2017 08:08
Quote: "It's not really about right or wrong"


This. For what it's worth, I used to follow the hide/unhide approach, but AppGameKit is so quick when it comes to creating and destroying sprites that IMO there is no benefit in having them hidden. For me, I feel it's cleaner to create and destroy as and when needed...
Using AppGameKit V2 Tier 1
NGP
AGK Developer
8
Years of Service
User Offline
Joined: 29th Dec 2015
Location: In the studio
Posted: 12th May 2017 10:48 Edited at: 12th May 2017 10:49
Best practice: load as needed, delete when not. (Since the image files in your project are always available and super-quick to access, is it necessary to keep copies of them in limited memory at all times?)

Think of it like your own memory. Is there any point constantly remembering a shopping list when you're not at the shop? How about 20 of them? It's a lot cleaner to forget them and only refer to them when you get to the shop. Then your brain can get on with its current task much more rapidly.

It's always wise to think of the weakest hardware and to practice efficiency wherever possible. Using "natural" breaks between game sections, to remove and load data, is a solid and well-proven approach! You can easily write a small function to check/wipe/load things and keep the process organised. At the end of the day though, whatever works best for *you* in the current moment is the "correct" approach!
AGK Linux user.
Tessellatus - a game of chance for Android.
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 12th May 2017 19:55
thanks for the answers, so if i understand correctly then deleting and reloading the images will just mean more work for every system but helps ensure low end systems will continue to run (and higher spec systems will have no problem coping with the increased workload anyway), while keeping all images in memory will mean less work overall for the systems but could make the game unplayable for low end users due to memory limits.

i always thought it was good practice to keep images in memory if you needed them often but i think i need to change my approach in future
life\'s one big game
spec= 2.6ghz, 1gb ram, 512mb gpu, directx 9.0c, dbpro and classic
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 15th May 2017 23:52
You just need to adapt accordingly. There's no right/wrong "way" - just appropriate.

On big games, it's sometimes one of the most difficult post processes to make the loading / memory management work - it's an art in itself and tends not to be a major issue these days with "huge" memory but we will always find ways to make it an issue
Historically, this was a massive design factor in games and should still be IMO

There's no "always" and no "should". It's all down to the design.

I remember making a loader on the amiga which loaded the samples used in the first 2 seconds of music from the boot track separately because by the time the loader had loaded track 1 and beyond, the samples would be present in time for the music to use them.
The result? The music started playing instantly you booted the game and the user thinks that the ENTIRE music got loaded instantly.
It's all about the context.

Login to post a reply

Server time is: 2024-04-25 21:47:19
Your offset time is: 2024-04-25 21:47:19