Here's my entry for the Breakout Challenge. I haven't playtested it very much, so my level design might suck. But... you can design your own levels! I've attached a zipped up text file of the source, in case cutting and pasting from this snippet doesn't work so well.
` Project: Breakout Challenge by Rich Dersheimer
` Started: Wednesday, November 18, 2009
set display mode 800,600,32
disable escapekey
gosub InitializeVariables
gosub MakeFiles
gosub LoadFiles
gosub MakeGraphics
gosub MakeBackdrop
sync on
sync
nGameMode = 0
`********************************************************
` main program loop *************************************
`********************************************************
do
if nGameMode = 0 then gosub StartScreen
if nGameMode = 1 then gosub PlayGame
if nGameMode = 2 then gosub EditGame
if nGameMode = 3 then gosub EndGame
loop
`********************************************************
` end of main program loop ******************************
`********************************************************
end
`*******************
StartScreen:
show mouse
` get difficulty level
do
ink cBlack,cBlack
box 320,400,480,430
box 200,400,300,430
box 500,400,600,430
box 300,450,500,480
box 300,500,500,530
ink cWhite,cBlack
center text 400,350,"Choose your difficulty level"
center text 400,400,"NORMAL"
center text 250,400,"EASY"
center text 550,400,"HARD"
center text 400,450,"START EDITOR"
center text 400,500,"QUIT GAME"
nDiffChoice = 0
if keystate(1) ` ESC key - quit game
for x = 1 to 3
delete sound x
next x
undim Brick()
end
endif
if mousex()>=300 and mousex()<=500 and mousey()>=500 and mousey()<=530
nDiffChoice = 7
ink cWhite,cBlack
box 300,500,500,530
ink cBlack,cBlack
center text 400,500,"QUIT GAME"
endif
if mousex()>=300 and mousex()<=500 and mousey()>=450 and mousey()<=480
nDiffChoice = 6
ink cWhite,cBlack
box 300,450,500,480
ink cBlack,cBlack
center text 400,450,"START EDITOR"
endif
if mousex()>=200 and mousex()<=300 and mousey()>=400 and mousey()<=430
nDiffChoice = 3
ink cWhite,cBlack
box 200,400,300,430
ink cBlack,cBlack
center text 250,400,"EASY"
endif
if mousex()>=320 and mousex()<=480 and mousey()>=400 and mousey()<=430
nDiffChoice = 2
ink cWhite,cBlack
box 320,400,480,430
ink cBlack,cBlack
center text 400,400,"NORMAL"
endif
if mousex()>=500 and mousex()<=600 and mousey()>=400 and mousey()<=430
nDiffChoice = 1
ink cWhite,cBlack
box 500,400,600,430
ink cBlack,cBlack
center text 550,400,"HARD"
endif
if mouseclick()=1 and nDiffChoice=7
for x = 1 to 3
delete sound x
next x
undim Brick()
end
endif
if mouseclick()=1 and nDiffChoice=6
nGameMode = 2 ` edit game
wait 200
return
endif
if mouseclick()=1 and nDiffChoice<>0
nGameDifficulty = nDiffChoice
nGameMode = 1 ` play game
wait 200
return
endif
sync
loop
return
`*******************
PlayGame:
nLevel = 1 ` the current Brick array level
nTotalLevel = 1 ` the highest level reached
nInstructionsOn = 1 ` 0 = don't show instructions, 1 = show instructions
nDirection = 2 ` 1 = move spaceship left, 2 = move spaceship right
nBallOnPaddle = 1 ` 0 = ball is not on paddle, 1 = ball is on paddle
scale sprite 1000,100
scale sprite 1001,100
if nGameDifficulty = 3 then Difficulty$="Easy":nNewBallScore=1000
if nGameDifficulty = 2 then Difficulty$="Normal":nNewBallScore=2000
if nGameDifficulty = 1 then Difficulty$="Hard":nNewBallScore=3000
nBalls = (nGameDifficulty*2)-1
nScore = 0
nGameSpeed = 7
gosub NewLevel
show sprite 1000
show sprite 1001
hide mouse
nTime = timer()
nSpriteTimer = timer()
do
if keystate(18) ` E - starts the game editor
nGameMode = 2
return
endif
if keystate(1) ` ESC key - quit game
nGameMode = 3
wait 100
return
endif
if timer() > nTime + nGameSpeed
` reset the game timer
nTime = timer()
` limit the paddle to inside the borders
nPaddleX = mousex()
if nPaddleX < 70 then nPaddleX = 70
if nPaddleX > 730 then nPaddleX = 730
` limit the mouse to the playing field
if mousex()<50 then position mouse nPaddleX,300
if mousey()<50 then position mouse nPaddleX,300
if mousey() > 500 then position mouse nPaddleX,300
if mousex() > 765 then position mouse nPaddleX,300
` move the paddle
nOldPaddleX = sprite x(1001)
sprite 1001,nPaddleX,580,iPaddle1
if mouseclick() = 1 and nBallOnPaddle
nBallOnPaddle = 0
rotate sprite 1000,180
nInstructionsOn = 0
endif
` move the ball
if nBallOnPaddle
sprite 1000,nPaddleX,555,iBall
else
oldBallX = sprite x(1000)
oldBallY = sprite y(1000)
move sprite 1000,6
endif
` move the spaceship
sprite 1005,sprite x(1005)+nDirection,350,nSpaceshipImage
` and loop through the frames
if timer()>nSpriteTimer + 50
inc nSpaceshipImage
if nSpaceshipImage = 106 then nSpaceshipImage = 101
set sprite image 1005,nSpaceshipImage
nSpriteTimer = timer()
endif
` spaceship reaches right side of screen
if sprite x(1005) > 950
nDirection = -1
if sprite visible(1005)
if rnd(4) = 1
hide sprite 1005
stop sound 3
endif
else
if rnd(4) = 1 and nInstructionsOn = 0
show sprite 1005
loop sound 3
endif
endif
endif
` spaceship reaches left side of screen
if sprite x(1005) < -150
nDirection = 1
if sprite visible(1005)
if rnd(4) = 1
hide sprite 1005
stop sound 3
endif
else
if rnd(4) = 1 and nInstructionsOn = 0
show sprite 1005
loop sound 3
endif
endif
endif
` find the latest object to collide with the ball
nOldCollision = nCollision
nCollision = sprite collision(1000,0)
` this checks for a collision between the ball and a block
if nCollision > 0 and nCollision <= nNumberOfSprites
select sprite image(nCollision)
case iSoftBrick
delete sprite nCollision
inc nScore,5
dec nNumberOfBricks
endcase
case iHardBrick
bounce(nCollision)
delete sprite nCollision
inc nScore,5
dec nNumberOfBricks
endcase
case iBarrierBrick
if nCollision <> nOldCollision
bounce(nCollision)
endif
endcase
case iGoldBrick
bounce(nCollision)
delete sprite nCollision
inc nScore,100
dec nNumberOfBricks
endcase
case iPaddleBrick
bounce(nCollision)
delete sprite nCollision
inc nScore,5
dec nNumberOfBricks
scale sprite 1001,200
nBigPaddleTimer = timer()+(10000*nGameDifficulty)
endcase
case iBallBigBrick
bounce(nCollision)
delete sprite nCollision
inc nScore,5
dec nNumberOfBricks
scale sprite 1000,200
nBigBallTimer = timer()+(10000*nGameDifficulty)
endcase
case iKillerBrick
delete sprite nCollision
inc nScore,25
dec nBalls
dec nNumberOfBricks
play sound 2
nBallOnPaddle = 1
if nBalls < 1
nGameMode = 3
return
endif
endcase
case iRandomBrick
delete sprite nCollision
rotate sprite 1000, rnd(359)
inc nScore,5
dec nNumberOfBricks
endcase
endselect
if not sound playing(1) then play sound 1
nOldCollision = nCollision
endif
` the ball hits the top border - mirror angle
if sprite y(1000) < 65
rotate sprite 1000, wrapvalue(180-sprite angle(1000))
nOldCollision = 0
if not sound playing(1) then play sound 1
endif
` the ball hits a side border - flip angle
if sprite x(1000) < 45 or sprite x(1000) > 755
rotate sprite 1000, wrapvalue(360 - sprite angle(1000))
nOldCollision = 0
if not sound playing(1) then play sound 1
endif
` the ball hits the paddle
if nCollision = 1001 and nBallOnPaddle = 0
` mirror the ball direction
nSpriteAngle = sprite angle(1000)
nSpriteAngle = wrapvalue(180-nSpriteAngle)
` add in some angle from the paddle movement
nPaddleMovement = (nPaddleX-nOldPaddleX)*3
if nPaddleMovement > 90 then nPaddleMovement = 90
if nPaddleMovement < -90 then nPaddleMovement = -90
nSpriteAngle = wrapvalue(nSpriteAngle+nPaddleMovement)
` make sure the ball is not travelling downward after the change
if nSpriteAngle > 80 and nSpriteAngle < 180 then nSpriteAngle = 80
if nSpriteAngle > 179 and nSpriteAngle < 280 then nSpriteAngle = 280
` set the new ball angle
rotate sprite 1000, nSpriteAngle
if not sound playing(1) then play sound 1
endif
` the ball hits the spaceship
if nCollision = 1005 and sprite visible(1005)
rotate sprite 1000,rnd(359)
if not sound playing(1) then play sound 1
endif
` the ball leaves the playing field
if sprite y(1000) > 600 or sprite y(1000) < 0 or sprite x(1000) > 800 or sprite x(1000) < 0
dec nBalls
play sound 2
nBallOnPaddle = 1
scale sprite 1000,100
scale sprite 1001,100
if nBalls < 1
nGameMode = 3
return
endif
endif
` right clicking the mouse
if mouseclick()=2
wait 500
dec nBalls
play sound 2
nBallOnPaddle = 1
scale sprite 1000,100
scale sprite 1001,100
if nBalls < 1
nGameMode = 3
return
endif
endif
` check score for new ball
if nScore >= nNewBallScore
inc nBalls
inc nNewBallScore,(4-nGameDifficulty)*1000
endif
` check for all bricks killed - new level
if nNumberOfBricks <= 0
inc nLevel
inc nTotalLevel
if nLevel = 11
nLevel = 1
dec nGameSpeed
if nGameSpeed < 3 then nGameSpeed = 3
endif
gosub NewLevel
nBallOnPaddle = 1
endif
` check for big ball timer to expire
if sprite scale x(1000) <> 100 and timer()>nBigBallTimer then scale sprite 1000,100
` check for big paddle timer to expire
if sprite scale x(1001) <> 100 and timer()>nBigPaddleTimer then scale sprite 1001,100
` display info
ink cWhite,cBlack
set text size 30
text 20,5,"Difficulty: "+Difficulty$+" Level: "+ str$(nTotalLevel)+ " Balls: "+str$(nBalls)+" Score: "+str$(nScore)
if nInstructionsOn then gosub ShowInstructions
sync
endif
loop
return
`*******************
NewLevel:
` clear all bricks
for s = 1 to 220
if sprite exist(s) then delete sprite s
next s
` hide the spaceship
hide sprite 1005
stop sound 3
` build the level
nNumberOfSprites = 0
nNumberOfBricks = 0
for y = 1 to 10
for x = 1 to 22
nBrickType = Brick(nLevel,x,y)
if nBrickType < 1 or nBrickType > 8
cls
set text size 20
ink cWhite,cBlack
print "ERROR OF BRICKTYPE ";nBrickType;" AT LEVEL ";nLevel;" X:";x;" Y:";y
sync
wait key
endif
inc nNumberOfSprites
if nBrickType <> 3 then inc nNumberOfBricks
sprite nNumberOfSprites,x*30+55,y*20+70,nBrickType
offset sprite nNumberOfSprites,15,10
next x
next y
gosub MakeNewBackdrop
return
`*******************
ShowInstructions:
set text size 20
ink cWhite,cBlack
paste image iSoftBrick,100,310
paste image iHardBrick,100,340
paste image iBarrierBrick,100,370
paste image iGoldBrick,100,400
paste image iPaddleBrick,100,430
paste image iBallBigBrick,100,460
paste image iKillerBrick,100,490
paste image iRandomBrick,100,520
text 130,310," - Soft brick, no bounce, 5 pts."
text 130,340," - Hard brick, 5 pts."
text 130,370," - Barrier brick, not destroyed, 0 pts."
text 130,400," - Gold bonus brick, 100 pts."
text 130,430," - Paddle Size Powerup brick, 5 pts."
text 130,460," - Ball Size Powerup brick, 5 pts."
text 130,490," - Ball Killer brick, 25 pts."
text 130,520," - Random bounce brick, 5 pts."
if nGameMode = 1
center text 600,310,"Left-click to launch the ball."
center text 600,340,"Moving the paddle will change"
center text 600,360,"the ball's bounce angle."
center text 600,400,"If the ball ever gets stuck,"
center text 600,420,"you may right-click to destroy"
center text 600,440,"the ball and launch a new one."
center text 600,480,"Press 'E' to start the editor."
center text 600,520,"Press the ESCAPE key to quit."
endif
if nGameMode = 2
center text 580,310,"Use PgUp and PgDn to change level."
center text 580,340,"Left-click a brick type to choose it."
center text 580,370,"Left-click a brick to change that"
center text 580,390,"brick to the current brick type."
center text 580,410,"(You can click and drag, too.)"
center text 580,440,"Press S to save changes to the bricks file."
center text 580,470,"Press L to load in the bricks file."
center text 580,500,"Press P to play the game."
center text 580,530,"Press the ESCAPE key to quit."
endif
return
`*******************
EditGame:
hide sprite 1000
hide sprite 1001
nScore = 0
nLevel = 1
gosub NewLevel
nCursorBrickType = 1
sprite 1006,0,0,nBrickType
offset sprite 1006,sprite width(1006)/2,sprite height(1006)/2
scale sprite 1006,75
set sprite priority 1006,1
do
gosub ShowInstructions
sprite 1006,mousex(),mousey(),nCursorBrickType
ink cWhite,cBlack
set text size 30
if keystate(1) ` ESC key - quit game
nGameMode = 3
wait 100
return
endif
if keystate(25) ` P - play the game
delete sprite 1006
for x = 1 to 220
if sprite exist(x) then delete sprite x
next x
nGameMode = 0
return
endif
if keystate(38) ` L - load from the bricks file
if file exist("BRICKS.DAT")
text 20,5,"LOADING FILE..."
sync
load array "BRICKS.DAT", Brick(10,22,10)
wait 2000
nLevel = 1
gosub NewLevel
else
text 20,5,"BRICKS.DAT FILE NOT FOUND!"
sync
wait 2000
endif
endif
if keystate(31) ` S - save to the bricks file
if file exist("BRICKS.DAT")
delete file "BRICKS.DAT"
endif
text 20,5,"SAVING FILE..."
sync
save array "BRICKS.DAT", Brick(10,22,10)
wait 2000
endif
` The dump to data file creates data statements
` that can be cut and and pasted back into the
` program code, thus satifying the requirements
` for no media, per challenge contest rules.
if keystate(32) ` D - dump to the data file
if file exist("BRICKSDUMP.TXT")
delete file "BRICKSDUMP.TXT"
endif
text 20,5,"SAVING DATA STATEMENTS FILE..."
sync
open to write 1,"BRICKSDUMP.TXT"
for L = 1 to 10
write string 1,"REM LEVEL "+str$(L)
for R = 1 to 10
a$="data "+chr$(34)
for C = 1 to 22
a$=a$+str$(Brick(L,C,R))
next C
a$=a$+chr$(34)
write string 1,a$
next R
next L
close file 1
wait 2000
endif
if keystate(201) ` PgUp - go up a level
inc nLevel
if nLevel = 11 then nLevel = 1
gosub NewLevel
wait 200
endif
if keystate(209) ` PgDn - go down a level
dec nLevel
if nLevel = 0 then nLevel = 10
gosub NewLevel
wait 200
endif
if mousex()>99 and mousex()<131 and mousey()>309 and mousey()<540
nCursorBrick = ((mousey()-280)/30)
else
nCursorBrick = 0
endif
if mousex()>69 and mousex()<731 and mousey()>79 and mousey()<281
nCursorX = (mousex()-40)/30
nCursorY = (mousey()-60)/20
nThisSprite = nCursorX+((nCursorY-1)*22)
else
nCursorX = 0
nCursorY = 0
nThisSprite = 0
endif
if mouseclick()=1 and nCursorBrick <> 0
nCursorBrickType = nCursorBrick
endif
if mouseclick()=1 and nCursorX+nCursorY <>0
if sprite exist(nThisSprite)
set sprite image nThisSprite,nCursorBrickType
Brick(nLevel,nCursorX,nCursorY)=nCursorBrickType
endif
endif
text 20,5,"EDIT MODE - Level: " + str$(nLevel)
sync
loop
return
`*******************
EndGame:
hide sprite 1000
hide sprite 1001
hide sprite 1005
if sprite exist(1006) then delete sprite 1006
stop sound 3
for x = 1 to 220
if sprite exist(x) then delete sprite x
next x
` check if the player's score is high enough to post
nLowScoreForLevel = val(Scores$(nGameDifficulty,5,2))
if nScore > nLowScoreForLevel
for x = 1 to 3
Initials$(x)="?"
next x
x=1
while Initials$(3)="?"
center text 400,300,"Your score is high enough to post!"
center text 400,330,"Type your initials..."
box 319,400,362,403
box 368,400,412,403
box 418,400,461,403
center text 295+50*x,370,Initials$(x)
for y = 1 to 3
center text 295+50*y,370,Initials$(y)
next y
sync
wait key
a$=inkey$()
a$=upper$(a$)
if find sub string$(Test$,a$)>0
Initials$(x)=a$
inc x
endif
endwhile
`swap the score up the array until it reaches its proper spot
for nSpot = 4 to 1 step -1
if nScore > val(Scores$(nGameDifficulty,nSpot,2))
TempScore$=Scores$(nGameDifficulty,nSpot,2)
TempInitials$=Scores$(nGameDifficulty,nSpot,1)
Scores$(nGameDifficulty,nSpot,2)=str$(nScore)
Scores$(nGameDifficulty,nSpot,1)=Initials$(1)+Initials$(2)+Initials$(3)
Scores$(nGameDifficulty,nSpot+1,2)=TempScore$
Scores$(nGameDifficulty,nSpot+1,1)=TempInitials$
endif
next nSpot
` now save the scoreboard file
if file exist("SCORES.DAT") then delete file "SCORES.DAT"
save array "SCORES.DAT", Scores$(3,5,2)
endif
show mouse
do
set text size 30
ink cWhite,cBlack
text 20,5,"Difficulty: "+Difficulty$+" Level: "+ str$(nTotalLevel)+ " Balls: "+str$(nBalls)+" Score: "+str$(nScore)
set text size 50
center text 400,270,"G A M E O V E R"
set text size 30
ink cBlack,cBlack
box 200,320,390,350
box 410,320,600,350
ink cWhite,cBlack
center text 295,320,"PLAY AGAIN"
center text 505,320,"QUIT GAME"
nEndChoice = 0
set text size 20
text 100,375,"EASY GAME"
text 300,375,"NORMAL GAME"
text 500,375,"HARD GAME"
set text size 30
for nDifficulty = 1 to 3
for nPlayer = 1 to 5
text 500-(nDifficulty-1)*200,370+nPlayer*30,Scores$(nDifficulty,nPlayer,1)+" "+Scores$(nDifficulty,nPlayer,2)
next nPlayer
next nDifficulty
if keystate(1) ` ESC key - quit game
for x = 1 to 3
delete sound x
next x
undim Brick()
end
endif
if mousex()>=200 and mousex()<=390 and mousey()>=320 and mousey()<=350
nEndChoice = 1
ink cWhite,cBlack
box 200,320,390,350
ink cBlack,cBlack
center text 295,320,"PLAY AGAIN"
endif
if mousex()>=410 and mousex()<=600 and mousey()>=320 and mousey()<=350
nEndChoice = 2
ink cWhite,cBlack
box 410,320,600,350
ink cBlack,cBlack
center text 505,320,"QUIT GAME"
endif
if mouseclick()=1 and nEndChoice<>0
if nEndChoice = 2
for x = 1 to 3
delete sound x
next x
undim Brick()
end
endif
if nEndChoice = 1
nGameMode = 0
wait 200
return
endif
endif
sync
loop
return
`*******************
MakeFiles:
if not file exist("BRICKS.DAT") ` is there a Brick data file?
for nLevel = 1 to 10
for nRow = 1 to 10
read a$
for nColumn = 1 to 22
Brick(nLevel,nColumn,nRow) = val(mid$(a$,nColumn))
next nColumn
next nRow
next nLevel
save array "BRICKS.DAT", Brick(10,22,10)
nLevel = 1
endif
if not file exist("SCORES.DAT") ` is there a high score file?
for nScoreDifficulty = 1 to 3
for nScoreEntry = 1 to 5
Scores$(nScoreDifficulty,nScoreEntry,1)="???"
Scores$(nScoreDifficulty,nScoreEntry,2)="0"
next nScoreEntry
next nScoreDifficulty
save array "SCORES.DAT", Scores$(3,5,2)
endif
return
`*******************
InitializeVariables:
set bitmap format 21
create bitmap 1,800,600
set current bitmap 0
` some color constants
#constant cWhite = rgb(255,255,255)
#constant cLightGrey = rgb(200,200,200)
#constant cGrey = rgb(128,128,128)
#constant cDarkGrey = rgb(50,50,50)
#constant cBlack = rgb(0,0,0)
#constant cLightRed = rgb(255,100,100)
#constant cRed = rgb(255,0,0)
#constant cDarkRed = rgb(50,0,0)
#constant cLightGreen = rgb(150,255,100)
#constant cGreen = rgb(0,255,0)
#constant cDarkGreen = rgb(0,50,0)
#constant cLightBlue = rgb(100,100,255)
#constant cBlue = rgb(0,0,255)
#constant cDarkBlue = rgb(0,0,50)
#constant cLightCyan = rgb(150,200,255)
#constant cCyan = rgb(0,200,255)
#constant cDarkCyan = rgb(0,25,50)
#constant cLightMagenta = rgb(255,100,205)
#constant cMagenta = rgb(255,0,205)
#constant cDarkMagenta = rgb(50,0,50)
#constant cYellow = rgb(255,255,0)
#constant cGold = rgb(255,175,0)
#constant cDarkGold = rgb(155,65,0)
` some constants for the Brick types and images
#constant iSoftBrick = 1
#constant iHardBrick = 2
#constant iBarrierBrick = 3
#constant iGoldBrick = 4
#constant iPaddleBrick = 5
#constant iBallBigBrick = 6
#constant iKillerBrick = 7
#constant iRandomBrick = 8
#constant iNullBrick = 9
#constant iBall = 10
#constant iPaddle1 = 11
#constant iBackdrop = 12
#constant iSpaceship = 13
#constant iRedLight = 14
` three textures for the spaceship
#constant tRed = 16
#constant tGrey = 17
#constant tYellow = 18
global oldBallX, oldBallY as integer
` these are the sound effects
createsound("blip",1,50,80,6000,-.4,2.0,0.1,10,1.2,0.2,10)
createsound("kill",2,30,50,16000,0.00,1.5,.0,0,0,0,100)
createsound("ship",3,1200,600,3000,10,0.1,0,0,0,0,10)
set sound volume 3,85
set sound speed 3,1500
nGameSpeed = 7
nLevel = 1
Test$="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
dim Brick(10,22,10)
dim Scores$(3,5,2)
dim Initials$(3)
randomize timer()
set text font "ariel"
set window title "Breakout Challenge by Rich Dersheimer"
return
`*******************
LoadFiles:
load array "BRICKS.DAT", Brick(10,22,10)
load array "SCORES.DAT", Scores$(3,5,2)
return
`*******************
MakeGraphics:
` textures for spaceship body and lights
ink cRed,cBlack
box 0,0,15,15
get image tRed,0,0,15,15,3
ink cLightGrey,cBlack
box 0,0,15,15
get image tGrey,0,0,15,15,3
ink cYellow,cBlack
box 0,0,15,15
get image tYellow,0,0,15,15,3
ink cBlack,cBlack
box 0,0,15,15
` set up the camera
backdrop on
color backdrop 0
autocam off
position camera 0,0,-500
point camera 0,0,0
set ambient light 50
` this is the spaceship
make object sphere 2,60,36,36
scale object 2,100,60,100
position object 2,0,75,0
texture object 2,tGrey
make object cone 3,150
scale object 3,100,10,100
position object 3,0,60,0
rotate object 3,180,0,0
texture object 3,tGrey
` the spaceship lights
make object sphere 4,6,36,36
texture object 4,tYellow
position object 4,-60,62,-50
make object sphere 5,6,36,36
texture object 5,tYellow
position object 5,60,62,-50
make object sphere 6,6,36,36
texture object 6,tYellow
position object 6,30,63,-60
make object sphere 7,6,36,36
texture object 7,tYellow
position object 7,-30,63,-60
make object sphere 8,6,36,36
texture object 8,tYellow
position object 8,0,63,-70
` the red light
make object sphere 9,6,36,36
texture object 9,tRed
position object 9,0,150,-70
` this is the ball
make object sphere 1,20,36,36
texture object 1,tYellow
scale object 1,100,100,1
` grab the ball and spaceship images
sync
set camera view 0,0,0,0
get image iBall,390,290,410,310
get image iSpaceship,326,205,474,248,1
get image iRedLight,395,120,405,130,1
for y = 1 to 5
paste image iSpaceShip,0,(y-1)*43
next y
paste image iRedLight,3,20,1
paste image iRedLight,35,61,1
paste image iRedLight,69,102,1
paste image iRedLight,103,146,1
paste image iRedLight,135,192,1
` grab the frames for the animated spaceship
for y = 1 to 5
get image 100+y,0,(y-1)*43,147,((y-1)*43)+43
next y
` delete the ball and spaceship parts
for x = 1 to 9
delete object x
next x
` this is the paddle
ink cWhite,cWhite
box 10,0,70,20
get image iPaddle1,10,0,70,10
` this is the pinkish or "soft" Brick
box 0,0,30,20,cGrey,cLightGrey,cDarkGrey,cGrey
box 1,1,29,19,cDarkRed,cLightRed,cDarkRed,cLightRed
get image iSoftBrick,0,0,30,20
` this is red or "hard" Brick
box 1,1,29,19,cDarkRed,cRed,cDarkRed,cRed
get image iHardBrick,0,0,30,20
` this is the grey or "barrier" Brick
ink cGrey,cBlack
box 1,1,29,19
get image iBarrierBrick,0,0,30,20
` this is the ball killer Brick
box 1,1,29,19,cBlack,cGrey,cBlack,cDarkGrey
get image iKillerBrick,0,0,30,20
` this is the big paddle Brick
box 1,1,29,19,cDarkCyan,cLightCyan,cDarkCyan,cLightCyan
get image iPaddleBrick,0,0,30,20
` this is the big ball Brick
box 1,1,29,19,cDarkGreen,cLightGreen,cDarkGreen,cLightGreen
get image iBallBigBrick,0,0,30,20
` this is the golden bonus Brick
box 1,1,29,19,cDarkGold,cGold,cDarkGold,cGold
get image iGoldBrick,0,0,30,20
` this is the random bounce Brick
box 1,1,29,18,cDarkMagenta,cLightMagenta,cDarkmagenta,cLightMagenta
get image iRandomBrick,0,0,30,20
` now get the sprites
` the ball
sprite 1000,400,570,iBall
offset sprite 1000,sprite width(1000)/2,sprite height(1000)/2
hide sprite 1000
` the paddle
sprite 1001,400,580,iPaddle1
offset sprite 1001,sprite width(1001)/2,sprite height(1001)/2
hide sprite 1001
` the spaceship
nSpaceshipImage = 101
sprite 1005,600,350,nSpaceshipImage
offset sprite 1005,sprite width(1005)/2,sprite height(1005)/2
hide sprite 1005
return
`*******************
MakeNewBackdrop:
set current bitmap 1
box 41,61,760,600,cBlue,cDarkBlue,cBlue,cDarkBlue
restore Quotes
for x=1 to rnd(13)+1
read Quote1$
read Quote2$
read Quote3$
next x
ink cBlack,cBlack
set text size 40
center text 400,100,Quote1$
center text 400,150,Quote2$
ink cLightBlue,cBlack
center text 397,97,Quote1$
center text 397,147,Quote2$
ink cBlack,cBlack
set text size 25
set text to italic
center text 400,200,Quote3$
ink cLightBlue,cBlack
center text 398,198,Quote3$
set text to normal
backdrop off
delete image iBackdrop
get image iBackdrop,0,0,799,599
texture backdrop iBackdrop
set current bitmap 0
return
`*******************
MakeBackdrop:
set current bitmap 1
ink cBlack,cBlack
box 0,0,800,600
box 41,61,760,600,cBlue,cDarkBlue,cBlue,cDarkBlue
ink cDarkBlue,cBlack
set text to bold
set text size 90
center text 400,90,"B R E A K O U T"
center text 400,180,"C H A L L E N G E"
ink cBlue,cBlack
center text 395,85,"B R E A K O U T"
center text 395,175,"C H A L L E N G E"
set text to normal
set text size 30
` top border
for x = 10 to 760 step 30
box x,40,x+30,60,cGrey,cLightGrey,cdarkGrey,cGrey
ink cGrey,cBlack
box x+1,41,x+29,59
next x
` left and right borders
for y = 60 to 600 step 20
box 10,y,40,y+20,cGrey,cLightGrey,cDarkGrey,cGrey
ink cGrey,cBlack
box 11,y+1,39,y+19
box 760,y,790,y+20,cGrey,cLightGrey,cDarkGrey,cGrey
ink cGrey,cBlack
box 761,y+1,789,y+19
next y
get image iBackdrop,0,0,799,599
set current bitmap 0
texture backdrop iBackdrop
return
`*******************
function bounce(nBrick as integer)
nDifferenceX = ABS(sprite x(nBrick) - oldBallX)
nDifferenceY = ABS(sprite y(nBrick) - oldBallY)
nCurrentAngle = sprite angle(1000)
if nDifferenceX > nDifferenceY
nNewAngle = wrapvalue(360 - sprite angle(1000))
endif
if nDifferenceX < nDifferenceY
nNewAngle = wrapvalue(180 - sprite angle(1000))
endif
if nDifferenceX = nDifferenceY
nNewAngle = wrapvalue(360 - sprite angle(1000))
nNewAngle = wrapvalue(180 - nNewAngle)
endif
rotate sprite 1000,nNewAngle
endfunction
`*******************
`DB Sound Creator by Ric, and:
`Tommy S - Original waveform code
`Green Gandalf - Memblock format
`Lampton Worm - Load/Save format
`Lampton Worm/Raven - Real time parameter editor
`Xtom - GUI/parameter editor
function createsound(name$,soundnumber,frequency#,length#,loudness#,bend#,decay#,vibratospeed#,vibratodepth#,tremelospeed#,tremelodepth#,attack#)
outWord as word
dword1 as dword: dword2 as dword: dword3 as dword: dword4 as dword
dword5 as dword: dword6 as dword: dword7 as dword
samples=int((length#/1000)*44100)
if memblock exist(1) then delete memblock 1
make memblock 1,samples*2+28
` write 28 memblock header bytes
dword1=1
dword2=2
dword3=22050
dword4=88200
dword5=4
dword6=16
dword7=0
position=0
write memblock dword 1, position, dword1 : inc position,4
write memblock dword 1, position, dword2 : inc position,4
write memblock dword 1, position, dword3 : inc position,4
write memblock dword 1, position, dword4 : inc position,4
write memblock dword 1, position, dword5 : inc position,4
write memblock dword 1, position, dword6 : inc position,4
write memblock dword 1, position, dword7 : inc position,4
rem generate and write wave
riseinloudness#=loudness#
for x=1 to samples
outInteger=int(sin((x/122.5)*(frequency#+vibratodepth#*sin(theta#)))*(loudness#-fallinloudness#-riseinloudness#+tremelodepth#*sin(phi#)))*3.0
if outInteger <-32767 then outInteger=-32767
if outInteger>32767 then outInteger=32767
outWord=outInteger
inc theta#,vibratospeed#
inc phi#,tremelospeed#
dec frequency#,bend#
if fallinloudness#<loudness#
inc fallinloudness#,decay#
endif
if riseinloudness#>0
dec riseinloudness#,attack#
endif
write memblock word 1, position, outWord : inc position,2
next x
if sound exist(soundnumber)=1 then delete sound soundnumber
make sound from memblock 999, 1
clone sound soundnumber, 999
delete sound 999
delete memblock 1
endfunction
`*******************
` There are 10 levels, each with 10 rows of 22 bricks.
` That means there are 220 Brick sprites possible.
` After the player has completed all 10 levels, they
` start at level 1 again, but the ball moves faster.
` So on, and so on, until they've lost all their balls. :)
` These data statements are used to build
` the BRICKS.DAT file, if it doesn't exist.
REM LEVEL 1
data "2222222222222222222222"
data "2111111111441111111112"
data "2111111111441111111112"
data "2111111111441111111112"
data "2111111111441111111112"
data "2118811111881111188112"
data "2111111111111111111112"
data "2111111111111111111112"
data "2111111111111111111112"
data "2522262222882222622252"
REM LEVEL 2
data "2222222444444442222222"
data "2111111111111111111112"
data "2151111111111111111612"
data "2111111111111111111112"
data "2111111111111111111112"
data "2888888333333338888882"
data "2111111111111111111112"
data "2111111111111111111112"
data "2111111111111111111112"
data "2222222222222222222222"
REM LEVEL 3
data "2222222222222222222222"
data "2511881111881111881152"
data "2111441111881111441112"
data "2111441111111111441112"
data "8111881111111111881118"
data "2111331111111111331112"
data "2111111111111111111112"
data "2111111111111111111112"
data "2611111111111111111162"
data "2822222222332222222282"
REM LEVEL 4
data "4444444444444444444444"
data "6111111111111111111116"
data "1111111111111111111111"
data "1111111111221111111111"
data "1111111111221111111111"
data "1111111111111111111111"
data "5111311111111111131115"
data "8888888888888888888888"
data "2222222222222222222222"
data "3332222222222222222333"
REM LEVEL 5
data "6411188882728888811146"
data "2211111112221111111122"
data "2211111111111111111122"
data "2211111111111111111122"
data "2251111111111111111522"
data "2288888888888888888822"
data "2244444444444444444422"
data "2233333333333333333322"
data "2222222222222222222222"
data "2222222222222222222222"
REM LEVEL 6
data "4411111162222511111144"
data "4411111124444211111144"
data "3311111211111121111133"
data "1111112111111112111111"
data "1111121111111111211111"
data "1111211111111111121111"
data "1112111111111111112111"
data "1121111111111111111211"
data "3222222222222222222223"
data "2828282828228282828282"
REM LEVEL 7
data "8111111111441111111118"
data "1111111111441111111111"
data "1122222222222222222211"
data "2223111111441111113222"
data "6221311111441111131226"
data "2221135111441115311222"
data "1121113111441113111211"
data "1122222222222222222211"
data "1111111111111111111111"
data "8888888888888888888888"
REM LEVEL 8
data "1111111118111111111114"
data "8121311211711114131281"
data "1411512411416821111111"
data "1121811112112111184111"
data "1131112111111381111111"
data "8811111141111112511213"
data "1111211218211411111111"
data "2141111631112121142841"
data "1112841281121813811811"
data "1181111111111111111112"
REM LEVEL 9
data "2222222222222222222222"
data "2222222222222222222222"
data "2244111116361111114422"
data "2244111118381111114422"
data "2288111118381111118822"
data "2288111118381111118822"
data "2244111118381111114422"
data "2244111115351111114422"
data "2222222222322222222222"
data "2222222222222222222222"
REM LEVEL 10
data "4444444444444444444444"
data "1222211222112221121121"
data "1211121121121112121121"
data "1211121121121111121121"
data "5211121121121111121126"
data "1222211121121111122221"
data "1221111121121111121121"
data "1212111121121111121121"
data "1211211121121112121121"
data "8288828222882228828828"
Quotes:
data "Adversity causes some men to"
data "break, others to break records."
data "William Arthur Ward"
data "I found Rome a city of brick,"
data "I left it a city of marble."
data "Augustus Caesar"
data "The road to the City of Emeralds"
data "is paved with yellow brick."
data "L. Frank Baum"
data "That city is well fortified which"
data "has a wall of men instead of brick."
data "Plutarch"
data "The shell must break"
data "before the bird can fly."
data "Alfred Lord Tennyson"
data "A bruised reed shall he not break, and"
data "the smoking flax shall he not quench."
data "Isaiah"
data "When did morning ever break,"
data "and find such beaming eyes awake?"
data "Thomas Moore"
data "All and all, you're just"
data "another brick in the wall."
data "Pink Floyd"
data "Now I know I've got a heart,"
data "because it's breaking."
data "The Tin Woodsman"
data "Supreme excellence consists in breaking"
data "the enemy's resistance without fighting."
data "Sun Tzu"
data "Some people make promises for the"
data "pleasure of breaking them."
data "William Hazlitt"
data "The breaking of a wave cannot"
data "explain the whole sea."
data "Vladimir Nabokov"
data "Omelettes are not made"
data "without breaking eggs."
data "Maximillen Robespierre"
data "What's breaking into a bank"
data "compared with founding a bank?"
data "Bertolt Brecht"