Help with shot trajectory
Author |
Message |
WhatAmIDoing
|
Posted: Tue Feb 01, 2005 12:20 pm Post subject: Help with shot trajectory |
|
|
Well it's been along time since i've been on here but here i am again and i need some help i was reluctant to ask for help but after going to several of my teachers and them telling me that they had no-idea how to do this i'm posting to ask for help. i'm currently making a scorch game and it works but i'm trying to perfect the equation for the shot. so far all i do is take the power of the shot and divide by 9.8^2 then times by 100 to get how many pixels tall the parabola is. the to get the x value for how long the parabola is i divide the y by 2. i have the rough version of my new equation but it's not working so i was wondering if any of you guys new how to fix it?[/code]
Description: |
|
Download |
Filename: |
parabola shot.t |
Filesize: |
1.07 KB |
Downloaded: |
138 Time(s) |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Cervantes
|
Posted: Tue Feb 01, 2005 3:59 pm Post subject: (No subject) |
|
|
Wrong Forum. You want to be in Turing Help.
Why not use the formula for a parabola?
y = a(x - k)^2 + q
(I'm not sure if I've got the variables correct. I kinda forget.
Or, you could make it work graphically:
Turing: |
%based on homer_simpson's code
setscreen ("graphics:max;max,nobuttonbar")
var t := 0. 0
type projectile_t :
record
x, y, v, a, w, startx, starty : real
end record
var shell : projectile_t
shell.x := 0
shell.y := 50
shell.startx := 0
shell.starty := 50
put "Enter shell's angle : " ..
get shell.a
put "Enter shell's velocity : " ..
get shell.v
put "Enter shell's weight : " ..
get shell.w
procedure Projectile (var obj : projectile_t, t : real)
obj.x := (obj.v * cosd (obj.a ) * t ) + obj.startx
obj.y := (obj.v * sind (obj.a ) * t - (obj.w ) * t ** 2 / 2) + obj.starty
end Projectile
setscreen ("offscreenonly")
loop
cls
t + = 0. 1
Projectile (shell, t )
drawfilloval (round (shell.x ), round (shell.y ), 10, 10, black)
View.Update
delay (10)
exit when shell.y <= 0
end loop
|
|
|
|
|
|
|
|
|