Gameboy Development Forum

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.

Ads

#1 2019-12-04 17:33:17

jdsoft
Member
Registered: 2019-12-04
Posts: 10

Improve performance

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

 

#2 2019-12-04 17:43:36

AntonioND
Member
Registered: 2014-06-17
Posts: 134
Website

Re: Improve performance

If you are iterating over an array of structs, I think (I checked several years ago) it was a good idea to do this:

Code:

p = &array[0];
for (int i = 0; i < elements; i++)
{
    // do things with p
    magic = p->x + p->y;
    // etc

    p++;
}

Rather than this:

Code:

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

 

#3 2019-12-11 17:17:13

jdsoft
Member
Registered: 2019-12-04
Posts: 10

Re: Improve performance

Great! Thanks a lot smile

Offline

 

#4 2019-12-11 22:58:02

Ardis
Member
From: USA
Registered: 2019-06-06
Posts: 60
Website

Re: Improve performance

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.


Also known as Arvex in other places.

Interceptor (Demo)
https://arvex.itch.io/interceptor

Offline

 

#5 2019-12-14 16:30:11

jdsoft
Member
Registered: 2019-12-04
Posts: 10

Re: Improve performance

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 tongue

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson