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 > Moving rot/scale sprites

#82191 - redcode - Thu May 04, 2006 2:41 pm

I am currently making an Escape Velocity style game (Link http://www.ambrosiasw.com/games/ev/) on GBA. I have my sprite on-screen and it rotates fine, but I now have a problem:

Moving the sprite around. Actually I want to scroll the background under the sprite, while the sprite remains static. But I need to base the direction of scrolling on the angle the sprite is facing.

How is this done? If someone could point me towards some top-down shooter type examples that would be nice. A full tutorial would be nicer. ;)

#82203 - poslundc - Thu May 04, 2006 3:55 pm

X component to scroll = cos(angle)
Y component to scroll = sin(angle)

Multiply both by the scroll velocity.

Use fixed-point math for everything.

Dan.

#82217 - redcode - Thu May 04, 2006 4:34 pm

Thanks. :)