Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)
You are not logged in.
Hello to everybody.
I'm developing my first game using GBDK, and I have some questions related to coding strategies to improve speed of my game.
Currently, I'm using an array of struct to store coordinates of enemy shots (size:10), and another one to store enemies position (size:15). But when there's more than 10 elements on screen, tha game speed is affected dramatically.
Now, I'm checking positions each 10 frames, but I want to know if there's a better way to store and check sprites data.
Thanks a lot for your help
Offline
If you are iterating over an array of structs, I think (I checked several years ago) it was a good idea to do this:
p = &array[0]; for (int i = 0; i < elements; i++) { // do things with p magic = p->x + p->y; // etc p++; }
Rather than this:
for (int i = 0; i < elements; i++) { // do things with p[i] magic = p[i].x + p[i].y; // etc }
In the second case I think the compiler added multiplications when calculating the base address of each element.
It's hard to tell you what the problem may be and how to fix it. The CPU is just not too fast, and using C doesn't help.
Last edited by AntonioND (2019-12-04 17:44:29)
Offline
If you're still trying to get more performance out of your game, I would recommend spreading out all the position checks. Instead of doing all of them every tenth frame, maybe some of them at a more frequent interval to distribute the workload more evenly. Something as simple as alternating between checking odds and evens and checking every fifth frame.
Offline
Thanks for the idea, Ardis.
Programming using '90s technology is a complete challenge, but it's fun. And working only with 4 colours is a handicap too
Offline