' Creator: Jaze McAskill -- mcaskilljaze@gmail.com
crap:
PRINT "Error, error line"
beginning:
CONST leftDirection
= 19200 ' to make the code more readable with the left and right arrowkeys CONST rightDirection
= 19712 ' CONST upAndLeft
= 1 'the ball always moves in one diagonal direction CONST theBackground
= 0 ' to determine what the ball hit CONST hitWallSound$
= "O2L30G" CONST hitPaddleSound$
= "O3L30C" CONST hitBrickSound$
= "O3L30G" CONST deathSound$
= "O4L15CO3CO2CO1L10C" CONST successBeep
= "L9O2DL15DL9DL4F" CONST letterE
= 69 'to lengthen / expand the paddle CONST letterS
= 83 'to shrink the paddle CONST letterPlus
= 43 ' score increase CONST letterMinus
= 45 ' score decrease CONST letterStar
= 42 'score multiplier
'I share everything so I don't have to worry whether or not I was supposed to pass something. Plus it removes the need to pass the same variable multiple times
FOR initializeArrayX
= 2 TO 79 FOR initializeArrayY
= 2 TO 46 creationBoard(initializeArrayX, initializeArrayY) = 1 'set the board to the background color
DIM SHARED brick
AS coordinate: brick.x
= 2: brick.y
= 2 'start the creation board at 2, 2 DIM SHARED ball
(1 TO 2) AS coordinate
'to track where the ball is on the board DIM SHARED ballDirection
(1 TO 2) AS INTEGER 'track the ball's direction using the directional constants above DIM SHARED spaceToStart: spaceToStart
= FALSE
'whether or not the spacebar was pushed to begin the level DIM SHARED debugMode
AS INTEGER: debugMode
= FALSE
'to bounce the ball off the bottom or to decrement numberOfGuys DIM SHARED penUp
, currentColor
, eraserOn
AS INTEGER: penUp
= TRUE: currentColor
= 0: eraserOn
= FALSE
DIM SHARED changeBallSomewhat
AS INTEGER: changeBallSomewhat
= 0 'used to move the ball a little bit to avoid never hitting all of the bricks DIM levelChecking
AS INTEGER: levelChecking
= 0 'used in the following loop to check what is the highest level DIM SHARED activeLetter
AS droppingLetter: activeLetter.x
= 0: activeLetter.y
= 0: activeLetter.letter
= 0
printTheMenu = TRUE 'used to stop the menu from flickering
PRINT CenterText$
("Menu") PRINT CenterText$
("------") PRINT CenterText$
("1.) Instructions") PRINT CenterText$
("2.) Create A Level") PRINT CenterText$
("3.) Play The Game") PRINT CenterText$
("4.) Exit") printTheMenu = FALSE
printTheMenu = TRUE
printTheMenu = TRUE
printTheMenu = TRUE
PRINT CenterText$
("Level Creator") PRINT CenterText$
("---------------")
PRINT CenterText$
("The available commands are listed at the bottom of the screen.") PRINT CenterText$
("When the pen is up, the cursor moves without adding to the level") PRINT CenterText$
("being created. When the pen is down the current brick is added") PRINT CenterText$
("to the level being created. The other commands are self explanatory.") PRINT CenterText$
("If no levels have been created, the default level is used.") PRINT CenterText$
("If you progress beyond all levels created, the last level created repeats.") PRINT CenterText$
("Game") PRINT CenterText$
("------")
PRINT CenterText$
("The object of the game is to progress to the next level by") PRINT CenterText$
("destroying all of the bricks. To do this you must position the") PRINT CenterText$
("under the ball so that it is reflected toward the bricks using") PRINT CenterText$
("the left and right arrow keys.") LOCATE , 2:
PRINT "[ESC] to return to the main menu * = Score multiplier (-1, 1.5 or 2)":
PRINT PRINT CenterText$
("Push C to turn on debug mode and O to turn it off.") PRINT CenterText$
("Push any key to continue.")
returnString$
= SPACE$(INT((80 - LEN(thisString$
)) / 2)) + thisString$
CenterText$ = returnString$
SUB PrintBrick
(x
, y
, onOrOff
) useColor = board(x, y, 2) 'print the brick instead of erasing it, pick up the color there
useColor = 1
board(x + across, y, 1) = 219
board(x + across, y, 2) = useColor
IF onOrOff
= FALSE
THEN 'brick is destroyed numberOfBricks = numberOfBricks - 1
score = score + 5
chanceOfLetter
= INT(RND * 100) + 1 IF chanceOfLetter
<= 25 AND activeLetter.letter
= 0 THEN ' 25% chance of bonus pickingLetter
= INT(RND * 5) + 1 'choose which bonus to activate activeLetter.letter = letterE
activeLetter.letter = letterS
activeLetter.letter = letterPlus
activeLetter.letter = letterMinus
activeLetter.letter = letterStar
activeLetter.x = x + 3 'place the falling letter near the center of destroyed brick
activeLetter.y = y + 1
SUB PrintLetter
(onOrOff
) IF INT(activeLetter.y
) < 47 THEN 'whether the bonus letter is done falling IF onOrOff
= TRUE
THEN 'display the bonus letter clr = 9
clr = 1 'remove bonus letter from display
CALL PlaceChar
(activeLetter.x
, activeLetter.y
, activeLetter.letter
, clr
) 'put the letter on the board ELSEIF activeLetter.y
>= 47 THEN 'activate the letter or ignore it IF paddleLeft
<= activeLetter.x
AND activeLetter.x
<= paddleLeft
+ paddleLength
- 1 THEN 'letter was caught SELECT CASE activeLetter.letter
'which letter to activate CASE letterE
'lengthen the paddle IF paddleLength
<= 10 THEN paddleLength
= paddleLength
+ 2 CASE letterS
'shrink the paddle paddleLength = paddleLength - 2
paddleLength = paddleLength - 1
CASE letterPlus
'increase score score = score + 15
CASE letterMinus
' decrease score score = score - 15
CASE letterStar
'multiply the score multiplier = -1
multiplier = 1.5
score
= INT(score
* multiplier
) END SELECT 'action has been done with selected bonus letter END IF ' the letter has finished being caught activeLetter.x = 0: activeLetter.y = 0: activeLetter.letter = 0 'the letter is no longer active
'clear the playing field
FOR x
= 1 TO 80:
FOR y
= 1 TO 48 'make the board blue board(x, y, 1) = 219 ' ASCII code of board space
board(x, y, 2) = 1 ' color of board space
'print left, right and top borders and put them on the board
CALL PlaceChar
(1, y
, 219, 12) ' put the position, ASCII code and color on the board to make the left border CALL PlaceChar
(80, y
, 219, 12) ' same to make the left border on the board CALL PlaceChar
(x
, 1, 219, 12) ' put the top border on the board paddleLeft
= INT(RND * (72 - 2 + 1)) + 2 'position the paddle to start paddleLength = 8
CALL PrintPaddle
(TRUE
) ' put the paddle on the board with the left at x coordinate 36 activeBall = 1
ball(activeBall).x = paddleLeft + 4: ball(activeBall).y = 47 ' position the ball/moving ball
CALL PrintBall
(activeBall
, TRUE
) ' put the ball on the board ballDirection
(activeBall
) = INT(RND * 2) + 1 'randomize the starting direction of the ball as up and left or up and right highestLevel
= VAL(highLev$
) highestLevel = 0
filename$ = ""
IF currentLevel
< highestLevel
THEN filename$ = "Level " + S$(currentLevel)
filename$ = "Level " + S$(highestLevel)
OPEN filename$
FOR INPUT AS #1 'open the file with the level information FOR xCounting
= 2 TO 79 ' x coordinate of the board FOR yCounting
= 2 TO 46 ' y coordinate of the board INPUT #1, boardColor$
' get the color of the board at xCounting, yCounting board
(xCounting
, yCounting
, 2) = VAL(boardColor$
) 'color the board at xCounting, yCounting CALL PlaceChar
(x
, 2, 219, 14) 'put a yellow (14) block (219) at x, y on the board CALL PlaceChar
(x
, 4, 219, 14) CALL PlaceChar
(x
, 6, 219, 14) lastLevelCreated = 1
numberOfBricks = 0 ' after a level has been put on the board, count the number of bricks on it
FOR brickCountingY
= 2 TO 46 'with this set to 47 the ball was being counted as a brick sometimes FOR brickCountingX
= 2 TO 79 STEP 6 'each brick is 6 blocks long IF board
(brickCountingX
, brickCountingY
, 2) <> 1 THEN numberOfBricks = numberOfBricks + 1
CALL PrintBoard
'print the board to the screen spaceToStart = FALSE 'spacebar has yet to be puched to start the current level
CALL PrintLevel
(currentLevel
) 'put the current level on the board and print it out printOutBoard = FALSE ' to avoid flicker of the board being constantly printed, the need to print it is false
delaySpeed = 0.029 'delay to use inside the main DO-LOOP
activeBall = 1
debugging$
= INKEY$ 'using strings instead of _KEYDOWN(code) is easier. i initially added INKEY$ for debugging IF spaceToStart
= TRUE
THEN ' the spacebar has been hit to start the game CALL PrintBall
(activeBall
, FALSE
) CALL MoveBall
(activeBall
) CALL PrintBall
(activeBall
, TRUE
) IF _KEYDOWN(leftDirection
) = -1 THEN 'the left arrow key had been pushed CALL PrintPaddle
(FALSE
) ' remove the paddle from the board paddleLeft = paddleLeft - 1.5 ' move the paddle leftward
CALL PrintPaddle
(TRUE
) ' put the paddle on the board at the new position printOutBoard = TRUE 'it is now needed to print the board to the screen
paddleLeft = paddleLeft + 1.5
printOutBoard = TRUE
IF printOutBoard
= TRUE
THEN 'print the board to the screen CALL PrintBoard
' print the board to the screen printOutBoard = FALSE 'stop the board from being printed now
IF numberOfBricks
= 0 THEN 'there are no bricks left on the board currentLevel = currentLevel + 1 'increment the current level
activeLetter.letter = 0: activeLetter.x = 0: activeLetter.y = 0
CALL PrintLevel
(currentLevel
) 'put the newest level on the board spaceToStart = FALSE 'the spacebar has not been pressed since the new level has been output
score = score + 200 '200 points for finishing a level
IF mute
= -1 THEN PLAY successBeep
'1 is mute, -1 is note muted IF activeLetter.letter
<> 0 THEN activeLetter.y = activeLetter.y + 0.5
printOutBoard = TRUE
IF debugging$
= "C" THEN debugMode
= TRUE
IF debugging$
= "O" THEN debugMode
= FALSE
spaceToStart = TRUE ' the spacebar has been pushed
printOutBoard = TRUE ' it is needed to print the board to the screen
_DELAY (delaySpeed
) ' insert a delay to make the movement playable and visible IF score
MOD 750 = 0 AND score
<> 0 THEN numberOfGuys
= numberOfGuys
+ 1 ' new guy every 2,000 points IF debugging$
= "+" THEN 'increase the game speed delaySpeed = delaySpeed - 0.005
IF delaySpeed
< 0 THEN delaySpeed
= 0 'don't allow a negative delay IF debugging$
= "-" THEN delaySpeed
= delaySpeed
+ 0.005 'decrease the game speed IF debugging$
= "m" OR debugging$
= "M" THEN mute
= mute
* -1 'turn mute on or off IF debugging$
= "p" OR debugging$
= "P" THEN pause$
= INPUT$(1) 'pause the game
changeBallSomewhat = changeBallSomewhat + 1 'keep track of the number of times the ball has moved to occasionally nudge it
CALL MoveUpAndRight
(whichOne
) CALL MoveUpAndLeft
(whichOne
) CALL MoveDownAndRight
(whichOne
) CALL MoveDownAndLeft
(whichOne
)
FUNCTION Report
(x
, y
) 'determine what element is at specified x, y location 'if color 12 then border, 1 then background, 15 then paddle, 11 ball, 9 bonus, else brick
rtn = -1 'initialize what should be returned
rtn = theWall
rtn = theBackground
rtn = thePaddle
rtn = theBall
rtn = theBonus
rtn = theBrick
Report = rtn
SUB MoveUpAndRight
(thisBall
) SELECT CASE Report
(ball
(thisBall
).x
+ 1, ball
(thisBall
).y
- 1) 'report one away from where the ball currently is CASE theBackground
, theBall
' move it even if both balls are in the same place ball(thisBall).x = ball(thisBall).x + 1
ball(thisBall).y = ball(thisBall).y - 1
IF changeBallSomewhat
MOD 100 = 0 AND ball
(thisBall
).x
+ 1 < 80 THEN ball
(thisBall
).x
= ball
(thisBall
).x
+ 1 IF ball
(thisBall
).x
+ 1 = 80 THEN 'hit the right wall
ballDirection(thisBall) = upAndLeft
'hit top wall
ballDirection(thisBall) = downAndRight
leftSideOfBrick = FindBrickLeft(ball(thisBall).x + 1)
vertOfBrick = FindBrickVertical(ball(thisBall).y - 1)
CALL PrintBrick
(leftSideOfBrick
, vertOfBrick
, FALSE
) ballDirection(thisBall) = downAndRight
CASE theBackground
, theBall
, theBonus
ball(b).x = ball(b).x - 1
ball(b).y = ball(b).y - 1
IF changeBallSomewhat
MOD 100 = 0 AND ball
(b
).x
- 1 > 1 THEN ball
(b
).x
= ball
(b
).x
- 1 ballDirection(b) = upAndRight
ballDirection(b) = downAndLeft
leftSideOfBrick = FindBrickLeft(ball(b).x - 1)
vertOfBrick = FindBrickVertical(ball(b).y - 1)
CALL PrintBrick
(leftSideOfBrick
, vertOfBrick
, FALSE
) ballDirection = downAndLeft
SUB MoveDownAndRight
(var
) SELECT CASE Report
(ball
(var
).x
+ 1, ball
(var
).y
+ 1) CASE theBackground
, theBall
, theBonus
CALL PrintBall
(var
, FALSE
) 'remove the ball the fell from the screen IF activeBall
<> 3 THEN 'activeBall is 1 or 2 score = score - 50
spaceToStart = FALSE
paddleLength = 8
paddleLeft
= INT(RND * (72 - 2 + 1)) + 2 activeBall = 1
ball(activeBall).x = paddleLeft + 4: ball(activeBall).y = 47
CALL PrintBall
(activeBall
, TRUE
) ballDirection
(activeBall
) = INT(RND * 2) + 1 numberOfGuys = numberOfGuys - 1
activeBall = 2
activeBall = 1
ball(var).x = 0
ball(var).y = 0
PRINT "ball(var).x, ball(var).y" PRINT "ball(" + S$
(var
) + ").x, ball(+"; S$
(var
) + ").y" PRINT S$
(ball
(var
).x
) + ", " + S$
(ball
(var
).y
) PRINT "activeBall: " + S$
(activeBall
) ELSE 'debug mode is on (true) ballDirection(var) = upAndRight
ball(var).x = ball(var).x + 1
ball(var).y = ball(var).y - 1
IF changeBallSomewhat
MOD 100 = 0 AND ball
(var
).x
+ 1 < 80 THEN ball
(var
).x
= ball
(var
).x
+ 1 ball(var).x = ball(var).x + 1
ball(var).y = ball(var).y + 1
IF ball
(var
).x
+ 1 = 80 THEN ballDirection
(var
) = downAndLeft
leftSideOfBrick = FindBrickLeft(ball(var).x + 1)
vertOfBrick = FindBrickVertical(ball(var).y + 1)
CALL PrintBrick
(leftSideOfBrick
, vertOfBrick
, FALSE
) ballDirection(var) = upAndRight
ballDirection(var) = upAndRight
CASE theBackground
, theBall
, theBonus
IF activeBall
<> 3 THEN 'only one ball was active score = score - 50
spaceToStart = FALSE
paddleLeft
= INT(RND * (72 - 2%
+ 1)) + 2 paddleLength = 8
activeBall = 1
ball(activeBall).x = paddleLeft + 4: ball(activeBall).y = 47
CALL PrintBall
(activeBall
, TRUE
) ballDirection
(activeBall
) = INT(RND * 2) + 1 numberOfGuys = numberOfGuys - 1
ELSE 'one ball fell off the screen activeBall = 2
activeBall = 1
ball(i).x = 0
ball(i).y = 0
ballDirection(i) = upAndLeft
ball(i).x = ball(i).x - 1
ball(i).y = ball(i).y - 1
IF changeBallSomewhat
MOD 100 = 0 AND ball
(i
).x
- 1 > 1 THEN ball
(i
).x
= ball
(i
).x
+ 1 ELSE 'not at bottom of screen ball(i).x = ball(i).x - 1
ball(i).y = ball(i).y + 1
IF ball
(i
).x
- 1 = 1 THEN ballDirection
(i
) = downAndRight
leftSideOfBrick = FindBrickLeft(ball(i).x - 1)
vertOfBrick = FindBrickVertical(ball(i).y + 1)
CALL PrintBrick
(leftSideOfBrick
, vertOfBrick
, FALSE
) ballDirection(i) = upAndLeft
ballDirection(i) = upAndLeft
FUNCTION FindBrickLeft
(x
) 'this returns the x coordinate of the brick that was hit rtn = 0
FindBrickLeft = rtn
rtn = 0
FindBrickVertical = rtn
SUB PrintBall
(whichBall
, onOrOff
) 'put the ball on the board or remove it from the board to effect position change useColor = 11
useColor = 1
CALL PlaceChar
(ball
(whichBall
).x
, ball
(whichBall
).y
, 254, useColor
)
SUB PrintPaddle
(onOrOff
) theColor = 15
theColor = 1
IF paddleLeft
< 2 THEN paddleLeft
= 2 IF paddleLeft
> 80 - paddleLength
THEN paddleLeft
= 80 - paddleLength
FOR across
= 0 TO paddleLength
- 1 CALL PlaceChar
(INT(paddleLeft
) + across
, 48, 219, theColor
)
SUB PlaceChar
(X
, Y
, char
, clr
) 'put the character ASCII with specified color on the board board(X, Y, 1) = char 'character
board(X, Y, 2) = clr ' color
SUB PrintBoard
'print the current board configurationg to the screen and update the current stats displayed this$
= CHR$(board
(x
, y
, 1)) theColor = board(x, y, 2)
IF BrickIsThere
(x
, y
) = TRUE
THEN xCo = FindBrickLeft(x)
yCo = FindBrickVertical(y)
CALL PrintBrick
(xCo
, yCo
, TRUE
) PRINT " Level " + S$
(currentLevel
) + " ";
PRINT "Men: " + S$
(numberOfGuys
) + " ";
PRINT "Bricks remaining: " + S$
(numberOfBricks
) + " ";
PRINT "Score: " + S$
(score
) + " "
x = xCoord: y = yCoord
rtn = FALSE
IF board
(x
, y
, 2) <> 11 AND board
(x
, y
, 2) <> 15 AND board
(x
, y
, 2) <> 12 AND board
(x
, y
, 2) <> 9 AND board
(x
, y
, 2) <> 1 THEN rtn
= TRUE
BrickIsThere = rtn
SUB CreationMain
'main subroutine for the level creation feature penUp = TRUE
eraserOn = FALSE
currentColor = 0
brick.x = 2
brick.y = 2
creationBoard(countX, countY) = 1
printOutCurrentBoard = FALSE
penUp = FALSE
penUp = TRUE
printOutCurrentBoard = TRUE
eraserOn = TRUE
currentColor = 1
penUp = FALSE
eraserOn = FALSE
currentColor = 0
penUp = TRUE
printOutCurrentBoard = TRUE
CASE "C", "c" 'game uses 12, 15, 11, 1 and 9, 17 currentColor = 2
currentColor = 10
currentColor = 13
currentColor = 16
currentColor = 18
currentColor = currentColor + 1
currentColor = 0
printOutCurrentBoard = TRUE
penUp = TRUE
eraserOn = FALSE
currentColor = 0
creationBoard(xCount, yCount) = 1
printOutCurrentBoard = TRUE
brick.y = brick.y - 1
printOutCurrentBoard = TRUE
brick.x = brick.x - 6
printOutCurrentBoard = TRUE
brick.y = brick.y + 1
printOutCurrentBoard = TRUE
brick.x = brick.x + 6
printOutCurrentBoard = TRUE
IF printOutCurrentBoard
= TRUE
THEN printOutCurrentBoard = FALSE
hghstLvl = 0
highestLevel = highestLevel + 1
PRINT #1, S$
(highestLevel
) highestLevel = 1
filename$ = "Level " + S$(highestLevel)
PRINT "The game board has been saved as " + CHR$(34) + "Level " + S$
(highestLevel
) + CHR$(34) IF highestLevel
> 1 THEN PRINT "It will automatically be loaded after Level " + S$
(highestLevel
- 1) + " is completed." stringOut$ = S$(creationBoard(x, y))
IF LEN(stringOut$
) = 1 THEN stringOut$
= " " + stringOut$
a$
= "Push " + CHR$(34) + "A" + CHR$(34) + " to make (a)nother level" b$ = "Push any other key to exit."
SaveBoard$ = "END"
creationBoard(brick.x + counting, brick.y) = currentColor
LOCATE brick.y
, brick.x
+ count
COLOR creationBoard
(x
, y
), 1
PRINT "Use the Arrow Keys To Move P - Pen ";
'LOCATE 20, 20: COLOR 15, 0: PRINT "eraserOn = " + S$(eraserOn): CALL P
' LOCATE 48, 26
PRINT " S - Save [ESC] - End Without Save" ' LOCATE 45, 10: COLOR 10, 1: PRINT "eraserOn = " + S$(eraserOn)