03-07-2024, 04:33 AM
Hello All,
This is an older game that I posted om QB64 forum years ago
9tka is a 2 to 4 player board game which has 9 cells. Each cell has 9 spaces in it. The object of the game is to be the player who dominates the most cells. At the start of the game each player in turn places red blocker piece in each cell until each cell is filled with one red blocker in each cell. Blocker pieces can not be placed directly on the outer spaces inside the playing area. Next each player alternates placing one of their pieces on the outside border area until all spaces are filled, except for the corners. Next players takes turns sliding one of their pieces from outside the board, the border area, and slides it into the playing area until it is stopped by another piece or red blocker until all pieces are slid into the board that can be moved. The player who has the most of their pieces in a cell wins that cell. There may be a tie for cell which there is no winner of that cell. The player who wins the most number of cells is the winner.
This game uses keyboard inputs.
9 TKA Board Game Rules.pdf (Size: 131.44 KB / Downloads: 65)
This is an older game that I posted om QB64 forum years ago
9tka is a 2 to 4 player board game which has 9 cells. Each cell has 9 spaces in it. The object of the game is to be the player who dominates the most cells. At the start of the game each player in turn places red blocker piece in each cell until each cell is filled with one red blocker in each cell. Blocker pieces can not be placed directly on the outer spaces inside the playing area. Next each player alternates placing one of their pieces on the outside border area until all spaces are filled, except for the corners. Next players takes turns sliding one of their pieces from outside the board, the border area, and slides it into the playing area until it is stopped by another piece or red blocker until all pieces are slid into the board that can be moved. The player who has the most of their pieces in a cell wins that cell. There may be a tie for cell which there is no winner of that cell. The player who wins the most number of cells is the winner.
This game uses keyboard inputs.
Code: (Select All)
_TITLE "9 by Donald L. Foster Jr."
SCREEN _NEWIMAGE(1010, 735, 256)
_PALETTECOLOR 7, _RGB32(255, 215, 0) ' Yellow
_PALETTECOLOR 9, _RGB32(0, 80, 180) ' Blue
_PALETTECOLOR 14, _RGB32(255, 140, 0) ' Orange
_PALETTECOLOR 2, _RGB32(0, 180, 0) ' Green
_PALETTECOLOR 12, _RGB32(255, 0, 0) ' Red
_PALETTECOLOR 3, _RGB32(144, 238, 144)
_PALETTECOLOR 13, _RGB32(255, 192, 203)
DIM a1(36), b1(36), d1(36), e1(36), e2(36), e3(36), e4(36), l1(36), m1(36)
a = 1: c = 5: d = 5: e = 5: f = 5: endgame = 1: FullScreen = 0
c(1) = 7: c(2) = 9: c(3) = 2: c(4) = 14
LINE (0, 0)-(1009, 734), 15, BF
LINE (76, 76)-(658, 658), 0, BF
LINE (79, 79)-(654, 654), 15, BF
x = 0
FOR z = 1 TO 9
w = 0
FOR y = 1 TO 9
IF (z < 4) * (y < 4) THEN
cell(z, y) = 1: cellcolor(z, y) = 3
ELSEIF (z < 4) * (y > 6) THEN cell(z, y) = 3: cellcolor(z, y) = 3
ELSEIF z < 4 THEN cell(z, y) = 2: cellcolor(z, y) = 13
ELSEIF (z > 6) * (y < 4) THEN cell(z, y) = 7: cellcolor(z, y) = 3
ELSEIF (z > 6) * (y > 6) THEN cell(z, y) = 9: cellcolor(z, y) = 3
ELSEIF z > 6 THEN cell(z, y) = 8: cellcolor(z, y) = 13
ELSEIF y < 4 THEN cell(z, y) = 4: cellcolor(z, y) = 13
ELSEIF y > 6 THEN cell(z, y) = 6: cellcolor(z, y) = 13
ELSE cell(z, y) = 5: cellcolor(z, y) = 3
END IF
LINE (79 + w, 79 + x)-(143 + w, 143 + x), cellcolor(z, y), BF
a(z, y) = 111 + w: b(z, y) = 111 + x
w = w + 64
NEXT
a1(z) = 111 + x: b1(z) = 44: a1(9 + z) = 690: b1(9 + z) = 111 + x: a1(18 + z) = 623 - x: b1(18 + z) = 690: a1(27 + z) = 44: b1(27 + z) = 623 - x
x = x + 64
NEXT
x = 0
FOR z = 1 TO 10
LINE (79 + x, 14)-(79 + x, 719), 0
LINE (14, 79 + x)-(719, 79 + x), 0
x = x + 64
NEXT
LINE (734, 0)-(1010, 735), 0, BF
COLOR 15, 0
LOCATE 44, 95: PRINT "Number of players (2 to 4). [_]";
CURSOR1:
a$ = INKEY$: IF a$ = "" THEN GOTO CURSOR1
IF ASC(a$) = 27 AND FullScreen = 0 THEN FullScreen = -1: _FULLSCREEN _SQUAREPIXELS , _SMOOTH ELSE IF ASC(a$) = 27 THEN FullScreen = 0: _FULLSCREEN _OFF
IF (VAL(a$) > 1) * (VAL(a$) < 5) THEN b = VAL(a$): LOCATE 44, 124: PRINT a$;: GOTO CURSOR1
IF ASC(a$) = 8 THEN LOCATE 44, 124: PRINT "_";: GOTO CURSOR1
IF ASC(a$) <> 13 THEN GOTO CURSOR1
IF (b < 2) + (b > 4) THEN GOTO CURSOR1
LOCATE 44, 95: PRINT " ";
PLAYERINDICATOR:
CIRCLE (872, 107), 28, 8: PAINT (872, 107), c(a), 8
LOCATE 10, 106: PRINT "Player:"; a;
CIRCLE (872, 300), 28, 8: PAINT (872, 300), 12, 8
LOCATE 15, 103: PRINT "Place a marker";: LOCATE 16, 97: PRINT "in one of the empty cells.";
CURSOR2:
LINE (a(c, d) - 31, b(c, d) - 31)-(a(c, d) + 31, b(c, d) + 31), cellcolor(c, d), B
LINE (a(e, f) - 31, b(e, f) - 31)-(a(e, f) + 31, b(e, f) + 31), 0, B
GETINPUT1:
a$ = INKEY$
IF a$ = "" THEN GOTO GETINPUT1
IF ASC(a$) = 27 AND FullScreen = 0 THEN FullScreen = -1: _FULLSCREEN _SQUAREPIXELS , _SMOOTH ELSE IF ASC(a$) = 27 THEN FullScreen = 0: _FULLSCREEN _OFF
IF (a$ = CHR$(0) + CHR$(72)) * (e = 2) THEN c = e: d = f: e = 8: GOTO CURSOR2
IF a$ = CHR$(0) + CHR$(72) THEN c = e: d = f: e = e - 1: GOTO CURSOR2
IF (a$ = CHR$(0) + CHR$(77)) * (f = 8) THEN c = e: d = f: f = 2: GOTO CURSOR2
IF a$ = CHR$(0) + CHR$(77) THEN c = e: d = f: f = f + 1: GOTO CURSOR2
IF (a$ = CHR$(0) + CHR$(80)) * (e = 8) THEN c = e: d = f: e = 2: GOTO CURSOR2
IF a$ = CHR$(0) + CHR$(80) THEN c = e: d = f: e = e + 1: GOTO CURSOR2
IF (a$ = CHR$(0) + CHR$(75)) * (f = 2) THEN c = e: d = f: f = 8: GOTO CURSOR2
IF a$ = CHR$(0) + CHR$(75) THEN c = e: d = f: f = f - 1: GOTO CURSOR2
IF ASC(a$) <> 13 THEN GOTO GETINPUT1
IF (d(e, f) = 0) * (marker(cell(e, f)) = 0) THEN
d(e, f) = 5: counter = counter + 1: marker(cell(e, f)) = 1: CIRCLE (a(e, f), b(e, f)), 28, 8: PAINT (a(e, f), b(e, f)), 12, 8
ELSE GOTO GETINPUT1
END IF
IF a = b THEN a = 1 ELSE a = a + 1
IF counter < 9 THEN GOTO PLAYERINDICATOR
a = 1: c = e: d = f: g = 1: h = 1: counter = 0
LINE (a(c, d) - 31, b(c, d) - 31)-(a(c, d) + 31, b(c, d) + 31), cellcolor(c, d), B
PLAYERINDICATOR1:
CIRCLE (872, 107), 28, 0: PAINT (872, 107), c(a), 0
LOCATE 10, 106: PRINT "Player:"; a;
IF counter < 36 THEN
LOCATE 15, 99: PRINT " Place your piece ";: LOCATE 16, 96: PRINT "outside of the playing board.";
ELSE LOCATE 15, 99: PRINT " Choose a piece ";: LOCATE 16, 96: PRINT " to move onto the board. ";
END IF
LINE (842, 270)-(902, 330), 0, BF
IF counter < 36 THEN GOTO cursor3
endplayer = 1
FOR z = 1 TO 36: e1(z) = 0: NEXT
FOR z = 1 TO 36
IF d1(z) = 0 THEN GOTO ENDLOOP
IF z < 10 THEN i = 1: j = z: k = 0: GOTO DIR1
IF (z > 9) * (z < 19) THEN i = z - 9: j = 9: k = 0: GOTO DIR2
IF (z > 18) * (z < 28) THEN i = 9: j = 28 - z: k = 0: GOTO DIR3
IF z > 27 THEN i = 37 - z: j = 1: k = 0: GOTO DIR4
DIR1:
IF i + k < 10 THEN
IF d(i + k, j) = 0 THEN
IF (d1(z) = a) * (i + k = 9) THEN e1(z) = 1: l1(z) = 9: m1(z) = j: endplayer = 0: GOTO ENDLOOP
k = k + 1: GOTO DIR1
ELSE k = k - 1
END IF
END IF
IF k >= 0 THEN
endgame = 0
IF (d1(z) = a) + (i + k = 9) THEN
e1(z) = 1: l1(z) = i + k: m1(z) = z: endplayer = 0
END IF
END IF
GOTO ENDLOOP
DIR2:
IF j - k >= 0 THEN
IF d(i, j - k) = 0 THEN
IF (d1(z) = a) * (j - k = 1) THEN e1(z) = 1: l1(z) = i: m1(z) = 1: endplayer = 0: GOTO ENDLOOP
k = k + 1: GOTO DIR2
ELSE k = k - 1
END IF
END IF
IF k >= 0 THEN
endgame = 0
IF (d1(z) = a) + (j - k = 1) THEN
e1(z) = 1: l1(z) = i: m1(z) = j - k: endplayer = 0
END IF
END IF
GOTO ENDLOOP
DIR3:
IF i - k >= 0 THEN
IF d(i - k, j) = 0 THEN
IF (d1(z) = a) * (i - k = 1) THEN e1(z) = 1: l1(z) = 1: m1(z) = j: endplayer = 0: GOTO ENDLOOP
k = k + 1: GOTO DIR3
ELSE k = k - 1
END IF
END IF
IF k >= 0 THEN
endgame = 0
IF (d1(z) = a) + (i - k = 1) THEN
e1(z) = 1: l1(z) = i - k: m1(z) = j: endplayer = 0
END IF
END IF
GOTO ENDLOOP
DIR4:
IF j + k < 10 THEN
IF d(i, j + k) = 0 THEN
IF (d1(z) = a) * (j + k = 9) THEN e1(z) = 1: l1(z) = i: m1(z) = 9: endplayer = 0: GOTO ENDLOOP
k = k + 1: GOTO DIR4
ELSE k = k - 1
END IF
END IF
IF k >= 0 THEN
endgame = 0
IF (d1(z) = a) + (j + k = 9) THEN
e1(z) = 1: l1(z) = i: m1(z) = j + k: endplayer = 0
END IF
END IF
ENDLOOP:
NEXT
IF endgame = 1 THEN
LINE (734, 0)-(1010, 735), 0, BF
LOCATE 23, 104: PRINT "Cells Won by:";
v = 0: w = 0
FOR y = 1 TO b
CIRCLE (872, 48 + w), 28, 8: PAINT (872, 48 + w), c(y), 8
LOCATE 6 + v, 106: PRINT "Player:"; y;
v = v + 5: w = w + 80
NEXT
x = 0
FOR z = 1 TO 9
celltotal = 0
FOR y = 1 TO b
IF playercell(y, z) > celltotal THEN celltotal = playercell(y, z): cellwinner(z) = y ELSE IF playercell(y, z) = celltotal THEN cellwinner(z) = 0
NEXT
LOCATE 25 + x, 100: PRINT "Cell"; z; ": ";: IF cellwinner(z) = 0 THEN PRINT "No Winner"; ELSE PRINT "Player "; cellwinner(z);
x = x + 2
NEXT
FOR z = 1 TO b: playerwinner(z) = 0: NEXT
FOR z = 1 TO 9: playerwinner(cellwinner(z)) = playerwinner(cellwinner(z)) + 1: NEXT
cells = 0
FOR z = 1 TO b
IF playerwinner(z) > cells THEN cells = playerwinner(z): winner = z ELSE IF playerwinner(z) = cells THEN winner = 0
NEXT
LOCATE 43, 97: IF winner = 0 THEN PRINT "The game ended in a Draw!!!"; ELSE PRINT " Player"; winner; "is the winner!!! ";
LOCATE 45, 96: PRINT "Play Another Game? ( Y / N )";
ENDGAME:
a$ = UCASE$(INKEY$)
IF a$ = "" THEN GOTO ENDGAME
IF ASC(a$) = 27 AND FullScreen = 0 THEN FullScreen = -1: _FULLSCREEN _SQUAREPIXELS , _SMOOTH ELSE IF ASC(a$) = 27 THEN FullScreen = 0: _FULLSCREEN _OFF
IF a$ = "Y" THEN RUN
IF a$ = "N" THEN SYSTEM
GOTO ENDGAME
END IF
IF endplayer = 1 THEN
LOCATE 15, 99: PRINT "You have no more moves. ";
LOCATE 16, 96: PRINT " Press <ENTER> to continue. ";
PRESSENTER:
a$ = INKEY$: IF a$ = "" THEN GOTO PRESSENTER
IF ASC(a$) = 27 AND FullScreen = 0 THEN FullScreen = -1: _FULLSCREEN _SQUAREPIXELS , _SMOOTH ELSE IF ASC(a$) = 27 THEN FullScreen = 0: _FULLSCREEN _OFF
IF ASC(a$) <> 13 THEN GOTO PRESSENTER
GOTO ENDTURN
END IF
cursor3:
LINE (a1(g) - 30, b1(g) - 30)-(a1(g) + 30, b1(g) + 30), 15, B
LINE (a1(h) - 30, b1(h) - 30)-(a1(h) + 30, b1(h) + 30), 0, B
GETINPUT2:
a$ = INKEY$
IF a$ = "" THEN GOTO GETINPUT2
IF ASC(a$) = 27 AND FullScreen = 0 THEN FullScreen = -1: _FULLSCREEN _SQUAREPIXELS , _SMOOTH ELSE IF ASC(a$) = 27 THEN FullScreen = 0: _FULLSCREEN _OFF
IF (a$ = CHR$(0) + CHR$(77)) * (h = 36) THEN g = h: h = 1: GOTO cursor3
IF a$ = CHR$(0) + CHR$(77) THEN g = h: h = h + 1: GOTO cursor3
IF (a$ = CHR$(0) + CHR$(75)) * (h = 1) THEN g = h: h = 36: GOTO cursor3
IF a$ = CHR$(0) + CHR$(75) THEN g = h: h = h - 1: GOTO cursor3
IF ASC(a$) <> 13 THEN GOTO GETINPUT2
IF (d1(h) = 0) * (counter < 36) THEN
d1(h) = a
CIRCLE (a1(h), b1(h)), 28, 0: PAINT (a1(h), b1(h)), c(a), 0
counter = counter + 1
ELSEIF (d1(h) = a) * (e1(h) = 1) * (counter = 36) THEN
d1(h) = 0
e1(h) = 0
d(l1(h), m1(h)) = a
playercell(a, cell(l1(h), m1(h))) = playercell(a, cell(l1(h), m1(h))) + 1
LINE (a1(h) - 30, b1(h) - 30)-(a1(h) + 30, b1(h) + 30), 15, BF
CIRCLE (a(l1(h), m1(h)), b(l1(h), m1(h))), 28, 0
PAINT (a(l1(h), m1(h)), b(l1(h), m1(h))), c(a), 0
ELSE GOTO GETINPUT2
END IF
ENDTURN:
IF a = b THEN a = 1 ELSE a = a + 1
endgame = 1
GOTO PLAYERINDICATOR1
9 TKA Board Game Rules.pdf (Size: 131.44 KB / Downloads: 65)