pls help me wit my program
Author |
Message |
shoobyman
![](http://compsci.ca/v3/uploads/user_avatars/1894631788463006b596f19.gif)
|
Posted: Wed Jan 11, 2006 9:08 am Post subject: pls help me wit my program |
|
|
ok this is my program, i need help to make the ball bounce off of the paddle :
var x, y, button : int
var paddleHEIGHT: int:=5
var objectVX, objectVY, x2, y2 : int
objectVY := 10
objectVX := 10
x2 := maxx div 2
y2 := maxy div 2
const ballRad : int := 5
setscreen ("offscreenonly")
loop
delay (30)
cls
mousewhere (x, y, button)
drawfillbox (x,13,x+60,paddleHEIGHT,black)
drawfilloval (x2, y2, ballRad, ballRad, black)
x2 += objectVX
y2 += objectVY
if x2 > maxx - 5 then
objectVX := -objectVX
elsif x2 < 5 then
objectVX := -objectVX
elsif y2 > maxy - 5 then
objectVY := -objectVY
elsif y2 < 5 then
objectVY := -objectVY
end if
View.Update
end loop |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
codemage
![](http://usera.imagecave.com/codemage/codemage-small.gif)
|
Posted: Wed Jan 11, 2006 10:35 am Post subject: (No subject) |
|
|
Do a search for pong. There have been many, many posts about this already - where you can find your answer. |
|
|
|
|
![](images/spacer.gif) |
do_pete
![](http://i38.photobucket.com/albums/e112/do_pete/1943.gif)
|
Posted: Wed Jan 11, 2006 10:38 am Post subject: (No subject) |
|
|
Whenever the ball hits a paddle go
|
|
|
|
|
![](images/spacer.gif) |
pavol
|
Posted: Wed Jan 11, 2006 10:50 am Post subject: (No subject) |
|
|
use an if statement to check where the ball is. ex:
code: | if x2 > x and x2 < x + 60 and y2 < 13 then
y2 := -y2
end if |
|
|
|
|
|
![](images/spacer.gif) |
|
|