PDA

View Full Version : Moving stuff around


derangedPEZ
2002.08.16, 06:31 PM
Hi, I've been trying to think of a way to move something (a sprite) from one point to another. And now, I'm out of ideas.
Here's the scenario:
the sprite has two variables (int) descibing it's movement speed. hSpeed and vSpeed
for every frame drawn, hSpeed and vSpeed is added to the hLocation and vLocation of the sprite.

Now, how do I calculate the hSpeed and vSpeed in order to get the most accurate movement? In real life you would use decimal numbers, but when working with pixles, you cant:(

Any suggestions? Please help me

thanks in advance,
Ruben

inio
2002.08.16, 07:12 PM
Originally posted by derangedPEZ
Now, how do I calculate the hSpeed and vSpeed in order to get the most accurate movement? In real life you would use decimal numbers, but when working with pixles, you cant:(Why can't you? Why not store the location and velocity as pairs of floats? You could also use fixed-point integers (24.8 would probably be enough).

derangedPEZ
2002.08.17, 07:26 AM
blimey. i'm relatively new to programming, so what is a fixed-point integer? how do i declare it?

OneSadCookie
2002.08.17, 07:30 AM
Then just ignore the fixed-point suggestion :)

Just use floats or doubles, and just convert them to integers (either by rounding or by rounding down) when you need pixel coordinates. It'll be close enough to look right.

furballphat
2002.08.17, 07:47 AM
If you're using quartz you can input the coordinates directly as floats. The antialiaser will draw it slightly differently depending on the exact float coordinates.

derangedPEZ
2002.08.17, 07:54 AM
im programming on classic, so i guesss there arent any anti aliasers:) I'm currently experimenting with another spritepackage (spriteworld) as it looks better and is being updated more often than SAT. and i think i just found an example application that explains how to deal with my problem, but thanks for the support