
-----------------------------------
shoobyman
Wed Jan 11, 2006 9:08 am

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

-----------------------------------
codemage
Wed Jan 11, 2006 10:35 am


-----------------------------------
Do a search for pong.  There have been many, many posts about this already - where you can find your answer.

-----------------------------------
do_pete
Wed Jan 11, 2006 10:38 am


-----------------------------------
Whenever the ball hits a paddle go
Ball_X_Speed *= -1

-----------------------------------
pavol
Wed Jan 11, 2006 10:50 am


-----------------------------------
use an if statement to check where the ball is. ex:
if x2 > x and x2 < x + 60 and y2 <  13 then 
    y2 := -y2
end if 
