gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > Sprite Velocity Problems

#17324 - gbawiz - Sat Mar 06, 2004 12:09 pm

Hello all,
I have a question which has continued to bug me for a while.
It regards having more than one sprite with their own speed settings, I want the different sprites to move at different speeds.
The first thing that springs to mind is to add more pixels to the current position, for example moving right:
sprite_Avelocity =1 which will add 2 pixels to the current x coord of sprite_A.
sprite_Bvelocity =5 which will add 5 pixels to the current x coord of sprite_B.

This creates a couple of other problems, not only does the movment appear jerky but it totally messes up the collision detection which should only test one pixel at a time and by skipping 5 pixels then the sprite can, in effect, walk through solid objects.

My sprites are updated and tested every loop of the game.

Is there a method which I can use so that the collision detection will work, make the sprites move smoothly and at different speeds?

Many thanks
GbaWIZ

#17331 - poslundc - Sat Mar 06, 2004 2:30 pm

There is. Use fixed point math.

Dan.