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

Username:   Password: 
 RegisterRegister   
 parabolic arch needed in this dont know how to put it in
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
waleedalidogar




PostPosted: Wed Dec 14, 2005 6:55 pm   Post subject: parabolic arch needed in this dont know how to put it in

my code is:

setscreen ("graphics:max;max")
loop
var x : int
var y : int
x := 10
y := 600
var yLimit : int
yLimit := 400
for i : 1 .. 15
y := yLimit
loop

drawoval (x, y, 30, 30, brightblue)
delay (15)
cls
x := x + 2
y := y - 10
exit when y <= 25
end loop
yLimit := yLimit - 30
loop
drawoval (x, y, 30, 30, brightblue)
delay (15)
cls
x := x + 1
y := y + 10
exit when y >= yLim
Sponsor
Sponsor
Sponsor
sponsor
Paul




PostPosted: Wed Dec 14, 2005 7:22 pm   Post subject: (No subject)

1. This is the wrong from to be posting in, post in the turing help forum.
2. put your code in code boxes like the following.
3. Remember you're not trying to program a parabolic trajectory, as the trajectory is a result of gravity, so you're trying to simulate gravity. Think about it and its easy.

Here's something I quickly wrote up.:
code:

setscreen ("graphics: max; max")
var Hspeed, Vspeed, Haccel, Vaccel, Posx, Posy, Decay: real
Hspeed:=3
Vspeed:=0
Haccel:=0
Vaccel:=-0.2%force of gravity
Posx:= 100
Posy:= maxy-200
Decay:= 0.75


loop
Draw.FillOval (round(Posx), round(Posy), 10, 10, brightred)
Hspeed+=Haccel
Vspeed+=Vaccel
Posx+=Hspeed
Posy+=Vspeed

if Posy-11 <= 0 then
Posy:= 11
Vspeed:= -Vspeed*Decay
end if
delay (10)
end loop

Cervantes




PostPosted: Wed Dec 14, 2005 7:30 pm   Post subject: (No subject)

Moved.
Don't forget to indent, Paul. Wink

waleedalidogar: Please use [ code][ /code] tags when posting code. Or better yet, [ syntax="turing"][ /syntax] tags.

If you're trying to simulate gravity, try Paul's approach. If you really do want to make a parabola, well, why are you adding constant values to x and y? Incriment x, and calculate y based on the equation of your parabola. Ex.
code:

var x := 0.0
var y : real

loop
    x += 0.1
    y := -(x - maxx div 2)**2 + maxy div 1.5
    Draw.FillOval (round (x), round (y), 10, 10, black)
    delay (10)
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  [ 3 Posts ]
Jump to:   


Style:  
Search: