Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help with shot trajectory
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
WhatAmIDoing




PostPosted: 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]


parabola shot.t
 Description:

Download
 Filename:  parabola shot.t
 Filesize:  1.07 KB
 Downloaded:  136 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: 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. Eh

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
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: