'===============
'INSANECLONE.BAS
'===============
'A close clone of Qbasic puzzle game called 'Insane" by entropy.
'Coded for QB64 by Dav, SEP/2018 during Hurricane Florence (NC).
'==============================================================
'CREDITS: Heavily inspired by Qbasic game "insane" by 'entropy'
' It's about the same idea, you clear groups of blocks.
'==============================================================
'===========
'HOW TO PLAY:
'===========
'
'Try to clear the board of groups of color blocks.
'You click on a group of colors to remove that group.
'Any Blocks left above will drop down to fill in the holes.
'Blocks move to the right when a whole column is cleared.
'SPACE key will generate a new puzzle board.
'ESC key quits.
'==============================================================
rows = 10: columns = 10: size = 60
'=== set up screen
'======
newgame:
'======
'generate random board colors
'make sure there's enough groups present to do puzzle.
'without this here, it's soooo hard! Really insane...
IF NumberOfGroups
< rows
* columns
- rows
THEN GOTO newgame
nm = 0 'block count
nm = nm + 1
bx = (r * size) - size: by = (c * size) - size
old = Block(r, c) 'block color
'only do when non black touched
'only do if a neighbor block color is same
nn = 0
IF Block
(r
- 1, c
) = old
THEN nn
= 1 IF Block
(r
+ 1, c
) = old
THEN nn
= 1 IF Block
(r
, c
- 1) = old
THEN nn
= 1 IF Block
(r
, c
+ 1) = old
THEN nn
= 1 'if a group of colors...
x = (r * size) - size: y = (c * size) - size
selected:
'fill the group...
FloodFill old, 6, r, c
'show blacked out colors
'drop down blocks here...
IF Block
(r
, c
) <> Block
(r
, c2
) THEN moved
= 1 Block(r, c) = Block(r, c2): Block(r, c2) = 6
'move blocks right here...
IF Block
(r
, c
) <> Block
(r2
, c
) THEN moved
= 1 Block(r, c) = Block(r2, c): Block(r2, c) = 6
'redraw puzzle board
'wait until mouse button up to continue
'see if all blocks gone (cleared!)
h = 0
IF Block
(r
, c
) <> 6 THEN h
= 1
'if board is cleared, then you win...
LINE (200, 200)-(400, 300), 15, BF
LINE (202, 202)-(398, 298), _RGB(0, 0, 255), BF
'see if any groups presently left
dn = NumberOfGroups
'if no more groups, end...
LINE (200, 200)-(400, 300), 15, BF
LINE (202, 202)-(398, 298), _RGB(0, 0, 255), BF
'=============================================================================
'==========
updateboard:
'==========
nm = 0
j = Block(r, c): nm = nm + 1
x = (r * size) - size: y = (c * size) - size
LINE (x
, y
)-(x
+ size
, y
+ size
), fill
, BF
LINE (x
, y
)-(x
+ size
, y
+ size
), 0, B
_DELAY .025 'add delay for moving effect
'=====================================================
'returns how many block groups left on board
dn = 0
IF Block
(r
- 1, c
) = Block
(r
, c
) THEN dn
= dn
+ 1 IF Block
(r
+ 1, c
) = Block
(r
, c
) THEN dn
= dn
+ 1 IF Block
(r
, c
- 1) = Block
(r
, c
) THEN dn
= dn
+ 1 IF Block
(r
, c
+ 1) = Block
(r
, c
) THEN dn
= dn
+ 1
NumberOfGroups = dn
'=====================================================
SUB FloodFill
(old
, clr
, x
, y
) Block(x, y) = clr
IF x
> 1 THEN FloodFill old
, clr
, x
- 1, y
IF x
< rows
THEN FloodFill old
, clr
, x
+ 1, y
IF y
> 1 THEN FloodFill old
, clr
, x
, y
- 1 IF y
< columns
THEN FloodFill old
, clr
, x
, y
+ 1