setscreen ("graphics:400,440;offscreenonly")
const maxxy : int := 400 %Allows there to be an area with no gameplay
var speed, x, y, dir, size, dx, dy, px, py : real
var facing, mx, my, mb, xsize, ysize, brickcol, count, offset, scol : int
var start, finished, m : boolean
var chars : array char of boolean
m := true %Music
offset := 180 %Where the bricks start
xsize := 40
ysize := 20
var bricks : array 1 .. maxx div xsize, 1 .. maxxy div ysize of int %Array that holds the number of hits per brick
var cheats : array 1 .. 5 of boolean %Whether a cheat is true or false
var cheatcodes : array 1 .. 5 of string %The codes needed to be entered per cheat
var cheatselect : string
const midx : int := maxx div 2
const midy : int := maxxy div 2
const sx := maxx - ysize %Where the sould logo is
const sy := maxy - ysize %Where the sould logo is
randint (facing, 240, 300) %Direction the ball starts moving in
cheatselect := "Enter a cheat code"
speed := 1
size := 5
dir := -intreal (facing) %Direction the ball starts moving in
%dir := 270
x := midx
y := midy div 2
dx := 1
dy := -1
py := 10
px := midx
count := 0
start := true
finished := false
for i : 1 .. 5 %Make all of the cheats inactive
cheats (i) := false
end for
cheatcodes (1) := "iwin" %Automatically win
cheatcodes (2) := "invisible" %Invisible paddle
cheatcodes (3) := "nocollisions" %Ball goes through bricks
cheatcodes (4) := "disco" %Bricks flash
cheatcodes (5) := "reversed" %Paddle moves oppositely
for i : 1 .. maxx div xsize %Make all of the bricks dead
for ii : 1 .. maxxy div ysize
bricks (i, ii) := 0
end for
end for
for i : 2 .. maxx div xsize %Make certain bricks alive
for ii : 1 .. (maxxy - 12 * ysize) div ysize
bricks (i, ii) := 1
count += 1
end for
end for
count -= 4
for i : 2 .. maxx div xsize %The bottom row of bricks that alternate solidity
for ii : 1 .. (maxxy - 19 * ysize) div ysize
if i mod 2 = 0 then
bricks (i, ii) := 3
else
bricks (i, ii) := 2
count += 1
end if
end for
end for
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Main Loop %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for lives : 1 .. 3 %Self-explanitory
loop
if cheats (1) = true then %Auto-win
count := 0
end if
Input.KeyDown (chars)
if chars (KEY_CTRL) then %Key to press to enter cheats
color (0)
locate (1, 10)
get cheatselect
end if
for i : 1 .. 5 %Checks if what you entered cooresponds to a cheat
if cheatselect = cheatcodes (i) then
cheats (i) := true
end if
end for
colorback (7)
drawfillbox (0, maxxy, maxx, 0, 0) %White background for playing field
if m = true then %Changes the color of the sound icon
scol := 10
else
scol := 12
end if
%speed += 0.0001
delay (0)
x += cosd (dir) * speed * dx %Makes the ball move relative to its direction and speed
y += sind (dir) * speed * dy %Makes the ball move relative to its direction and speed
for k : xsize .. maxx by xsize %Allows for brick collisions and drawing
for kk : ysize .. maxxy by ysize %Allows for brick collisions and drawing
var xx : int := k - xsize %Where the bricks are horizontally
var yy : int := (kk - ysize) + offset %Where the bricks are vertically
if bricks (k div xsize, kk div ysize) ~= 0 then %Checks if the brick is dead and if not goes on
if cheats (4) = false then %Disco bricks
brickcol := RGB.AddColor (0, 1 - bricks (k div xsize, kk div ysize) / 6, 1 - bricks (k div xsize, kk div ysize) / 6)
else %Brick colour depending on the amount of hits needed
brickcol := RGB.AddColor (Rand.Int (1, 100) / 100, 1 - bricks (k div xsize, kk div ysize) / 6, 1 - bricks (k div xsize, kk div ysize) / 6)
end if
drawfillbox (xx, yy, xx + xsize, ysize + yy, brickcol) %Draws the bricks
drawbox (xx, yy, xx + xsize, ysize + yy, 0) %Draws lines between the bricks
if x >= xx and x <= xx + xsize and y >= yy and y <= yy + ysize then %if the ball is within the bricks
if floor (x) = xx and cheats (3) = false or ceil (x) = xx + xsize and cheats (3) = false then %If it hit the left/right side and the no-collisions cheat was off
if dx = 1 then %Change the horizontal Direction
dx := -1
else
dx := 1
end if
end if
if floor (y) = yy and cheats (3) = false or ceil (y) = yy + ysize and cheats (3) = false then %If it hit the top/bottom side and the no-collisions cheat was off
if dy = 1 then %Change the vertical Direction
dy := -1
else
dy := 1
end if
end if
bricks (k div xsize, kk div ysize) -= 1 %Give a hit to the cooresponding brick
if bricks (k div xsize, kk div ysize) = 0 then %If the brick is dead make the overall bricks - 1
count -= 1
end if
if m = true then %If the music is on play a sound
if bricks (k div xsize, kk div ysize) = 0 then
Music.Sound (440, 1)
elsif bricks (k div xsize, kk div ysize) = 1 then
Music.Sound (400, 1)
elsif bricks (k div xsize, kk div ysize) = 2 then
Music.Sound (360, 1)
end if
end if
end if
end if
end for
end for
if start = true then % The 3/2/1 thing on startup
colorback (white)
color (7)
for i : 0 .. 3
locatexy (midx + 5, offset - ysize)
if i < 3 then
put 3 - i
if m = true then
Music.Play ("16c")
end if
else
put "GO!"
if m = true then
Music.Play ("16>c<")
end if
end if
View.Update
delay (1000)
if i = 3 then
start := false
end if
end for
end if
mousewhere (mx, my, mb) %Checks if you clicked on the sound logo
if mb = 1 and round (sqrt ((mx - sx + 5) ** 2 + (my - sy + 5) ** 2)) <= 13 then
if m = false then
m := true
else
m := false
end if
end if
if x - size < 0 then %Hits the left wall
if dx = 1 then
dx := -1
else
dx := 1
end if
if m = true then
Music.Sound (480, 1)
end if
elsif x + size > maxx then %Hits the right wall
if dx = 1 then
dx := -1
else
dx := 1
end if
if m = true then
Music.Sound (480, 1)
end if
elsif y - size < 10 and x > px - 20 and x < px + 20 then %If it hit the paddle
if dy = 1 then
dy := -1
else
dy := 1
end if
if m = true then
Music.Sound (300, 1)
end if
if dx = 1 then
dir += - ((x - px) * 2) %Chenge the balls direction based on where on the paddle it hits
else
dir += ((x - px) * 2)
end if
elsif y + size > maxxy then %If it hits the top
if dy = 1 then
dy := -1
else
dy := 1
end if
if m = true then
Music.Sound (480, 1)
end if
end if
if mx >= 20 and mx <= maxx - 20 then %Move the paddle to the mouse
if cheats (5) = false then
px := intreal (mx)
else
px := maxx - (intreal (mx)) %Reverse the paddle if the cheat is on
end if
elsif mx <= 20 then %Stop the paddle from going past the edge
px := 20
else
px := maxx - 20
end if
color (white)
put "Lives: ", 4 - lives
put "Bricks Left:", count
%put cheats (3)
%put cheatselect
drawfilloval (sx, sy, 3, 3, scol) %Drawing the sound logo
drawline (sx + 2, sy + 2, sx + 2, sy + 12, scol) %Drawing the sound logo
drawline (sx + 2, sy + 12, sx + 12, sy + 12, scol) %Drawing the sound logo
drawline (sx + 12, sy + 12, sx + 12, sy + 2, scol) %Drawing the sound logo
drawfilloval (sx + 10, sy, 3, 3, scol) %Drawing the sound logo
drawoval (sx + 5, sy + 5, 13, 13, scol) %Drawing the sound logo
if scol = 12 then
drawline (sx - 5, sy - 5, sx + 15, sy + 15, scol) %Drawing the sound logo
end if
drawfilloval (round (x), round (y), 5, 5, 7) %Drawing the ball
if cheats (2) = false then
drawfillbox (round (px - 20), round (py), round (px + 20), round (py - 5), 7) %Draw the paddle
end if
drawline (0, maxxy, maxx, maxxy, 7) %Draw a line at the top of the playing area
View.Update
cls
if count = 0 then %If there are no bricks, finish
finished := true
end if
exit when y < 0 or count = 0 %Exit when you miss the ball or you win
end loop
randint (facing, 240, 300) %Restart the game with one less live
dir := -intreal (facing) %Restart the game with one less live
%dir := 270
x := midx %Restart the game with one less live
y := midy div 2 %Restart the game with one less live
dx := 1 %Restart the game with one less live
dy := -1 %Restart the game with one less live
py := 10 %Restart the game with one less live
px := midx %Restart the game with one less live
start := true %Restart the game with one less live
speed := 1 %Restart the game with one less live
exit when finished = true %Close the main loop when you win
end for
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% End of Main Loop %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if count = 0 then
put "You win!"
if m = true then
Music.Play ("2ae8e4f+2e4g+1a")
Music.Play ("2a > 4a < 2d 4g 2d 4e <2a> 2d <4a 2c 1a ")
end if
else
put "You Lose!"
if m = true then
Music.Play ("<<4gf+f1e16efefefef1e")
end if
end if
|