1. setPixel
- Posted by David Roach <roachd_76 at YAHOO.COM>
Feb 02, 2000
-
Last edited Feb 03, 2000
Can some one tell me how to set this up in a for loop
g=.5*32*1*1
v=200*1
y=y+g
x=x+v
setPixel( bullet, x,y , Blue)
Its to plot the path of a projectile. Or if any one knows an easier way
using.
these two equations that would be great.
y=.5 * g * t*t
x= v * t
__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com
2. Re: setPixel
Plotting the path of a projectile... I will give you some psuedocode so as
not to take the fun out of your programming experience.
variables:
v = initial velocity
a = initial angle from horizon
vx = initial velocity in x direction
vy = initial velocity in y direction
t = time
g = gravity ( tweak this value for whatever looks best )
vx = v * cos( a ) = a constant value (assuming no friction/wind)
vy = v * sin( a ) - g*t
as time (t) advances from zero, your object will be at:
x = v * cos( a ) * t
y = v * sin( a ) * t + g*t*t / 2
use the above equations to plot points as long as they are on the screen:
t = 0
x = initial x value
y = initial y value
while (x < MAX_X ) and (y < MAX_Y ) do
x = v * cos( a ) * t
y = v * sin( a ) * t + g*t*t / 2
plot( x, y )
t = t + 1 --(or t = t + time_increment)
end while
Keep in mind that Euphoria trig functions expect values in radians, not
degrees. To convert from degrees to radians, use:
r = d * PI / 180
where r = value in radians and d = value in degrees
hope this helps!
-- Brian
3. Re: setPixel
oops... one minor slip, the correct equation for the y component is:
y = v * sin( a ) * t - g*t*t / 2
and keep in mind that g is a positive value for this equation...
good luck!
-- Brian
4. Re: setPixel
----- Original Message -----
From: Brian Broker <bkb at CNW.COM>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Thursday, February 03, 2000 3:48 AM
Subject: Re: setPixel
> Plotting the path of a projectile... I will give you some psuedocode so
as
> not to take the fun out of your programming experience.
>
> g = gravity ( tweak this value for whatever looks best )
>
> vx = v * cos( a ) = a constant value (assuming no friction/wind)
These depend a good deal on altitude, of course.
Kat,
*not* thinking of building a missle.