'Simon Game
'Cobalt 2019-01-13
'INformation:
' 4 levels:
' 1-8 count pattern
' 2-16 count pattern
' 3-24 count pattern
' 4-32 count pattern
' Speed increase at 5,9,13,22,29 counts
' Tones E,C#,A,E-O1 ????
'Program actually adapts based off users screen size(upto 640vl anyway)
'------------------Types-------------------------
Level
AS _BYTE '1-4(easy,med,Norm,Hard) ScrnHeight
AS INTEGER 'computer's screen height Factor
AS SINGLE 'scale factor computer's height \640 GamePlay
AS _BYTE 'has player pressed START\GO! button? GO_GO_GO
AS _BYTE 'game started flag\ displaying pattern flag Display
AS _BYTE 'flag to display sequence Time_It
AS SINGLE 'after sequence display give player X# secs to enter each entry Current_Light
AS _BYTE 'where is player in sequence '---these pertain to click area colors-----------
'------------------------------------------------
'------------------------------------------------
'-----------------Arrays and Consts--------------
CONST EASY
= 1, MED
= 2, NORM
= 3, HARD
= 4 CONST SLOWEST
= 9, SLOWER
= 7, SLOW
= 6, FAST
= 5, FASTER
= 3, FASTEST
= 1 CONST RED
= 15, BLUE
= 31, GREEN
= 63, YELLOW
= 127, LOSER
= 1, GO
= 69 '------------------------------------------------
'-------------Setup------------------------------
G.ScrnHeight = 640
IF G.ScrnHeight
>= 640 THEN G.Factor
= 1 ELSE G.Factor
= G.ScrnHeight
/ 640 - .0125 '-------------layer loader-----------------------
GET #1, , c~%%
'number of records FOffset&(w%) = FOffset&(w%) + 1
'------------------------------------------------
Layer
(0) = _NEWIMAGE(640, 640 * G.Factor
, 32)Layer(1) = LoadGFX&(FOffset&(4), Size(4))
Layer(2) = LoadGFX&(FOffset&(3), Size(3))
Layer(3) = LoadGFX&(FOffset&(5), Size(5))
Layer(4) = LoadGFX&(FOffset&(2), Size(2))
Layer(5) = LoadGFX&(FOffset&(1), Size(1))
Layer
(6) = _NEWIMAGE(640, 640 * G.Factor
, 32)Layer
(7) = _NEWIMAGE(640, 640 * G.Factor
, 32)'--------------Sound Loader----------------------
FOffset&(w%) = FOffset&(w%) + 1
SFX(0) = LoadSFX&(FOffset&(3), Size(3)) '_SNDOPEN("RedTone.wav")
SFX(1) = LoadSFX&(FOffset&(1), Size(1)) '_SNDOPEN("BlueTone.wav")
SFX(2) = LoadSFX&(FOffset&(2), Size(2)) '_SNDOPEN("GreenTone.wav")
SFX(3) = LoadSFX&(FOffset&(4), Size(4)) '_SNDOPEN("YellowTone.wav")
SFX(4) = LoadSFX&(FOffset&(5), Size(5)) '_SNDOPEN("LoseTone.wav")
G.Yellow_Button
= _RGB32(255, 255, 0)G.Blue_Button
= _RGB32(0, 0, 255)G.Green_Button
= _RGB32(0, 255, 0)G.Red_Button
= _RGB32(255, 0, 0)G.Up_Arrow
= _RGB32(128, 0, 128)G.Down_Arrow
= _RGB32(160, 0, 160)G.Go_Button
= _RGB32(192, 0, 192)ON TIMER(Ti
(0), .05) Start_Flash_Yellow
Simon_Base
Simon_Label
Setup_Click_Area
'------------------------------------------------
Start_Up_Values
'------------------Main Loop---------------------
Simon_Mouse
IF G.Display
THEN _DELAY .75: G.GO_GO_GO
= FALSE: Display_Sequence
IF G.Last_Click
= Sequence
(G.Current_Light
) THEN IF G.Current_Light
= G.Level
* 8 THEN Winner%%
= TRUE: exitflag%%
= TRUE: G.Current_Light
= 0 G.Current_Light = G.Current_Light + 1
IF G.Current_Light
> G.Length
THEN Add_Color
G.Loser = TRUE
Start_Tone LOSER
Build_Display
Stop_Tone LOSER
Start_Up_Values
IF G.Length
= 5 THEN G.Speed
= SLOWER
IF G.Length
= 9 THEN G.Speed
= SLOW
IF G.Length
= 14 THEN G.Speed
= FAST
IF G.Length
= 22 THEN G.Speed
= FASTER
IF G.Length
= 29 THEN G.Speed
= FASTEST
G.Loser = TRUE
Start_Tone LOSER
Build_Display
Stop_Tone LOSER
Start_Up_Values
Build_Display
G.Last_Click = FALSE
'------------------------------------------------
_PUTIMAGE (0, 0)-STEP(320 * G.Factor
, 320 * G.Factor
), Layer
(3), Layer
(0), (0, 0)-(146, 146)
_PUTIMAGE (320 * G.Factor
, 320 * G.Factor
)-STEP(320 * G.Factor
, 320 * G.Factor
), Layer
(3), Layer
(0), (147, 147)-(293, 293)
_PUTIMAGE (320 * G.Factor
, 0)-STEP(320 * G.Factor
, 320 * G.Factor
), Layer
(3), Layer
(0), (147, 0)-(293, 146)
_PUTIMAGE (0, 320 * G.Factor
)-STEP(320 * G.Factor
, 320 * G.Factor
), Layer
(3), Layer
(0), (0, 147)-(146, 293)
_PUTIMAGE (0, 0)-STEP(640 * G.Factor
, 640 * G.Factor
), Layer
(1), Layer
(7)
G.Length = G.Length + 1 'add one level to sequence
G.Display = TRUE 'tell main loop to display new sequence
G.Current_Light = 1 'start player at first entry
Sequence(G.Length) = YELLOW
Sequence(G.Length) = BLUE
Sequence(G.Length) = RED
Sequence(G.Length) = GREEN
x% = 170 * G.Factor
y% = 158 * G.Factor
_PUTIMAGE (x%
, y%
)-STEP(294 * G.Factor
, 294 * G.Factor
), Layer
(2), Layer
(7)
x% = 170 * G.Factor
y% = 284 * G.Factor
_PUTIMAGE (x%
, y%
)-STEP(294 * G.Factor
, 37 * G.Factor
), Layer
(4), Layer
(0), (0, 32)-(127, 47) _PUTIMAGE (x%
+ 60, y%
)-STEP(45 * G.Factor
, 37 * G.Factor
), Layer
(4), Layer
(0), (3, 16)-(22, 31) _PUTIMAGE (x%
+ 107, y%
)-STEP(44 * G.Factor
, 37 * G.Factor
), Layer
(4), Layer
(0), (23, 16)-(42, 31) _PUTIMAGE (x%
+ 152, y%
)-STEP(44 * G.Factor
, 37 * G.Factor
), Layer
(4), Layer
(0), (43, 16)-(62, 31) _PUTIMAGE (x%
+ 198, y%
)-STEP(45 * G.Factor
, 37 * G.Factor
), Layer
(4), Layer
(0), (63, 16)-(82, 31)
x% = 196 * G.Factor
y% = 284 * G.Factor
_PUTIMAGE (x%
, y%
)-STEP(22 * G.Factor
, 32 * G.Factor
), Layer
(4), Layer
(0), (85, 0)-(96, 15) _PUTIMAGE (x%
+ 224, y%
)-STEP(22 * G.Factor
, 32 * G.Factor
), Layer
(4), Layer
(0), (85, 16)-(96, 31) LINE (x%
, y%
)-STEP(22 * G.Factor
, 32 * G.Factor
), G.Down_Arrow
, BF
LINE (x%
+ 224, y%
)-STEP(22 * G.Factor
, 32 * G.Factor
), G.Up_Arrow
, BF
SUB Start_Button
(state%%
) x% = 292 * G.Factor
y% = 360 * G.Factor
_PUTIMAGE (x%
, y%
)-STEP(52 * G.Factor
, 32 * G.Factor
), Layer
(4), Layer
(0), (97, 0)-(123, 15) _PUTIMAGE (x%
, y%
)-STEP(52 * G.Factor
, 32 * G.Factor
), Layer
(4), Layer
(0), (97, 16)-(123, 31) LINE (x%
, y%
)-STEP(52 * G.Factor
, 32 * G.Factor
), G.Go_Button
, BF
ButtonDown%% = TRUE
'--------lock mouse until button release---------
'stops program progess but not timer progress
'player could lose if they hold button down.
'this IS ment to be.
IF G.GO_GO_GO
THEN Press_Color: Start_Tone G.Last_Click
Stop_Tone G.Last_Click
'------------------------------------------------
Build_Display
G.Yellow_On = G.Yellow_On + 1
IF G.Yellow_On
> 19 THEN G.Yellow_On
= 1
_PUTIMAGE (0, 0)-STEP(640 * G.Factor
, 640 * G.Factor
), Layer
(5), Layer
(6)
IF G.Level
< 4 AND (NOT G.GamePlay
) THEN G.Level
= G.Level
+ 1 IF G.Level
> 1 AND (NOT G.GamePlay
) THEN G.Level
= G.Level
- 1 G.GamePlay = TRUE
StartUp%% = TRUE
G.Last_Click = GO
IF StartUp%%
THEN TIMER(Ti
(0)) OFF: G.Yellow_On
= FALSE: StartUp%%
= FALSE: Add_Color
G.Last_Click = YELLOW
G.Last_Click = BLUE
G.Last_Click = GREEN
G.Last_Click = RED
Button_Down_Lock
Level_LED
Level_Adjust_Arrows
Start_Button G.GamePlay
Start_Tone Sequence(i%%)
Yellow_Light
Blue_Light
Green_Light
Red_Light
Stop_Tone Sequence(i%%)
Build_Display
G.Display = FALSE 'done displaying sequence
G.Time_It
= TIMER + .15 'start player input timer +.25 for delay _DELAY .15 'short pause before player can start entering sequence G.GO_GO_GO = TRUE 'allow player to have mouse actions
G.Last_Click = FALSE
Yellow_Light
Blue_Light
Green_Light
Red_Light
Level_LED
Level_Adjust_Arrows
Start_Button G.GamePlay
'---------Build Display--------------------------
IF StartUp%%
AND G.Yellow_On
> 10 THEN Yellow_Light
Level_LED
Level_Adjust_Arrows
Start_Button G.GamePlay
'------------------------------------------------
'----------------Start Up Values ----------------
G.Level = 1
G.Speed = SLOWEST
G.Length = 0
G.Loser = FALSE
G.GamePlay = FALSE
G.GO_GO_GO = TRUE
G.Current_Light = 0
G.Display = FALSE
G.Time_It = 0
'------------------------------------------------