Write a program that bounces a ball across the screen...
Author |
Message |
sarmi123
|
Posted: Thu Dec 15, 2005 6:10 pm Post subject: 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). |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Thu Dec 15, 2005 6:24 pm Post subject: (No subject) |
|
|
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 Wink](images/smiles/icon_wink.gif) |
|
|
|
|
![](images/spacer.gif) |
sarmi123
|
Posted: Thu Dec 15, 2005 6:35 pm Post subject: (No subject) |
|
|
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 |
|
|
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Sat Dec 17, 2005 3:56 pm Post subject: (No subject) |
|
|
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:
This way, instead of just reversing it, you are reversing it an decreasing its magnitude by a bit. |
|
|
|
|
![](images/spacer.gif) |
|
|