Moving stuff around

derangedPEZ
Unregistered
 
Post: #1
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 cantSad

Any suggestions? Please help me

thanks in advance,
Ruben
Quote this message in a reply
Member
Posts: 145
Joined: 2002.06
Post: #2
Quote: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 cantSad
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).

"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!
Quote this message in a reply
derangedPEZ
Unregistered
 
Post: #3
blimey. i'm relatively new to programming, so what is a fixed-point integer? how do i declare it?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
Then just ignore the fixed-point suggestion Smile

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.
Quote this message in a reply
furballphat
Unregistered
 
Post: #5
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.
Quote this message in a reply
derangedPEZ
Unregistered
 
Post: #6
im programming on classic, so i guesss there arent any anti aliasersSmile 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
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Making monsters drop stuff when they die Kingbry 0 2,106 Sep 10, 2007 11:41 PM
Last Post: Kingbry
  Newbie question about libraries and unix stuff... WhatMeWorry 8 3,977 Jun 25, 2005 04:17 PM
Last Post: OneSadCookie