'Number Guessing Game
'Cobalt 2019/1/2
'-------------setup------------------------------
CONST HAPPY
= 1, ANGRY
= 2, Neutral
= 0 '------------------------------------------------
'Face Data FF,FR,FL,FH,FAR,FAL,W1,W2
DATA 10,2016,2064,5160,4488,4488,4104,4104,4104,2064,2016,9,2016,2064,4360,4104,7688,4104,4104,2064,2016 DATA 9,2016,2064,4232,4104,4216,4104,4104,2064,2016,11,2016,2640,4104,5160,6120,6120,6120,5064,4104,2064,2016 DATA 12,992,1040,2096,4192,5824,4224,4264,4344,4104,4104,2064,2016,12,1984,2080,3088,1544,872,264,5384,7944,4104,4104,2064,2016 DATA 10,2016,2064,4680,4104,4488,4104,4104,4104,2064,2016,9,2016,2064,5160,4104,4488,4104,4104,2064,2016 '-----------Load Face Data-----------------------
shift%% = (16 - L%%) \ 2 'center image in 16 lines
READ Pic
(J%%
, i%%
+ shift%%
) Pic
(J%%
, i%%
+ shift%%
) = _SHL(Pic
(J%%
, i%%
+ shift%%
), 8) 'center image in 32 rows'------------------------------------------------
Pick_Numbs NumbA%%, NumbB%%
'--------------side A Number---------------------
'------------------------------------------------
'--------------Side B Number---------------------
'_PUTIMAGE (288, 64)-STEP(32, 64), Numbers&, _DISPLAY, (16 * NumbB%%, 0)-STEP(8, 16)
'------------------------------------------------
'------------------Main Game Loop----------------
_PRINTSTRING (75, 330), "Using Left\Right Arrow keys Pick which number will be Greater" Dot_Display
4, 447, 350, 2, _RGB32(16, 212, 96)Dot_Display
5, 0, 350, 2, _RGB32(224, 16, 32)G.Happiness = 0
IF face_frame%%
= 7 THEN face_frame%%
= 8 ELSE face_frame%%
= 7 ExitFlag%% = TRUE
'------------------CHOOSE LEFT-----------------
G.Trys = G.Trys + 1
Dot_Display
2, 80, 64, 5, _RGB32(128, 128, 128) G.Face = HAPPY
G.Wins = G.Wins + 1
G.Happiness = G.Happiness + 1
G.Face = ANGRY
G.Losses = G.Losses + 1
G.Happiness = G.Happiness - 1
Pick_Numbs NumbA%%, NumbB%%
G.Face = Neutral
'---------------------------------------------
'----------------CHOOSE RIGHT------------------
G.Trys = G.Trys + 1
Dot_Display
3, 80, 64, 5, _RGB32(128, 128, 128) G.Face = HAPPY
G.Wins = G.Wins + 1
G.Happiness = G.Happiness + 1
G.Face = ANGRY
G.Losses = G.Losses + 1
G.Happiness = G.Happiness - 1
Pick_Numbs NumbA%%, NumbB%%
G.Face = Neutral
'---------------------------------------------
Display_Happiness
'-------------------after 5 go's check how player did----------
'--------------------------------------------------------------
'------------------------------------------------
'-------------Dot Matrix display-----------------
'32x16- 16 LONG integers
SUB Dot_Display
(image%%
, X%
, Y%
, Scale%%
, Colr~&
) Yloc% = Y% + (3 * Scale%%) * J%%
Xloc% = X% + (3 * Scale%%) * (31 - I%%)
IF Pic
(image%%
, J%%
) AND 2 ^ I%%
THEN 'Dot is Lit LINE (Xloc%
, Yloc%
)-STEP(2 * Scale%%
, 2 * Scale%%
), Colr~&
, BF
LINE (Xloc%
, Yloc%
)-STEP(2 * Scale%%
, 2 * Scale%%
), _RGB32(16, 12, 16), BF
'------------------------------------------------
'-----------------32Bit PRNG---------------------
High~&
= INT(RND * (2 ^ 16)) 'upper 16 bits Low~%
= INT(RND * (2 ^ 16)) 'lower 16 bits RND32~&
= _SHL(High~&
, 16) + Low~%
'------------------------------------------------
'------------Create Face data values-------------
IF t%%
THEN result~&
= result~&
+ 2 ^ i%%
result~&
= _SHL(result~&
, SHFL%%
) MakeData~& = result~&
'------------------------------------------------
'------------Change Face animations--------------
IF face_frame%%
= 7 THEN face_frame%%
= 8 ELSE face_frame%%
= 7 IF face_frame%%
= 1 THEN face_frame%%
= 4 ELSE face_frame%%
= 1 IF face_frame%%
= 5 THEN face_frame%%
= 6 ELSE face_frame%%
= 5 Dot_Display face_frame%%
, 80, 64, 5, _RGB32(128, 128, 128)'------------------------------------------------
'------------------pick new numbers--------------
SUB Pick_Numbs
(NumbA%%
, NumbB%%
) DO 'make sure 2 different numbers chosen '------------------------------------------------
'---------------Happiness Scale------------------
IF G.Happiness
> 0 THEN vals%%
= 1 ELSE vals%%
= -1 LINE (320 + i%%
, 350)-(320 + i%%
, 450), _RGB32(127 - i%%
, 127 + i%%
, 0) '------------------------------------------------