'*
'* ------------------
'* --- QB64 Simon ---
'* ------------------
'*
'* By Terry Ritchie
'*
'* Written from March 22nd to March 28th, 2015
'* Version 1.0
'*
'--------------------------------
'- VARIABLE DECLARATION SECTION -
'--------------------------------
CONST FALSE
= 0 ' boolean: false indicator CONST TRUE
= NOT FALSE
' boolean: true indicator CONST MOUSE%
= 200 ' call PADPRESS with mouse button
DIM Pad&
(3, 1) ' color pads: 0,x=BLUE, 1,x=RED, 2,x=GREEN, 3,x=YELLOW DIM PadXY%
(3, 1) ' x,y locations of color pads DIM Tone&
(4) ' game sounds: 0=BLUE, 1=RED, 2=GREEN, 3=YELLOW, 4=LOSE DIM Simon&
' simon graphics image DIM SimonHelp&
' simon help screen DIM Keys&
(3, 1) ' keyboard key images 0=Q, 1=W, 2=S, 3=A DIM Bslider&
' blue slider switch image DIM Rslider&
' red slider switch image DIM OnOff&
' on/off slider switch DIM KeysXY%
(3, 1) ' location of keyboard key images on play screen DIM GameOver%
' boolean: true when game has ended DIM Game%
' the position the blue slider switch is in (0-2) DIM Skill%
' the position the red slider switch is in (0-3) DIM GameDir%
' the direction blue slider switch will move (1, -1) DIM SkillDir%
' the direction red slider switch will move (1, -1) DIM Longest$
' the longest tune correctly played by a player DIM Last$
' the last tune played by the player DIM Count%
' generic counter DIM KeyPress$
' any keys pressed by the player DIM Pcolor~&
(3) ' color pad base colors: 0=BLUE, 1=RED, 2=GREEN, 3=YELLOW
'----------------
'- MAIN PROGRAM -
'----------------
INITIALIZE ' prepare graphics, sounds and variables
_TITLE "QB64 SIMON" ' give game screen a title _DELAY .5 ' light delay to move to middle of screen CLS ' remove black transparency DO ' BEGIN MAIN GAME LOOP GameOver% = FALSE ' reset game over flag
PRESSPAD 0, 0 ' reset game board
DO ' BEGIN PLAY GAME LOOP _LIMIT 120 ' limit to 120 loops per second IF POINTER%
(232 + Game%
* 10, 323, 289 + Game%
* 10, 345) THEN ' test blue slider area? IF Game%
= 0 OR Game%
= 2 THEN ' yes, is blue slider at its limit? GameDir% = -GameDir% ' yes, reverse blue slider direction
Game% = Game% + GameDir% ' change game level
PRESSPAD 0, .125 ' display change on screen
WAIT4RELEASE
ELSEIF POINTER%
(319 + Skill%
* 10, 323, 375 + Skill%
* 10, 345) THEN ' test red slider area? IF Skill%
= 0 OR Skill%
= 3 THEN ' yes, is red slider at its limit? SkillDir% = -SkillDir% ' yes, reverse red slider direction
Skill% = Skill% + SkillDir% ' change skill level
PRESSPAD 1, .125 ' display change on screen
WAIT4RELEASE
ELSEIF POINTER%
(254, 371, 271, 388) THEN ' test last button area? WAIT4RELEASE
FOR Count%
= 1 TO LEN(Last$
) ' cycle through last tune string PRESSPAD
VAL(MID$(Last$
, Count%
, 1)), .5 ' play each individual tone _DELAY .125 ' pause for 1/8 second ELSEIF POINTER%
(371, 371, 388, 388) THEN ' test longest button area? Count% = 0 ' yes, reset 1/120 counter
DO ' BEGIN MOUSE RELEASE LOOP _LIMIT 120 ' don't hog CPU while looping Count% = Count% + 1 ' increment 1/120 second counter
IF Count%
> 360 THEN ' have 3 seconds elapsed? FOR Count%
= 0 TO 3 ' yes, cycle through all four color pads PRESSPAD Count%, .125 ' light pad and play tone quickly
Longest$ = "" ' reset longest tune string
SIMONFILE 2 ' delete simon.sav file
FOR Count%
= 1 TO LEN(Longest$
) ' cycle through longest tune string PRESSPAD
VAL(MID$(Longest$
, Count%
, 1)), .5 ' play each individual tone _DELAY .125 ' pause 1/8 second ELSEIF POINTER%
(314, 371, 331, 388) THEN ' test start button area? _DELAY .5 ' 1/2 second delay before game start PLAYGAME ' play game
ELSEIF POINTER%
(321, 408, 332, 419) THEN ' test power button slider area? ENDGAME ' yes, end the game
KeyPress$
= INKEY$ ' get any key player may have pressed DISPLAYHELP ' yes, display help screen to player
LOOP ' MAIN GAME LOOP end
'--------------------
'- END MAIN PROGRAM -
'--------------------
'---------------------------
'- SUBROUTINES & FUNCTIONS -
'---------------------------
'----------------------------------------------------------------------------------------------------------------------
' DISPLAYHELP
'---------------------------------------
'- Display the help screen to the player
'---------------------------------------
SHARED SimonHelp&
' simon help screen
_PUTIMAGE (0, 0), SimonHelp&
' display help screen DO ' BEGIN KEY/MOUSE LOOP _LIMIT 120 ' don't hog the CPU PRESSPAD 0, 0 ' restore game screen
'----------------------------------------------------------------------------------------------------------------------
' WAIT4RELEASE
'--------------------------------------------
'- Waits for left mouse button to be released
'--------------------------------------------
DO ' BEGIN MOUSE RELEASE LOOP _LIMIT 120 ' don't hog the CPU
'----------------------------------------------------------------------------------------------------------------------
' SIMONFILE
'------------------------------------------
'- Loads, updates, or deletes the save file
'-
'- Task%: 0 - load file
'- 1 - update file
'- 2 - delete file
'------------------------------------------
SHARED Longest$
' the longest tune correctly played by a player
LINE INPUT #1, Longest$
' get the longest tune ever played CLOSE #1 ' close the file PRINT #1, Longest$
' write the longest tune ever played CLOSE #1 ' close the file KILL "simon.sav" ' yes, delete it
'----------------------------------------------------------------------------------------------------------------------
' POINTER%
'------------------------------------------------------------------------------
'- Returns TRUE if the mouse pointer falls within x1%,y1% - x2%,y2% coordinates
'-
'- x1%: upper left hand corner x coordinate of box area
'- y1%: upper left hand corner y coordinate of box area
'- x2%: lower right hand corner x coordinate of box area
'- y2%: lower right hand corner y coordinate of box area
'------------------------------------------------------------------------------
DIM mx%
' current mouse pointer x coordinate DIM my%
' current mouse pointer y coordinate
POINTER% = FALSE ' assume pointer does not fall within coordinates
mx%
= _MOUSEX ' get current mouse pointer x coordinate my%
= _MOUSEY ' get current mouse pointer y coordinate IF mx%
>= x1%
THEN ' could pointer be within x coordinates? IF mx%
<= x2%
THEN ' yes, is pointer within x coordinates? IF my%
>= y1%
THEN ' yes, could pointer be within y coordinates? IF my%
<= y2%
THEN ' yes, is pointer within y coordinates? POINTER% = TRUE ' yes, report back that pointer falls within coordinates
'----------------------------------------------------------------------------------------------------------------------
' PLAYGAME
'-----------------------
'- Plays a game of simon
'-----------------------
SHARED GameOver%
' boolean: true when game has ended SHARED Game%
' the position the blue slider switch is in (0-2) SHARED Skill%
' the position the red slider switch is in (0-3) SHARED Longest$
' the longest tune correctly played by a player SHARED Last$
' the last tune played by the player
DIM Tune$
' string of random tunes generated during game play DIM KeyPress&
' contains value of any key pressed DIM PlaySpeed!
' speed that simon plays notes DIM Count%
' generic counter DIM Notes%
' player note counter DIM PadPress%
' value of colored pad pressed by player DIM Plongest$
' current player's longest tune DIM Win%
' number of correct tones to win
'-------------
'- MAIN CODE -
'-------------
PRESSPAD 0, 0 ' reset game screen
PlaySpeed! = 1 ' reset game speed
Win% = 12 + Skill% * 6 ' calculate number of tones to win
Tune$ = "" ' reset random tune string
DO ' BEGIN PLAY GAME LOOP FOR Count%
= 1 TO Game%
+ 1 ' number of notes to add PlaySpeed! = PlaySpeed! - .125 ' yes, increase speed of play
IF PlaySpeed!
< .125 THEN PlaySpeed!
= .125 ' keep play speed at certain minimum FOR Count%
= 1 TO LEN(Tune$
) ' cycle through the tones PRESSPAD
VAL(MID$(Tune$
, Count%
, 1)), PlaySpeed!
' play the tone _DELAY PlaySpeed!
/ 4 ' pause between tones Notes% = 0 ' reset player note count
DO ' BEGIN PLAY ROUND LOOP DO ' BEGIN BUFFER CLEAR LOOP KeyPress&
= _KEYHIT ' get keypress from keyboard buffer LOOP WHILE KeyPress&
' END BUFFER CLEAR LOOP when buffer clear Notes% = Notes% + 1 ' increment player note count
PadPress% = PLAYERINPUT% ' get player's next color pad press
IF PadPress%
<> VAL(MID$(Tune$
, Notes%
, 1)) THEN ' did the player press the right color pad? GameOver% = TRUE ' no, set game over flag
PRESSPAD 4, 2 ' play loser sound and light up simon
LOOP UNTIL Notes%
= LEN(Tune$
) OR GameOver%
' END PLAY ROUND LOOP when player success or game over IF NOT GameOver%
THEN Plongest$
= Tune$
' remember last attempt as player's longest IF Notes%
= Win%
THEN ' did player win? GameOver% = TRUE ' yes, set game over
FOR Win%
= 1 TO 6 ' cycle 6 times FOR Count%
= 0 TO 3 ' cycle through all color pads PRESSPAD Count%, .125 ' press color pad
_DELAY PlaySpeed!
* 2 ' slight delay between rounds LOOP UNTIL GameOver%
' END PLAY GAME LOOP when game over Last$ = Tune$ ' remember the entire last tune played
IF LEN(Plongest$
) > LEN(Longest$
) THEN ' did player set a new longest record? Longest$ = Plongest$ ' yes, remember the new longest tune
SIMONFILE 1 ' update simon.sav with new longest tune
'----------------------------------------------------------------------------------------------------------------------
' PLAYERINPUT%
' -----------------------------------------------------------------------
' Waits for player input then returns the color pad pressed by the player
' -----------------------------------------------------------------------
SHARED Pcolor~&
() ' color pad base colors: 0=BLUE, 1=RED, 2=GREEN, 3=YELLOW
DIM PadPress%
' the color pad that was pressed DIM KeyPress&
' a key the player has pressed DIM mx%
' current mouse pointer x coordinate DIM my%
' current mouse pointer y coordinate DIM Clr~&
' color of pixel clicked on
PadPress% = -1 ' reset pad press indicator
_LIMIT 120 ' don't hog the CPU KeyPress&
= _KEYHIT ' get the latest key status IF KeyPress&
THEN ' was a key pressed? CASE 81, 113 ' Q or q key PRESSPAD 0, KeyPress& ' press blue pad on simon
PadPress% = 0 ' remember blue pad pressed
CASE 87, 119 ' W or w key PRESSPAD 1, KeyPress& ' press red pad on simon
PadPress% = 1 ' remember red pad pressed
CASE 83, 115 ' S or s key PRESSPAD 2, KeyPress& ' press green pad on simon
PadPress% = 2 ' remember green pad pressed
PRESSPAD 3, KeyPress& ' press yellow pad on simon
PadPress% = 3 ' remember yellow pad pressed
mx%
= _MOUSEX ' yes, get x location of mouse pointer my%
= _MOUSEY ' get y location of mouse pointer IF mx%
< 320 AND my%
< 320 AND Clr~&
= Pcolor~&
(0) THEN ' pointer in blue area? PRESSPAD 0, MOUSE% ' yes, press blue pad on simon
PadPress% = 0 ' remember blue pad pressed
ELSEIF mx%
> 319 AND my%
< 320 AND Clr~&
= Pcolor~&
(1) THEN ' no, pointer in red area? PRESSPAD 1, MOUSE% ' yes, press red pad on simon
PadPress% = 1 ' remember red pad pressed
ELSEIF mx%
> 319 AND my%
> 319 AND Clr~&
= Pcolor~&
(2) THEN ' no, pointer in green area? PRESSPAD 2, MOUSE% ' yes, press green pad on simon
PadPress% = 2 ' remember green pad pressed
ELSEIF mx%
< 320 AND my%
> 319 AND Clr~&
= Pcolor~&
(3) THEN ' no, pointer in yellow area? PRESSPAD 3, MOUSE% ' yes, press yellow pad on simon
PadPress% = 3 ' remember yellow pad pressed
LOOP UNTIL PadPress%
<> -1 ' END INPUT LOOP when simon pad pressed PLAYERINPUT% = PadPress% ' return the pad that was pressed
'----------------------------------------------------------------------------------------------------------------------
' PRESSPAD
SUB PRESSPAD
(PadNum%
, Behavior!
)
' -----------------------------------------------------------------------------------------
' Simulates pressing a colored pad by lighting it up and playing its corresponding sound
'
' PadNum% - The colored pad to press: 0=BLUE, 1=RED, 2=GREEN, 3=YELLOW, 4=ALL
' Behavior! - If value is less than 5 then sound plays for this duration
' - If value is less than 120 then sound plays until scancode of key is released
' - if value > 120 then sound plays until left mouse button is released
' - if value is zero then game board is redrawn only
' -----------------------------------------------------------------------------------------
SHARED Pad&
() ' color pads: 0,x=BLUE, 1,x=RED, 2,x=GREEN, 3,x=YELLOW SHARED PadXY%
() ' x,y locations of color pads SHARED Simon&
' simon graphics image SHARED Keys&
() ' keyboard key images 0=Q, 1=W, 2=S, 3=A SHARED KeysXY%
() ' location of keyboard key images SHARED Bslider&
' blue slider switch image SHARED Rslider&
' red slider switch image SHARED OnOff&
' on/off slider switch SHARED Game%
' the position the blue slider switch is in (0-2) SHARED Skill%
' the position the red slider switch is in (0-3)
DIM KeyPress&
' key press value DIM KeyStatus%
' 0=no key animation, 1=key animation
'-------------
'- MAIN CODE -
'-------------
KeyStatus% = 1 ' assume key animation
IF Behavior!
THEN ' just a board redraw? IF Behavior!
= MOUSE%
OR Behavior!
< 5 THEN ' turn key animation off? KeyStatus% = 0 ' yes, turn animation off
IF PadNum%
<> 4 THEN ' single color pad selected? _PUTIMAGE (PadXY%
(PadNum%
, 0), PadXY%
(PadNum%
, 1)), Pad&
(PadNum%
, 1) ' yes, light color pad _PUTIMAGE (KeysXY%
(PadNum%
, 0), KeysXY%
(PadNum%
, 1)), Keys&
(PadNum%
, KeyStatus%
) ' animate key if needed ELSE ' no, all color pads selected FOR Count%
= 0 TO 3 ' cycle through all color pads _PUTIMAGE (PadXY%
(Count%
, 0), PadXY%
(Count%
, 1)), Pad&
(Count%
, 1) ' light color pad _PUTIMAGE (KeysXY%
(Count%
, 0), KeysXY%
(Count%
, 1)), Keys&
(Count%
, 0) ' set keys to raised position _PUTIMAGE (200, 200), Simon&
' place round simon image _PUTIMAGE (232 + Game%
* 10, 323), Bslider&
' place blue slider _PUTIMAGE (319 + Skill%
* 10, 323), Rslider&
' place red slider _PUTIMAGE (321, 408), OnOff&
' place power button slider _SNDLOOP Tone&
(PadNum%
) ' sound into continuous loop CASE IS < 5 ' computer pressing color pad _DELAY Behavior!
' use value as a delay CASE IS < 120 ' player is pressing a key _DELAY .125 ' pause for 1/8 second DO ' BEGIN KEYBOARD SCAN LOOP KeyPress%
= _KEYHIT ' get value of key pressed LOOP UNTIL KeyPress%
= -Behavior!
' END LOOP when key released _DELAY .125 ' pause for 1/8 second WAIT4RELEASE ' wait left button released
_SNDSTOP Tone&
(PadNum%
) ' stop the sound FOR Count%
= 0 TO 3 ' cycle through all color pads _PUTIMAGE (PadXY%
(Count%
, 0), PadXY%
(Count%
, 1)), Pad&
(Count%
, 0) ' unlight color pad _PUTIMAGE (KeysXY%
(Count%
, 0), KeysXY%
(Count%
, 1)), Keys&
(Count%
, 0) ' set keys to raised position _PUTIMAGE (200, 200), Simon&
' place round simon image _PUTIMAGE (232 + Game%
* 10, 323), Bslider&
' place blue slider _PUTIMAGE (319 + Skill%
* 10, 323), Rslider&
' place red slider _PUTIMAGE (321, 408), OnOff&
' place power button slider
'----------------------------------------------------------------------------------------------------------------------
' INITIALIZE
' --------------------------------------------------------------------------------------------
' Initialize all variables, create color pad images, load sounds and load spritesheet graphics
' --------------------------------------------------------------------------------------------
SHARED Pad&
() ' color pads: 0,x=BLUE, 1,x=RED, 2,x=GREEN, 3,x=YELLOW SHARED PadXY%
() ' x,y locations of color pads SHARED Simon&
' simon graphics image SHARED SimonHelp&
' simon help screen SHARED Keys&
() ' keyboard key images 0=Q, 1=W, 2=S, 3=A SHARED Bslider&
' blue slider switch image SHARED Rslider&
' red slider switch image SHARED OnOff&
' on/off slider switch SHARED KeysXY%
() ' location of keyboard key images SHARED Game%
' the position the blue slider switch is in (0-2) SHARED Skill%
' the position the red slider switch is in (0-3) SHARED GameDir%
' the direction blue slider switch will move (1, -1) SHARED SkillDir%
' the direction red slider switch will move (1, -1) SHARED Pcolor~&
() ' color pad base colors: 0=BLUE, 1=RED, 2=GREEN, 3=YELLOW
DIM Sheet&
' sprite sheet containing game graphics DIM Mask&
' color pad mask image DIM Count%
' increasing color brightness counter DIM Pcount%
' pad counter DIM x%
' x location of pad circles DIM y%
' y location of pad circles DIM Clr~&
' temporary color pad color holder
'-------------
'- MAIN CODE -
'-------------
Tone&
(0) = _SNDOPEN("SimonB209.ogg", "VOL,SYNC") ' load blue sound 209 Hz Tone&
(1) = _SNDOPEN("SimonR310.ogg", "VOL,SYNC") ' load red sound 310 Hz Tone&
(2) = _SNDOPEN("SimonG415.ogg", "VOL,SYNC") ' load green sound 415 Hz Tone&
(3) = _SNDOPEN("SimonY252.ogg", "VOL,SYNC") ' load yellow sound 252 Hz Tone&
(4) = _SNDOPEN("SimonL042.ogg", "VOL,SYNC") ' load lose sound 42 Hz Simon&
= _NEWIMAGE(242, 242, 32) ' simon image holder Bslider&
= _NEWIMAGE(57, 22, 32) ' blue slider image holder Rslider&
= _NEWIMAGE(57, 22, 32) ' red slider image holder OnOff&
= _NEWIMAGE(11, 11, 32) ' power button slider image holder Sheet&
= _LOADIMAGE("SimonGFX.png", 32) ' load simon sprite sheet of images SimonHelp&
= _LOADIMAGE("SimonHELP.png", 32) ' load simon help screen _PUTIMAGE (0, 0), Sheet&
, Simon&
, (0, 94)-(241, 335) ' extract simon from spritesheet _PUTIMAGE (0, 0), Sheet&
, Bslider&
, (200, 0)-(256, 21) ' extract blue slider from spritesheet _PUTIMAGE (0, 0), Sheet&
, Rslider&
, (200, 22)-(256, 43) ' extract red slider from spritesheet _PUTIMAGE (0, 0), Sheet&
, OnOff&
, (200, 44)-(210, 54) ' extract power button slider from spritesheet FOR Count%
= 0 TO 3 ' cycle through 4 color pads Pad&
(Count%
, 0) = _NEWIMAGE(320, 320, 32) ' create color pad off image Pad&
(Count%
, 1) = _NEWIMAGE(320, 320, 32) ' create color pad on image Keys&
(Count%
, 0) = _NEWIMAGE(50, 47, 32) ' create q,w,s,a raised key image holders Keys&
(Count%
, 1) = _NEWIMAGE(50, 47, 32) ' create q,w,s,a pressed key image holders _PUTIMAGE (0, 0), Sheet&
, Keys&
(Count%
, 0), (Count%
* 50, 0)-(Count%
* 50 + 49, 46) ' extract key raised images _PUTIMAGE (0, 0), Sheet&
, Keys&
(Count%
, 1), (Count%
* 50, 47)-(Count%
* 50 + 49, 93) ' extract key pressed images PadXY%(0, 0) = 0 ' color pad locations
PadXY%(0, 1) = 0
PadXY%(1, 0) = 320
PadXY%(1, 1) = 0
PadXY%(2, 0) = 320
PadXY%(2, 1) = 320
PadXY%(3, 0) = 0
PadXY%(3, 1) = 320
KeysXY%(0, 0) = 20 ' keyboard key image locations
KeysXY%(0, 1) = 20
KeysXY%(1, 0) = 570
KeysXY%(1, 1) = 20
KeysXY%(2, 0) = 570
KeysXY%(2, 1) = 573
KeysXY%(3, 0) = 20
KeysXY%(3, 1) = 573
Pcolor~&
(0) = _RGB32(0, 0, 128) ' blue color of pad in off condition Pcolor~&
(1) = _RGB32(128, 0, 0) ' red color of pad in off condition Pcolor~&
(2) = _RGB32(0, 128, 0) ' green color of pad in off condition Pcolor~&
(3) = _RGB32(128, 128, 0) ' yellow color of pad in off condition Game% = 0 ' set initial game level
Skill% = 0 ' set initial skill level
GameDir% = -1 ' set intial blue slider direction
SkillDir% = -1 ' set initial red slider direction
SIMONFILE 0 ' load longest tune ever played if available
'*
'* Create the eight semi-circle color pads, four off, four on
'*
FOR Pcount%
= 0 TO 3 ' cycle through four color pads _DEST Pad&
(Pcount%
, 0) ' set color pad off image as destination CLS ' remove black transparency SELECT CASE Pcount%
' which color pad is being worked on? x% = 319: y% = 319 ' set x,y coordinates of circles
x% = 0: y% = 319 ' set x,y coordinates of circles
x% = 0: y% = 0 ' set x,y coordinates of circles
CASE 3 ' yellow color pad x% = 319: y% = 0 ' set x,y coordinate of circles
CIRCLE (x%
, y%
), 319, _RGB32(16, 16, 16) ' draw simon outer circle segment CIRCLE (x%
, y%
), 300, Pcolor~&
(Pcount%
) ' draw color pad outer circle segment CIRCLE (x%
, y%
), 140, Pcolor~&
(Pcount%
) ' draw color pad inner circle segment PAINT (159, 159), Pcolor~&
(Pcount%
), Pcolor~&
(Pcount%
) ' paint color pad circle segment interior LINE (x%
, y%
)-(ABS(319 - x%
), ABS(10 - y%
)), _RGB32(16, 16, 16), BF
' separate color pads horizontally LINE (x%
, y%
)-(ABS(10 - x%
), ABS(319 - y%
)), _RGB32(16, 16, 16), BF
' separate color pads vertically CIRCLE (x%
, y%
), 319, _RGB32(32, 32, 32) ' highlight edge of simon Mask&
= _COPYIMAGE(Pad&
(Pcount%
, 0)) ' create an image mask _DEST Mask&
' set the mask as the destination _CLEARCOLOR Pcolor~&
(Pcount%
) ' set circle segment as transparent _DEST Pad&
(Pcount%
, 1) ' set color pad on image as destination CLS ' remove black transparency Clr~& = Pcolor~&(Pcount%) ' remember color being worked on
LINE (0, 0)-(319, 319), Clr~&
, BF
' fill entire image with color pad color FOR Count%
= 129 TO 255 ' cycle 126 times SELECT CASE Pcount%
' which color pad is being worked on? Clr~& = Clr~& + 1 ' increase blue component
Clr~& = Clr~& + 65536 ' increase red component
Clr~& = Clr~& + 256 ' increase green component
CASE 3 ' yellow color pad Clr~& = Clr~& + 65792 ' increase red and green component (yellow)
CIRCLE (159, 159), (255 - Count%
) * 2, Clr~&
' draw circle with new color component PAINT (159, 159), Clr~&
, Clr~&
' paint inside circle new color component _PUTIMAGE (0, 0), Mask&
' place mask over circles _FREEIMAGE Mask&
' remove mask image from RAM (no longer needed) _FREEIMAGE Sheet&
' remove spritesheet from RAM (no longer needed)
'----------------------------------------------------------------------------------------------------------------------
' ENDGAME
'--------------------------------------------------------------------
'- Removes game's assets from RAM and returns to the operating system
'--------------------------------------------------------------------
SHARED Pad&
() ' color pads: 0,x=BLUE, 1,x=RED, 2,x=GREEN, 3,x=YELLOW SHARED Simon&
' simon graphics image SHARED SimonHelp&
' simon help screen SHARED Keys&
() ' keyboard key images 0=Q, 1=W, 2=S, 3=A SHARED Bslider&
' blue slider switch image SHARED Rslider&
' red slider switch image SHARED OnOff&
' on/off slider switch
DIM Count%
' generic counter
LINE (321, 408)-(331, 418), _RGB32(0, 0, 0), BF
' clear power button _PUTIMAGE (313, 408), OnOff&
' place power button in new position FOR Count%
= 0 TO 3 ' cycle through assets _FREEIMAGE Keys&
(Count%
, 0) ' remove key raised images _FREEIMAGE Keys&
(Count%
, 1) ' remove key pressed images _FREEIMAGE Pad&
(Count%
, 0) ' remove color pad unlit images _FREEIMAGE Pad&
(Count%
, 1) ' remove color pad lit images _FREEIMAGE SimonHelp&
' remove simon help screen image _FREEIMAGE Bslider&
' remove blue slider switch image _FREEIMAGE Rslider&
' remove red slider switch image _FREEIMAGE OnOff&
' remove on/off power switch image SYSTEM ' return control to the operating system