#3331 - misehert - Sat Feb 22, 2003 10:29 pm
Sorry for this newbie post - maybe there should be a forum for stupid questions. o.k. I've gone through PERN and GBAJunkie tutorials, and have progressed to putting my own animated 32x32 sprite onto my own scrolling 512x512 background using C++ and gbadevkitadv.
I'm trying to do a pokemon movement like demo with the animated sprite glued in the middle, but when I do the animation, the sprite goes into hyper mode - even using the timer delays.
1) Does anyone know a tutorial or available source for slowing this guy down?
2) Then my next question is how to synchronise the sprite steps with the background scroll speed, so it does not look like it's on ice.
_________________
Sorry, I'm just a Stoopid Noobie...
thank god for video x 4 - i can see again
#3332 - darkcloud - Sat Feb 22, 2003 11:46 pm
Just lengthen the amount of time between frame changes. If your using the hardware timers, you can set them up like this (from PERN):
Code: |
REG_TMxCNT = TIME_FREQUENCY_1024 | TIME_ENABLE;
REG_TMxD = 0;
//then to change frames
if (REG_TMxD >= 16386/10)
{
//do frame switch code
REG_TMxD = 0;
}
|
16386 would be the value for one second so just divide that to get the speed between frames. After you switch frames reset the timer to 0 again so you can do it again.
I'm not really sure about the second question though, I would just do some trial and error until I get something I like.
_________________
Maybe in order to understand mankind, we have to look at the word itself: "Mankind". Basically, it's made up of two separate words - "mank" and "ind". What do these words mean ? It's a mystery, and that's why so is mankind.
#3338 - imikeyi - Sun Feb 23, 2003 2:01 am
If you base your code around the vblank, it should be simple.
IE Model your main game loop like this:
Code: |
while(1)
{
getControls();
updateSprites();
doMiscStuff();
for(i = 0; i < X; i++)
waitForVblank();
}
|
Then X = the speed of your game, where 1 is very fast and 60 is slow.
You could change the animation frame in updateSprites().
_________________
microkernel advance
#3348 - satanicfreak2 - Sun Feb 23, 2003 6:30 am
dont slow it down... instead draw the same one say 10-20 times. then draw the next one 10-20 times.
you can have a counter and when it reaches 20 switch to the next frame. and start the counter again. do this over and over again.
hope it helps
#3372 - CoolMan - Sun Feb 23, 2003 6:57 pm
There are several different ways to do it. For instance, in my game, I sync with VBLANK, and only switch the sprite frame every X number of frames. It all depends on coding style. Details, (actual numbers), depend on some information that you haven't provided.
Hope that helps.
_________________
Moron! You don't herd chickens with a shotgun!
--CoolMan
#3380 - misehert - Sun Feb 23, 2003 9:27 pm
Thanks for the suggestions - as crazy as it may sound, the draw 10 times each solved the problem because it doesn't pause the background scroll like the waits (of course I was probably still doing something wrong with the vblank).
Now I'm ready to move on to setting up my background boundaries using collision detection - I have staringmonkey's RPG demo source, so hopefully I'll get there. Wish me luck - or I'll be back.