
-----------------------------------
sarmi123
Thu Dec 15, 2005 6:10 pm

Write a program that bounces a ball across the screen...
-----------------------------------
NEED HELP TO..Write a program that bounces a ball across the screen. The height of the bounces should decrees on each bounce ( like the cards after winning a game of solitaire).

-----------------------------------
Cervantes
Thu Dec 15, 2005 6:24 pm


-----------------------------------
Welcome to CompSci.ca. :)

Know that we don't do homework for people.  What have you got so far?  We'll help, but not do the entire thing and then hand it to you on platter.  :wink:

-----------------------------------
sarmi123
Thu Dec 15, 2005 6:35 pm


-----------------------------------
setscreen ("graphics:max;max")

var firstx, firsty : real

var x, y : real := 100

firstx := 3

firsty := 13

loop

    x := firstx + x

    firsty := firsty - 1

    y := firsty + y

    if x > maxx or x < 0 then

        firstx := -1 * firstx

    end if

    if y < 0 then

        firsty := -1 * firsty

    end if

    drawfilloval (round (x), round (y), 20, 20, 103)

    delay (20)

    cls

end loop

%This is wht i have so far... but i need to make dis program bounce really high n come down lower n lower and finish at a really low part by da end of da screen

-----------------------------------
Cervantes
Sat Dec 17, 2005 3:56 pm


-----------------------------------
Thanks for posting your problem, and the exact same code, twice more.  (read with great sarcasm.)  They've been removed.

All you have to do is decrease the y_velocity of the ball.  It seems that you are using "firsty", whatever that means, for your velocity.  Replace the contents of your your if y < 0 statement:

firsty *= -0.98

This way, instead of just reversing it, you are reversing it an decreasing its magnitude by a bit.
