View.Set ("graphics:max,max")
var size : int := 50
var mx, my, mb : int
var collidex, collidey:int
var ballx, bally : int := 500
var dirx, diry : int := 0
var ballSpeed : int := 1
var life: int:=0
var point:int:=0
% What box did we hit?????
% Ball direction after it hits paddle
% Change ball Speed
% Levels ??
% balls left
% Paddle size
% Score...box count
% Obsticles (Difficult)
dirx := ballSpeed
diry := ballSpeed
for x : 100 .. 800 by 100
for y : 300 .. 600 by 100
drawfillbox (x, y, x + 50, y + 30, red)
end for
end for
loop
delay (3)
mousewhere (mx, my, mb)
drawfillbox (mx - size, 0, mx + size, 50, black)
drawfillbox (mx - size - 1, 0, 0, 50, white)
drawfillbox (maxx, 0, mx + size + 1, 50, white)
drawfilloval (ballx, bally, 15, 15, white)
ballx += dirx
bally += diry
drawfilloval (ballx, bally, 15, 15, blue)
if ballx >= maxx then % right wall
dirx := - (dirx)
elsif bally >= maxy then % top wall
diry := - (diry)
elsif ballx <= 0 then % bottom
dirx := - (dirx)
elsif bally <= 0 then % left wall
diry := - (diry)
locate (1, 1)
put "lost ball"
put point
ballx := 200
bally := 200
life +=1
loop
mousewhere (mx, my, mb)
exit when mb = 1
end loop
end if
%paddle collision
if ballx > mx - size and ballx < mx + size and bally <= 66 then
diry := - (diry)
end if
for botx : 1 .. 30
if whatdotcolour (ballx - 15 + botx, bally - 16) = red then
diry := - (diry)
locate (1, 1)
point:=point+1
put "Brick Hit Top"
collidex:=ballx div 100
collidey:=bally div 100
collidex:=collidex *100
collidey:=collidey * 100
drawfillbox (collidex, collidey, collidex +50, collidey+30, white)
end if
end for
for topx : 1 .. 30
if whatdotcolour (ballx - 15 + topx, bally - 16) = red then
diry := - (diry)
locate (1, 1)
point:=point+1
put "Brick Hit Top"
collidex:=ballx div 100
collidey:=bally div 100
collidex:=collidex *100
collidey:=collidey * 100
drawfillbox (collidex, collidey, collidex +50, collidey+30, white)
end if
end for
for leftside : 1 .. 30
if whatdotcolour (ballx - 16, bally - 15 + leftside) = red then
dirx := - (dirx)
locate (1, 1)
point:=point+1
put "Brick Hit Left Side"
collidex:=ballx div 100
collidey:=bally div 100
collidex:=collidex *100
collidey:=collidey * 100
drawfillbox (collidex, collidey, collidex +50, collidey+30, white)
end if
end for
for rightside : 1 .. 30
if whatdotcolour (ballx - 16, bally - 15 + rightside) = red then
dirx := - (dirx)
locate (1, 1)
point:=point+1
put "Brick Hit Right Side"
collidex:=ballx div 100
collidey:=bally div 100
collidex:=collidex *100
collidey:=collidey * 100
drawfillbox (collidex, collidey, collidex +50, collidey+30, white)
end if
end for
% for baly : 1 .. 30
exit when life = 3
end loop
put "Game Over"