Since I don't mind reinventing the wheel for the sake of learning something I've been working on a small engine/framework as a foundation to work on some simple games. When I was working on my imageLoading manager (part of the resourceLoading bundle), at the moment I have it set up in a way that once a image is loaded, its temp. held (in memory) by the program as long as its running. If a call asks for an image that hasn't been loaded yet, it does so, else it returns the copy that was loaded and stored in a hashmap (which essentially is in memory).
I've also done pretty much the same for my audioResourceLoading manager.
Now what I'm thinking of implementing down the road is that the imageLoading manager only holds image files that are under a certain size or animations (other things like static backgrounds can be reloaded if needed).
And as for the audio, if its sound effects its pre-loaded onto a clip and therefore its held in memory. But for large audio files like background music, I'm thinking of maybe streaming it and buffering it so that its played as its loaded, with a sourceDataLine.
One thing I'm wondering is, I know when i load an image and an instance is presenting it on the screen (using it as representation), its being held in memory. Now if I'm putting a copy of it in a hashmap will that copy be in memory as well? or is it using the same memory space as the first one that was loaded? Same goes for when I create other instances that use this same image as a representation. Does anyone know?
And yes I know tools like Slick2D handle all this resource loading stuff for you (or so I've read), but I'm mostly doing it for the learning experience. For example to get that audioLoader going I learned a great deal of the sound API.
So yeah, just wanna hear some thoughts on this. ;D
s.MasonMember Since 25 Jul 2012
Offline Last Active Aug 22 2012 06:13 PM
- Group Members
- Active Posts 12
- Profile Views 1,002
- Submitted Links 0
- Member Title Member
- Age Age Unknown
- Birthday Birthday Unknown