I’ve spent the last couple of weeks on and off trying to ‘slimline’ Underlord.
Now, what I write here is going to shock those of you that have been writing games for a while. Shock you and probably make you collapse laughing. Please, however, bear in mind a couple of things…
1) I’ve been coding games for only a year.
2) Underlord is my first scroller and only my 3rd game.
3) I’ve got absolutly no idea what I’m doing until I try something.
Are you sitting down? Good………
I had reason during testing some code to go to the windows task manager and terminate the Underlord process. It’s not something I’ve conciously had to do until then so I would normally not look. I saw immediatly why the game was running ‘sluggishly’. 99% cpu usage, mmm, OK, not good, BUT RAM useage of close to 300MB.
There you go, picked yourself up yet?
What to do? Well, I’ll keep it brief. The issue is I was stupidly loading all the levels into bitmap and blitting just the bit of the map I needed to the buffer.
This wouldn’t be so much of an issue if the following were not true…
There are 9 levels
Each level is 8000 pixels wide
Each level has a background, object map, foreground AND NPC map
My maths is bad, but I make that 36 8000 pixel wide bitmaps loaded into memory ALL THE TIME
Not only was it hoarding memory, loadtimes were suffering.
Anyway, I’m now just blitting tiles directly to the buffer and, lordy lordy, RAM useage is down to 20MB. Performance issues should be less obvious now!
Onwards and upwards!