Burbruee
Member
In my game, I have animated backgrounds of 32 frames that are repeating themselves over and over.
There are 10 levels, each with a new animated bg.
I have stored the bg frames for each level in a separate fpg, each fpg are about 2.5 MB in size if you compress them, otherwise 5 MB.
It works fine on the PC, a black screen for maybe 1 second and then the game will proceed.
On the GP2X, I must comment out the load_fpg section for levels over 3.
Even then, the game takes a while to load, if I put in the animated background for a fourth level, the game won't even start. Stays black for maybe 15 seconds and then it goes back to the menu.
This is okay, because of the way I have currently programmed it, it tried to load all fpgs upon boot. (roughly 25 MB if compressed)
Now, the way it works at the moment. It's a puzzle game, and for each 100 levels the background should change.
To optimize, I would like it to unload the previous fpg before the new background loads.
I'm having trouble implementing this.
Here's a code snippet from the bg() process:
CODE
PROCESS bg( x, y )
BEGIN
file = bg[0];
graph = 1;
z = 100;
bg[0] = load_fpg( "data/graphics/level0.fpg" );
bg[1] = load_fpg( "data/graphics/level1.fpg" );
bg[2] = load_fpg( "data/graphics/level2.fpg" );
bg[3] = load_fpg( "data/graphics/level3.fpg" );
bg[4] = load_fpg( "data/graphics/level4.fpg" );
bg[5] = load_fpg( "data/graphics/level5.fpg" );
bg[6] = load_fpg( "data/graphics/level6.fpg" );
bg[7] = load_fpg( "data/graphics/level7.fpg" );
bg[8] = load_fpg( "data/graphics/level8.fpg" );
bg[9] = load_fpg( "data/graphics/level9.fpg" );
loop;
graph++;
//maybe I could have used a for here for all this.. but I was very tired
if( curLvl >= 0 )
file = bg[0];
end;
if( curLvl >= 100 )
file = bg[1];
end;
if( curLvl >= 200 )
file = bg[2];
end;
if( curLvl >= 300 )
file = bg[3];
end;
if( curLvl >= 400 )
file = bg[4];
end;
if( curLvl >= 500 )
file = bg[5];
end;
if( curLvl >= 600 )
file = bg[6];
end;
if( curLvl >= 700 )
file = bg[7];
end;
if( curLvl >= 800 )
file = bg[8];
end;
if( curLvl >= 900 )
file = bg[9];
end;
frame(250);
end;
END
You can see why things are going bad right? Loading that much data at once... On the GP2X it's too much it seems.
What I would like to do is, in each of those ifs, unload the current and load the next, or something like it.
But.. Everything is in a loop. So it would be executed forever. Loading each fpg an unlimited amount of times. :rolleyes:
So, how can I best solve this?
Thanks.
There are 10 levels, each with a new animated bg.
I have stored the bg frames for each level in a separate fpg, each fpg are about 2.5 MB in size if you compress them, otherwise 5 MB.
It works fine on the PC, a black screen for maybe 1 second and then the game will proceed.
On the GP2X, I must comment out the load_fpg section for levels over 3.
Even then, the game takes a while to load, if I put in the animated background for a fourth level, the game won't even start. Stays black for maybe 15 seconds and then it goes back to the menu.
This is okay, because of the way I have currently programmed it, it tried to load all fpgs upon boot. (roughly 25 MB if compressed)
Now, the way it works at the moment. It's a puzzle game, and for each 100 levels the background should change.
To optimize, I would like it to unload the previous fpg before the new background loads.
I'm having trouble implementing this.
Here's a code snippet from the bg() process:
CODE
PROCESS bg( x, y )
BEGIN
file = bg[0];
graph = 1;
z = 100;
bg[0] = load_fpg( "data/graphics/level0.fpg" );
bg[1] = load_fpg( "data/graphics/level1.fpg" );
bg[2] = load_fpg( "data/graphics/level2.fpg" );
bg[3] = load_fpg( "data/graphics/level3.fpg" );
bg[4] = load_fpg( "data/graphics/level4.fpg" );
bg[5] = load_fpg( "data/graphics/level5.fpg" );
bg[6] = load_fpg( "data/graphics/level6.fpg" );
bg[7] = load_fpg( "data/graphics/level7.fpg" );
bg[8] = load_fpg( "data/graphics/level8.fpg" );
bg[9] = load_fpg( "data/graphics/level9.fpg" );
loop;
graph++;
//maybe I could have used a for here for all this.. but I was very tired
if( curLvl >= 0 )
file = bg[0];
end;
if( curLvl >= 100 )
file = bg[1];
end;
if( curLvl >= 200 )
file = bg[2];
end;
if( curLvl >= 300 )
file = bg[3];
end;
if( curLvl >= 400 )
file = bg[4];
end;
if( curLvl >= 500 )
file = bg[5];
end;
if( curLvl >= 600 )
file = bg[6];
end;
if( curLvl >= 700 )
file = bg[7];
end;
if( curLvl >= 800 )
file = bg[8];
end;
if( curLvl >= 900 )
file = bg[9];
end;
frame(250);
end;
END
You can see why things are going bad right? Loading that much data at once... On the GP2X it's too much it seems.
What I would like to do is, in each of those ifs, unload the current and load the next, or something like it.
But.. Everything is in a loop. So it would be executed forever. Loading each fpg an unlimited amount of times. :rolleyes:
So, how can I best solve this?
Thanks.
Last edited by a moderator: