
-----------------------------------
waleedalidogar
Wed Dec 14, 2005 9:21 pm

need help in making the ball bounce in a parabolic
-----------------------------------
need help in making the ball bounce in a parabolic

loop     % This tells the program to start the loop.
    var x, y, c, i, r, p : int     %This is a variable it makes a space in the memory for the x, y, c, i, r, p;
    %I selected int because i know the input has to be in integers.
    var n, e, s : string     %This is a variable it makes a space in the memory for the n, e, s;
    %I selected string because i know the input has to be in letters.
    put "Welcome to Waleed's bouncing ball program"     % This displays the text on the run screen.
    put "  "     % This displays the text on the run screen.
    put "What is your name?"     % This displays the text on the run screen.
    get n     % This gets the input from the user for the n.
    put "Hi, ", n     % This displays the text on the run screen with the n.
    put n, ", What colour do you want the ball to be?(give a number 1=Blue, 10=Green, 15=grey, 255=Black or a number between 1-255) "     % This displays the text on the run screen with the n.
    get p     % This gets the input from the user for the p.
    put n, ", How big do you want the ball to be?(1-50)"     % This displays the text on the run screen with the n.
    get r     % This gets the input from the user for the r.
    put n, ", How fast do you want the ball to move?(1-30)"     % This displays the text on the run screen with the n.
    get i     % This gets the input from the user for the i.
    x := 10     % This declares what x is.
    y := 600     % This declares what y is.
    var yLimit : int     % This sets the yLimit which means that the highest point the ball can reach.
    yLimit := 400     % This declares what the ylimit is for the next for loop.
    for cnt : 1 .. 15     % This is a for loop; it sets cnt as a variable and tells it to do something 15 times.
        y := yLimit     % This declares what y is equal to; y=yLimit.
        loop     % This tells the program to loop itself.
            drawfilloval (x, y, r, r, p)     % This tells the program to draw an oval and fill it, in which all the measurements are given by the user.
            delay (i)     % This delays the program for i seconds; i is a variable.
            drawfilloval (x, y, r, r, white)     % This tells the program to draw an oval and fill it, in which all the measurements are given by the user.
            x := x + 2     % This declares what x is.
            y := y - 10     % This declares what y is.
            exit when y = yLimit.
        end loop     % This tells the program to end the loop.
        exit when cnt maxx or x< 0 then
        dx*=-1
    end if
    if y< 0 then
        dy*=-1
    end if
    cls
    drawfilloval(round(x),round(y),10,10,4)
    delay(20)
end loop  


-----------------------------------
Paul
Wed Dec 14, 2005 9:58 pm


-----------------------------------
Er actually, I didn't know cervantes moved it.
I would encourage you to stop making multiple posts of the same topic.
Here's my code again :P

setscreen ("graphics: max; max") 
setscreen ("offscreenonly")
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) 
delay (10) 
View.Update
Draw.FillOval (round(Posx), round(Posy), 10, 10, white) 
Hspeed+=Haccel 
Vspeed+=Vaccel 
Posx+=Hspeed 
Posy+=Vspeed 

if Posy-11 