GP32 Animating A Slowly Counting Score


solarice

Member
Joined
Jan 29, 2004
Messages
120
Location
UK
Website
Visit site
right lets see if i can explain this so you can understand me :)

im using a strip of sprites to act as the on screen score, and at the moment ive got it coded to work with the select button, for testing purposes only. so when select is pressed it updates the 1's until it reaches 9 then resets to 0 and updates the 10's by one and so on. creating a score the slowly counts up, which is what i want it to do. However when i give it code to say add 100 to the score it runs through so quickly that all it does is display the 100pts in the score instead of the gentle addition upto 100.

Has anyone got any ideas on how i can fix this to create a slowly adding score. timers dont seem to make any difference.

Hopefully you can understand what im on about, and if you can thanks for any help you can provide.
 
I only program in Visual Basic but I get the same problem at times. the problem may be the order that your coding is in. Meaning that the coding goes

if its past 9 go to 10
then it continues and goes to
if its past 10 go to 11 etc.

you have to flip the code up side down so that it scans your code and only does one addition for every time you press it. This isnt easy to explain ummm....
if the code said:

if 1 goto 2
if 2 goto 3
if 3 goto 4
if 4 goto 5
if 5 goto 6

then the process would go from 1 to 2 but then instantaneously from 2 to 3, then 3 to 4 etc so in a split second it would go from 1 to 6

if the code read

if 5 goto 6
if 4 goto 5
if 3 goto 4
if 2 goto 3
if 1 goto 2

then it would scan the process and hit the bottom, make it 2 - STOP
then next time it would hit "if 2 goto 3" and change to 3. the next line is no longer appropriate to the variable so it STOPS AGAIN

I hope this is right, dont wanna confuse you with a stupid idea.

(I only know VB and would appreciate any help on learning C or C++ I REALLY WANNA PROGRAM FOR MY LITTLE BABY THAT IS MY GAMEPARK)
 
Maybe something like this?



unsigned int t0,t1;

while(score < newScore)
{
score++;
displayScore();

t0 = GpTickCountGet();
do
{
t1 = GpTickCountGet() - t0;
} while(t1 < 1000); //about 1 second
}
 
If the timer code isn't working for you, you could just have something like:

If select is pressed a++;

if (a>100) score++, a=0;

That should slow it down by 100x

-Craig
 
to slow down some part of my code i use the same principa as craigix

example:

if (jeu.TEMPS){
++jeu.CHRONO;
if (jeu.CHRONO==20){
jeu.CHRONO=0;
--jeu.TEMPS;
if (jeu.TEMPS==0){
mort_hero();
for (i=0;i<jeu.NB_MECHANT;++i)
mort_mechant(i);
}
}
}

here i slow down the count time in a game
 
Are you sure you are updating your framebuffer between each increment? You could be just doing all that offscreen and then you won't see any of that change. Unitl it's finished.
 
thanks for the replies. i'll test out your ideas tomorrow and let you know if i can get it doing what i want it to.


Daz_Genetic yeah im pretty sure everythings being displayed as it should, as ive got other animated sprite on screen running at the same time.


birdofprey just to let you know ive only been coding in c and c++ for a few months now on and off and still have very little idea of what im actually doing :D . i just worked on ricos tutorials and then jumped in the deep end. Probably not the best idea but it sort of working for me, go on give it a shot you know you want to :D.

The best bit is when you see your own code running on the gp32_console
 
Hi, i do this quite diffrent in TinyTetris.
I have a variable named score, scoretoadd
and displayscore.

If the player gets some points, they are
added to score and scoretoadd.

Within every frame, i add 2 points
to the displayscore var.
-> I use a fixed framerate (14fps).

The result looks quite fluent.

You can download the code at
ttetris.sourceforge.net
 
just to let you's know ive got it working...craigix's code seems to be doing the trick. But i'll look into the tinytetris code aswell.
 
Back
Top