randomize timer()
sync on
sync rate 100
backdrop on
type objectdata
x as float
y as float
xspeed as float
yspeed as float
time as integer
endtype
rem globals
global ball as objectdata
global player1 as objectdata
global player2 as objectdata
global player3 as objectdata
global player4 as objectdata
ball.y = 240
ball.x = 320
ball.xspeed = rnd(1)+1
ball.yspeed = rnd(1)+1
player1.x = 590
player1.y = 240
player2.x = 50
player2.y = 240
player3.x = 320
player3.y = 430
player4.x = 320
player4.y = 50
Time = timer()
do
draw_pad(player1.x, player1.y)
draw_pad(player2.x, player2.y)
draw_padx(player3.x, player3.y)
draw_padx(player4.x, player4.y)
ball()
playercontrol()
center text 320, 240, "Time "+str$(second)
if timer() > Time+1000
inc second
Time = timer()
endif
if Ball.x < 15
center text 320, 200, "FAILED"
reset()
dec second, second
endif
if ball.y > 465
center text 320, 200, "FAILED"
dec second, second
reset()
endif
if ball.y < 15
center text 320, 200, "FAILED"
reset()
dec second, second
endif
if Ball.x > 625
center text 320, 200, "FAILED"
reset()
dec second, second
endif
sync
loop
function ball
inc ball.x, ball.xspeed
inc ball.y, ball.yspeed
`draw_ball
circle ball.x, ball.y, 1
circle ball.x, ball.y, 2
circle ball.x, ball.y, 3
circle ball.x, ball.y, 4
circle ball.x, ball.y, 5
if Ball.x > Player1.x -10 and Ball.x < Player1.x +10 and Ball.xspeed > 0
if Ball.y < Player1.y +25 and Ball.y > Player1.y -25
Ball.xspeed = Ball.xspeed -(Ball.xspeed * 2) - 0.2
if downkey() = 1 then Ball.yspeed = Ball.yspeed + 0.2
if upkey() = 1 then Ball.yspeed = Ball.yspeed - 0.2
endif
endif
if Ball.x < player2.x +10 and Ball.x > player2.x -10 and Ball.xspeed < 0
if Ball.y < player2.y +25 and Ball.y > player2.y -25
Ball.xspeed = abs(Ball.xspeed)+0.1
endif
endif
if Ball.y > Player3.y -10 and Ball.y < Player3.y +10 and Ball.yspeed > 0
if Ball.x < Player3.x +25 and Ball.x > Player3.x -25
Ball.yspeed = Ball.yspeed -(Ball.yspeed * 2) - 0.2
if downkey() = 1 then Ball.yspeed = Ball.yspeed + 0.2
if upkey() = 1 then Ball.yspeed = Ball.yspeed - 0.2
if leftkey() = 1 then ball.xspeed = ball.xspeed - 0.2
if rightkey() = 1 then ball.xspeed = ball.xspeed + 0.2
endif
endif
if Ball.y < player4.y +10 and Ball.y > player4.y -10 and Ball.yspeed < 0
if Ball.x < player4.x +25 and Ball.x > player4.x -25
Ball.yspeed = abs(Ball.yspeed)+0.1
endif
endif
endfunction
function draw_pad(x, y)
box x-10, y-25, x+10, y+25
endfunction
function draw_padx(x, y)
box x-25, y-10, x+25, y+10
endfunction
function playercontrol()
if upkey() = 1 then dec Player1.y , 5
if upkey() = 1 then dec Player2.y, 5
if downkey() = 1 then inc Player1.y, 5
if downkey() = 1 then inc Player2.y, 5
if rightkey() = 1 then inc player3.x, 5
if rightkey() = 1 then inc player4.x, 5
if leftkey() = 1 then dec player3.x, 5
if leftkey() = 1 then dec player4.x, 5
if Player1.y > 455 then player1.y = 455
if Player2.y > 455 then player2.y = 455
if player1.y < 25 then player1.y =25
if player2.y < 25 then player2.y =25
if player3.x < 25 then player3.x =25
if player4.x < 25 then player4.x =25
if player3.x > 615 then player3.x =615
if player4.x > 615 then player4.x =615
endfunction
function reset()
Ball.x =320
Ball.y =240
endfunction
i kinda did it my own way for the seconds to restart just the failed part does the same thing
also this game you control all 4 squares tryin to keep the ball in the middle (still needs alot of work as the ball increases every time it restarts )
can anyone help me do the message part when it hits the sides? just want that working first lol