Moving stuff around
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
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
Quote:Originally posted by derangedPEZWhy 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).
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
"He who breaks a thing to find out what it is, has left the path of wisdom."
- Gandalf the Gray-Hat
Bring Alistair Cooke's America to DVD!
blimey. i'm relatively new to programming, so what is a fixed-point integer? how do i declare it?
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.

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.
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.
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
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
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Making monsters drop stuff when they die | Kingbry | 0 | 1,930 |
Sep 10, 2007 11:41 PM Last Post: Kingbry |
|
| Newbie question about libraries and unix stuff... | WhatMeWorry | 8 | 3,702 |
Jun 25, 2005 04:17 PM Last Post: OneSadCookie |
|

