'=========
'TENTS.BAS v0.30
'==========
'Tents & Trees puzzle clone.
'Coded by Dav, FEB/2021
'Added: 10 levels. Navigate levels with left/right arrows
'Added: Current level shown in title bar
'Added: _ICON _DISPLAY for instant program icon
'Fixed: Reorganized how the board updates/draws.
'Fixed: Touching tent conflicts now shown instantly
'===========
'HOW TO PLAY:
'===========
'Click on blank squares to place tent next a tree.
'Every tree must have a tent next to it.
'However, tents cannot be next to other tents.
'If tents are touching, they will turn red.
'Numbers on side tell how many tents each row needs.
'When the right number is reach, number turns green.
'Too many tents in the row/col, number turns red.
'when all numbers turn green, and no tents are red,
'then the puzzle is completed.
'Pressing SPACE will retart level.
'Use Left/Right Arrows to navigate to other levels
'======================================================
grid = 9 '9x9 grid size (8 for tiles, 1 for number row/col)
tiles = grid * grid ' total number of tiles on board
'Make the images
tree& = BASIMAGE1&
tent& = BASIMAGE2&
blank& = BASIMAGE3&
Level = 1
LevelMax = 10
'======
Restart:
'======
'init values
bc = 1
tilex(bc) = (x * 75) - 75: tiley(bc) = (y * 75) - 75
tilem(bc) = 0
bc = bc + 1
'=======
MainLoop:
'=======
'wait until mouse button up to continue
'cycle through tiles
'skip the numbers sides
CASE 1 TO 10, 19, 28, 37, 46, 55, 64, 73:
GOTO skip
tx = tilex(t): tx2 = tilex(t) + 75
ty = tiley(t): ty2 = tiley(t) + 75
'if you clicked on a tile
'check for win, see if tent tally matches
win = 1
IF RowTally
(row
) <> tilev
(row
) THEN win
= 0 IF ColTally
(col
) <> tilev
(col
) THEN win
= 0
'See if there's any conflicting tents
tilem(r) = 1
win = 0
tilem(r) = 0
'If all still good, you won
Level = Level + 1
IF Level
> LevelMax
THEN Level
= 1
skip:
K$
= INKEY$ 'Check for a keypress 'Right arrows advance to next level
Level = Level + 1
IF Level
> LevelMax
THEN Level
= 1 'Left Arrows go back a level
Level = Level - 1
IF Level
< 1 THEN Level
= LevelMax
'space restarts level
'ESC ends game
'========
DrawBoard:
'========
bc = 1
CASE 1:
'skip this corner CASE 2 TO 10, 19, 28, 37, 46, 55, 64, 73 PPRINT tilex
(bc
), tiley
(bc
) + 10, 45, _RGB(128, 128, 128), 0, STR$(tilev
(bc
)) LINE (tilex
(bc
), tiley
(bc
))-(tilex
(bc
) + 75, tiley
(bc
) + 75), _RGBA(255, 0, 0, 100), BF
bc = bc + 1
'Update numbers in row
PPRINT tilex
(row
), tiley
(row
) + 10, 45, _RGB(255, 0, 0), 0, STR$(tilev
(row
)) PPRINT tilex
(row
), tiley
(row
) + 10, 45, _RGB(0, 255, 0), 0, STR$(tilev
(row
)) PPRINT tilex
(row
), tiley
(row
) + 10, 45, _RGB(128, 128, 128), 0, STR$(tilev
(row
))'Update numbers in cols
PPRINT tilex
(col
), tiley
(col
) + 10, 45, _RGB(255, 0, 0), 0, STR$(tilev
(col
)) PPRINT tilex
(col
), tiley
(col
) + 10, 45, _RGB(0, 255, 0), 0, STR$(tilev
(col
)) PPRINT tilex
(col
), tiley
(col
) + 10, 45, _RGB(128, 128, 128), 0, STR$(tilev
(col
))
'==================================================================
'=======
SetLevel:
'=======
CASE 1: lev$
= "012031302278877777177777878277777777177778777" lev$ = lev$ + "178778777177777777278777887277877787"
CASE 2: lev$
= "031120122278777787187777777277877778177778777" lev$ = lev$ + "277777777087787887377877777177777787"
CASE 3: lev$
= "021212040177877777287778877278777777177777778" lev$ = lev$ + "278777787177778777178877777277777877"
CASE 4: lev$
= "021111312177788778377777777187778777187788787" lev$ = lev$ + "377777777077777877287777777177777787"
CASE 5: lev$
= "021211212177787777277777777178788887277777777" lev$ = lev$ + "177777777187777778177877787378778777"
CASE 6: lev$
= "021121122277777777278778778177877777177777887" lev$ = lev$ + "277887777177777777177877788278777777"
CASE 7: lev$
= "012112122177777777287777787177787778378777878" lev$ = lev$ + "177878777177777778277877877177777777"
CASE 8: lev$
= "021211212277787777187778777178777877277777777" lev$ = lev$ + "278778778177778777177777787277877787"
CASE 9: lev$
= "011212113377777777077878778278778777277778778" lev$ = lev$ + "177777877087777778277777777277787877"
CASE 10: lev$
= "012121122278787778177777777177777787177777777" lev$ = lev$ + "378788777177787778177787877277877777"
'==================================================================
DoNum = row 'how many for all done
Count = 0
IF tilev
(t
) = 9 THEN Count
= Count
+ 1 RowTally = Count
'==================================================================
DoNum = tilev(col)
Count = 0
FOR t
= col
+ 1 TO col
+ 8 IF tilev
(t
) = 9 THEN Count
= Count
+ 1 ColTally = Count
'==================================================================
'returns if given tent num is touching another
Touching = 0
IF tilev
(num
+ 1) = 9 THEN Touching
= 1 IF tilev
(num
+ 9) = 9 THEN Touching
= 1 IF tilev
(num
+ 10) = 9 THEN Touching
= 1 CASE 18 'bottom left corner IF tilev
(num
- 1) = 9 THEN Touching
= 1 IF tilev
(num
+ 8) = 9 THEN Touching
= 1 IF tilev
(num
+ 9) = 9 THEN Touching
= 1 CASE 74 'top right corner IF tilev
(num
+ 1) = 9 THEN Touching
= 1 IF tilev
(num
- 8) = 9 THEN Touching
= 1 IF tilev
(num
- 9) = 9 THEN Touching
= 1 CASE 81 'bottom right corner IF tilev
(num
- 1) = 9 THEN Touching
= 1 IF tilev
(num
- 9) = 9 THEN Touching
= 1 IF tilev
(num
- 10) = 9 THEN Touching
= 1 CASE 20, 29, 38, 47, 56, 65 'top row, 20 to 65 IF tilev
(num
+ 1) = 9 THEN Touching
= 1 IF tilev
(num
- 9) = 9 THEN Touching
= 1 IF tilev
(num
+ 9) = 9 THEN Touching
= 1 CASE 27, 36, 45, 54, 63, 72 'bottom row, 27 to 72 IF tilev
(num
- 1) = 9 THEN Touching
= 1 IF tilev
(num
- 9) = 9 THEN Touching
= 1 IF tilev
(num
+ 9) = 9 THEN Touching
= 1 CASE 12 TO 17 'left side, 12 to 17 IF tilev
(num
- 1) = 9 THEN Touching
= 1 IF tilev
(num
+ 1) = 9 THEN Touching
= 1 IF tilev
(num
+ 8) = 9 THEN Touching
= 1 IF tilev
(num
+ 9) = 9 THEN Touching
= 1 IF tilev
(num
+ 10) = 9 THEN Touching
= 1 IF tilev
(num
- 1) = 9 THEN Touching
= 1 IF tilev
(num
+ 1) = 9 THEN Touching
= 1 IF tilev
(num
- 8) = 9 THEN Touching
= 1 IF tilev
(num
- 9) = 9 THEN Touching
= 1 IF tilev
(num
- 10) = 9 THEN Touching
= 1 IF tilev
(num
- 1) = 9 THEN Touching
= 1 IF tilev
(num
+ 1) = 9 THEN Touching
= 1 IF tilev
(num
- 8) = 9 THEN Touching
= 1 IF tilev
(num
+ 8) = 9 THEN Touching
= 1 IF tilev
(num
- 9) = 9 THEN Touching
= 1 IF tilev
(num
+ 9) = 9 THEN Touching
= 1 IF tilev
(num
- 10) = 9 THEN Touching
= 1 IF tilev
(num
+ 10) = 9 THEN Touching
= 1
'=======================================================================
A$ = ""
A$ = A$ + "haIkL_SD343360N;YTB:cAQ:ZYRc2UL0h2#77P];GPDc#572Zc=`4W9NaIO5"
A$ = A$ + "KI9mkMG5?JPQQRT_8ITLfUVV6GS5F8DlmYe7fJ`jgC[nFioi?mecFd;fOJIF"
A$ = A$ + "IF]E\jMgWW3d??ZM[naM\kiRok[5cZ=[jL:\R<c\J2WNiBdn_IXmZF\JDWRS"
A$ = A$ + "8_#ECF3FMCWji5ZL<dFU\CCDCZI>6B[bf9`iHX\bW?#f9#iHX\Z;WZ]0[D>7"
A$ = A$ + "3QE5EkUH>fJ`:ALBYN;dd:aMBhJB]\BLWJS2ge_Nh:oB3[^bYfI2ZndcVhJ#"
A$ = A$ + ">[3UfZ^N3B9ba[fY]AZN7d8_:ne#LhOmiODJoXn7BH32[V]^\dm`Dl<8PgO5"
A$ = A$ + "SmR:]G[Vn[D`;]\:\odB]?D]\R]mVb`;9baTf:fgK:U#XI3Ud:eVYAYm`T`:"
A$ = A$ + "EfK2PGLKUZk=Y\GLJeP?K_iVmSj<P0mR;[bJ^?Zc0B=j=S=E_h<_JZinHM6`"
A$ = A$ + "DMIVcPPjid0i\nTdYALYoI##]?E8WeWTeMAWm`Bll[D_o1QV=DUNAAdo`5_F"
A$ = A$ + "2iE#V]ITm^ZmILFSm\c]EEe\=2h5GFEUcf`\GLH5lmVDb[B\Z:[i4d;ZFEee"
A$ = A$ + "L9hUFch\8ZiV::XGRL]:i?_M>R:[F<7[8O^;D39OoPPGiVGUbi^#92WCc37L"
A$ = A$ + "^kOkhi_Zek9Y^g5j[3ihlE_?gmh[MQg\h8hGlI8`A8mO7D2[lN4KeHA`;4g?"
A$ = A$ + "0ePEQoNA:FioMfZF=Emg]\J;NOCTCm7jj#dFUCm7jj#TFUKmgFf::iD8gc2m"
A$ = A$ + "mSC^iD8gc2]EiVCQ\>4meFKYFYIM82[:]n3EM8B[XVCQZ>4ie\=GF]F__D3i"
A$ = A$ + "DkL^1WS0UHWC_j#DFQj<XFBF5lRk#JW#IeB=<[<[<[<[F:aHFiooMhNK=HeM"
A$ = A$ + "mCKQ525o1`aF%%h1"
btemp$ = ""
IF F$
<> "%" THEN C$
= C$
+ F$
B&
= B&
* 64 + ASC(MID$(B$
, t%
)) - 48 X$
= X$
+ CHR$(B&
AND 255): B&
= B& \
256
'==================================================================
A$ = ""
A$ = A$ + "haIkL^SC33455e5D#9UDb2Q2ZXVU3U\0H3#7kQ\1X6A5;2ZI7HbHY15iHLNo"
A$ = A$ + "O?7^IdEb:FAJdaWkX9fAIHHHL01aYlana;HLdh[mSi\Zmngon38cb^m3`:`:"
A$ = A$ + "`:`Z]#0[0[0[0[f:1\jlPE??njDbNNDMFmihgo>OJ7WmlYZ\ZiB]iae_=>Uf"
A$ = A$ + "aE`_Z8[j>eE?mmDZRKE=FMXCMiM?>UZhFESE7jDMFE5gZB\J9WZB^EUHeB>E"
A$ = A$ + "UL[Z`ZeLZi^EFlZ:\J=WZ:Ma:`Z>WFcYZ#G<KFAYkE5g:KFA]kE1g:CF9aYb"
A$ = A$ + "LMn<IU4W:c^HF\BSCUEG<;FYeYb`]bPEDM::L<Bg:3FAaYJWkRK^U4_Rb]RV"
A$ = A$ + "EDggIklDIED^ET\RCg[aYFX^fO4kQ8BFaikleI5Eg:R^HD\BRCae]l^;65[X"
A$ = A$ + "jD;aZZhFA`:>kkLNoS;[ld]RPEJM:>m#?GWgKFaiNCmG>5Ggb[^XW\RCgK=W"
A$ = A$ + "BRKiAGdCFaiklAQEIkFNa:^g7QCeoT`:[M;_HU7>5gNXe^U7\b;W:Kgb3FiU"
A$ = A$ + "CYe]db;[I5GWB2[hjFFe5]VEL_OWLkOBIU5MA;I5WmMZaYTd3]`]\REBOVXB"
A$ = A$ + "IE6^UE\RKgCSCIQK9QGF`:9>U5\BRKYY;J1[Tll[dfod`:YMA]\:CWBJ?DZK"
A$ = A$ + "YUEIjDAkFJHEkJ2g[]FjDFhF]??EgB3[JGCjcen_5mC5[MZ3i5ei`li2EgB:"
A$ = A$ + "[j>eiBXhFJkPW;9Refo?5`:`:`:`Z]B0[0[0[0[f:1\2\2\2\J[TUHEkok`M"
A$ = A$ + "HLdXmJ>[##\<oTS4%%h1"
btemp$ = ""
IF F$
<> "%" THEN C$
= C$
+ F$
B&
= B&
* 64 + ASC(MID$(B$
, t%
)) - 48 X$
= X$
+ CHR$(B&
AND 255): B&
= B& \
256
'==================================================================
A$ = ""
A$ = A$ + "haIkL7K3243554dE7adND7GGPX>^f0\CmA84\BSOJCnQC1haHlN8mWjeL?\;"
A$ = A$ + "kL^M[Fg_ml^fjH>Fa:FaZ2a:Fa:FE9Fa:FaZ:a:Fa:FE9Fa:FaZ:a:Fa:FE9"
A$ = A$ + "Fa:FaZ:a:Fa:FE9Fa:FaZ:a:Fa:FE9Fa:FaZ:a:Fa:FE9Fa:FaZ:a:Fa:FE9"
A$ = A$ + "Fa:FaZ:a:Fa:FE9Fa:FaZ:m=[FogQ7fU]NkF9m;k3HFP%%h1"
btemp$ = ""
IF F$
<> "%" THEN C$
= C$
+ F$
B&
= B&
* 64 + ASC(MID$(B$
, t%
)) - 48 X$
= X$
+ CHR$(B&
AND 255): B&
= B& \
256
'==================================================================
SUB PPRINT
(x
, y
, size
, clr&
, trans&
, text$
) x1 = x + (t * size): x2 = x1 + size
y1 = y: y2 = y + size
_PUTIMAGE (x1
- (size
/ 2), y1
)-(x2
, y2
+ (size
/ 3)), pprintimg&