_TITLE "Flip It Squared" 'b+ started 2019-11-05 ' inspired by Steve's recent QB64 thread:
' https://www.qb64.org/forum/index.php?topic=1831.msg110717#msg110717
' from Quick Flip It experiments, add another dimemsion for complexity.
'Objective: to remove all cards from board
'Play: can only remove face up cards (lighter color), cards adjacent to removed card will be toggled up/down (dark/light).
CONST across
= 10, down
= 7, sqSide
= 50, sqSpace
= 60, marg
= 30 'should be enough to get the gist of what is going on CONST cardUp
= &HFFBBBBBB, cardDown
= &HFF000066, cardOut
= &HFF000000 xmax = across * sqSpace + 2 * marg: ymax = down * sqSpace + 2 * marg
gameover = 1
c = 0: r = 0
getCardClicked c, r 'this card is removed and cards adjacent (if any) are toggled up/down
IF state
(c
- 1, r
) <> -1 THEN state
(c
- 1, r
) = 1 - state
(c
- 1, r
) IF state
(c
+ 1, r
) <> -1 THEN state
(c
+ 1, r
) = 1 - state
(c
+ 1, r
) IF state
(c
, r
- 1) <> -1 THEN state
(c
, r
- 1) = 1 - state
(c
, r
- 1) IF state
(c
, r
+ 1) <> -1 THEN state
(c
, r
+ 1) = 1 - state
(c
, r
+ 1) state(c, r) = -1
updateScreen
IF mb
THEN ' get last place mouse button was down WHILE mb
' wait for mouse button release as a "click" IF mx
> (col
- 1) * sqSpace
+ marg
AND mx
< (col
- 1) * sqSpace
+ marg
+ sqSide
THEN IF my
> (row
- 1) * sqSpace
+ marg
AND my
< (row
- 1) * sqSpace
+ marg
+ sqSide
THEN col = 0: row = 0
SUB updateScreen
'and count the ups and downs of cards ups = 0: downs = 0 'count cards while displaying
ups = ups + 1: clr~& = cardUp
downs = downs + 1: clr~& = cardDown
clr~& = cardOut
LINE ((x
- 1) * sqSpace
+ marg
, (y
- 1) * sqSpace
+ marg
)-STEP(sqSide
, sqSide
), clr~&
, BF
yCP
10, SPACE$(60): yCP
10, "Ups, Downs: " + TS$
(ups
) + ", " + TS$
(downs
) 'check win
gameover = 1
yCP
10, SPACE$(60): yCP
10, "No win" yCP
10, SPACE$(60): yCP
10, "Win"
SUB initRound
'reassign letters and hide them all gameover = 0: updateScreen
SUB yCP
(y
, s$
) 'for xmax pixel wide graphics screen Center Print at pixel y row