%Designed By Mike Petrov and Scott Smith
View.Set ("offscreenonly")
var boxesbroken : int := 0
var boxcolor : int := 30
var mx, my, button : int %Mouse
var x, y, colo : int %Paddle
var blx, bly, speed : real %Ball
var ball : boolean := false
var borderx1, bordery1, borderx2, bordery2 : int
var bangle : real := 75
speed := 3
var works : boolean := true
var xbound, ybound : int
xbound := 10
ybound := 6
var box : array 1 .. xbound, 1 .. ybound of boolean
for i : 1 .. xbound
for j : 1 .. ybound
box (i, j) := true
end for
end for
borderx1 := 3
bordery1 := 5
borderx2 := maxx - 2
bordery2 := maxy - 5
colorback (black)
cls %Clears the screen making it black
x := (maxx div 2) - 50
y := 10
colo := 0
blx := (maxx div 2) - 50
bly := 20
%-------------------------PROCEDURES START-------------------------------
procedure DrawBoxes ()
for i : 1 .. xbound
for j : 1 .. ybound
if box (i, j) = true then
drawfillbox (borderx1 + i * 4 + i * 59, bordery2 - j * 4 - j * 15, borderx1 +
i * 4 + (i - 1) * 59, bordery2 - j * 4 - (j - 1) * 15, boxcolor)
end if
end for
end for
end DrawBoxes
%------------------------------------------------------------------------
procedure FindBox (fbX, fbY : int)
for i : 1 .. xbound
for j : 1 .. ybound
if fbX <= borderx1 + i * 4 + i * 59 and fbX >= borderx1 + i * 4 + (i - 1)
* 59 and fbY >= bordery2 - j * 4 - j * 15 and fbY <= bordery2 - j * 4 - (j - 1)
* 15 then
boxesbroken := boxesbroken + 1
if boxesbroken = xbound * ybound then
works := false
put "You Won"
end if
box (i, j) := false
end if
end for
end for
end FindBox
%------------------------------------------------------------------------
procedure calculatexy (var x, y : real, angle, step : real)
x := step * cosd (angle) + x
y := step * sind (angle) + y
end calculatexy
%------------------------------------------------------------------------
procedure CollisionDetect (cdX, cdY : real, var cdAngle : real)
if cdX <= borderx1 + 4 and cdAngle <= 180 then %Left Border + down
cdAngle := 90 - (cdAngle - 90)
elsif cdX <= borderx1 + 4 and cdAngle >= 180 then %Left Border + up
cdAngle := 270 + (270 - cdAngle)
elsif cdX <= x + 25 and cdX >= x - 25 and cdY <= 20 then
cdAngle := 360 - cdAngle
elsif cdY <= bordery1 + 4 then %Down Border
color (0)
put "YOU LOSE!" ..
works := false
elsif cdY >= bordery2 - 4 then %Up Border
cdAngle := 360 - cdAngle
elsif cdX >= borderx2 - 4 and cdAngle <= 180 then
cdAngle := 90 - (cdAngle - 90)
elsif cdX >= borderx2 - 4 and cdAngle >= 180 then
cdAngle := 270 + (270 - cdAngle)
end if
if whatdotcolor (round (cdX), round (cdY + 3)) = boxcolor then
if cdAngle < 180 then
cdAngle := 360 - cdAngle
else
end if
FindBox (round (cdX), round (cdY + 3))
end if
end CollisionDetect
%------------------------------------------------------------------------
procedure drawborders ()
drawbox (borderx1, bordery1, borderx2, bordery2, white)
drawbox (borderx1 - 1, bordery1 - 1, borderx2 + 1, bordery2 + 1, white)
end drawborders
%------------------------------------------------------------------------
%------------------------------------------------------------------------
Draw.FillBox (x, y, (x + 50), (y + 10), colo) % Paddle
Draw.FillOval ((round (blx) + 25), (round (bly) + 19), 8, 8, colo) %Ball
loop
Mouse.Where (mx, my, button)
cls
DrawBoxes ()
drawborders ()
if mx >= (borderx1 + 25) and mx <= (borderx2 - 25) then
x := mx
if ball = false then
blx := mx
end if
elsif x >= (borderx1 + 25) and mx < (borderx1 + 25) then
x := borderx1 + 25
if ball = false then
blx := x
end if
elsif x <= (borderx2 - 25) and mx > (borderx2 - 25) then
x := borderx2 - 25
if ball = false then
blx := x
end if
end if
if ball = false then
if button = 1 then
ball := true
calculatexy (blx, bly, bangle, speed)
end if
else
if button = 1 then
speed := speed + 0.05
end if
calculatexy (blx, bly, bangle, speed)
CollisionDetect (blx, bly, bangle)
end if
Draw.FillBox ((x - 25), y, (x + 25), (y + 10), colo) %Paddle
Draw.FillOval (round (blx), round (bly) + 4, 4, 4, colo) % Ball
View.Update
exit when works = false
delay (10)
end loop
|