Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Maryanne Board Game
#1
   

Quote:Hello All,

Maryann is a board game I designed and named it after my wife. I put together a board game that combine rules, features and characteristics of different board games.

The game is played on an 8x8 checkered board with 8 round discs lined up on each back row with arrows on top. The arrows point to the location where it can move to next. Each players turn consists of 2 moves. Moves consists on either one of the following: rotate player's piece, move a piece 1 space up,down, right, left, or diagonal, jump own pieces diagonal or capture opponent's piece up, down, left or right. A piece can be rotated on the same move, counts as 2 moves, Can move 1 piece twice or 2 pieces once. As pieces are removed from rows and columns the outer rows and columns are removed from the board. The winner is the player who captures their opponents first.

Donald

Code: (Select All)
Option _Explicit

' I used a code snippet by bplus modified to enlarge the characters on the screen.

_Title "Maryann - Designed and Programmed by Donald L. Foster Jr. 2018 - Code Snippet by bplus"

Screen _NewImage(1014, 735, 256)

_PaletteColor 1, _RGB32(6, 55, 255) ' Player 1 Piece Color
_PaletteColor 2, _RGB32(255, 61, 0) ' Player 2 Piece Color
_PaletteColor 3, _RGB32(127, 127, 127) ' Board Background Color
_PaletteColor 4, _RGB32(244, 244, 11) ' Arrow Color
_PaletteColor 5, _RGB32(80, 80, 80) ' Cursor Color

_Limit 10

Dim A As String
Dim V As _Unsigned Integer
Dim W As _Unsigned Integer
Dim X As _Unsigned Integer
Dim Y As _Unsigned _Byte
Dim Z As _Unsigned _Byte

Dim X1 As _Unsigned Integer
Dim X2 As _Unsigned Integer
Dim X3 As _Unsigned Integer
Dim X4 As _Unsigned Integer

Dim Player As _Unsigned _Byte
Dim Opponent As _Unsigned _Byte
Dim Winner As _Unsigned _Byte
Dim MovesLeft As _Unsigned _Byte
Dim CanSelect As _Unsigned _Byte
Dim Rotation As _Unsigned _Byte
Dim SquareColor1 As _Unsigned _Byte
Dim SquareColor2 As _Unsigned _Byte

Dim BoardX1 As _Unsigned Integer
Dim BoardY1 As _Unsigned Integer
Dim BoardX2 As _Unsigned Integer
Dim BoardY2 As _Unsigned Integer

Dim Rotate As _Unsigned _Byte

Dim TopBoardEdge As _Unsigned _Byte
Dim BottomBoardEdge As _Unsigned _Byte
Dim LeftBoardEdge As _Unsigned _Byte
Dim RightBoardEdge As _Unsigned _Byte

Dim Row1 As _Unsigned _Byte
Dim Column1 As _Unsigned _Byte
Dim Row2 As _Unsigned _Byte
Dim Column2 As _Unsigned _Byte

Dim PlayerColor(2) As Integer
Dim Pieces(2) As _Unsigned _Byte

Dim BoardX(8, 8) As _Unsigned Integer
Dim BoardY(8, 8) As _Unsigned Integer
Dim BoardPlayer(8, 8) As _Unsigned _Byte
Dim BoardRotate(8, 8) As _Unsigned _Byte
Dim Playable(8, 8) As _Unsigned _Byte
Dim RotationX(8) As _Unsigned Integer
Dim RotationY(8) As _Unsigned Integer

Dim Arrow As String
Dim Cursor As String
Dim Cursor1 As String
Dim TA$(8)
Dim Message As String

Player = 1: Opponent = 2
Pieces(1) = 8: Pieces(2) = 8
PlayerColor(1) = 1: PlayerColor(2) = 2

TopBoardEdge = 1: BottomBoardEdge = 8: LeftBoardEdge = 1: RightBoardEdge = 8

' Setup Pieces on Board
Data 6,8,6,8,6,8,5,1,5,1,4,2,4,2,4,2
For Z = 1 To 8: BoardPlayer(1, Z) = 2: BoardPlayer(8, Z) = 1: Read BoardRotate(1, Z), BoardRotate(8, Z): Next

Cursor$ = "TA0BU43BL43C5D86R86U86L86BF2D82R82U82L82BU1P5,5"
Cursor1$ = "TA0BU43BL43C0D86R86U86L86BF2D82R82U82L82BU1P0,0"
Arrow$ = "BD20BL10C4R20U20R10H20G20R10D20R10BU10P4,4"
TA$(1) = "TA0": TA$(2) = "TA45": TA$(3) = "TA90": TA$(4) = "TA135": TA$(5) = "TA180": TA$(6) = "TA225": TA$(7) = "TA270": TA$(8) = "TA315"

' Draw Game Title Message
Message$ = " Maryann ": X1 = 727: X2 = 2: X3 = 15: X4 = 4: GoSub DrawMessage
Line (0, 0)-(100, 30), 0, BF

' Draw Board
Line (10, 10)-(724, 724), 3, BF: ' LINE (12, 12)-(723, 723), 3, BF
X = 59
For Z = 1 To 8
W = 59
For Y = 1 To 8
If (Z + Y) / 2 = Fix((Z + Y) / 2) Then V = 0 Else V = 15
Line (W - 43, X - 43)-(W + 43, X + 43), V, BF
If BoardPlayer(Z, Y) > 0 Then X1 = W: X2 = X: X3 = PlayerColor(BoardPlayer(Z, Y)): X4 = BoardRotate(Z, Y): GoSub DrawPiece
BoardX(Z, Y) = W: BoardY(Z, Y) = X
W = W + 88
Next
X = X + 88
Next


StartGame:
MovesLeft = 2

' Draw Player Indicator
X1 = 863: X2 = 130: X3 = Player: X4 = 1: GoSub DrawPiece
Locate 12, 105: Print "Player"; Player;

MovesLeft: Locate 45, 104: Print "Moves Left:"; MovesLeft;

Locate 16, 100: Print " Choose a Piece. ";

ChooseAPieceInput:
Do While _MouseInput
For Z = 1 To 8
For Y = 1 To 8
If _MouseButton(1) = -1 And _MouseX > BoardX(Z, Y) - 44 And _MouseX < BoardX(Z, Y) + 44 And _MouseY > BoardY(Z, Y) - 44 And _MouseY < BoardY(Z, Y) + 44 Then
If BoardPlayer(Z, Y) = Player Then Row1 = Z: Column1 = Y: GoSub ReleaseMouseButton: GoTo EndChoice1
End If
Next
Next
Loop
GoTo ChooseAPieceInput

EndChoice1:
BoardX1 = BoardX(Row1, Column1): BoardY1 = BoardY(Row1, Column1): Rotate = BoardRotate(Row1, Column1)

' Get Color Row1 Column1 Square
If (Row1 + Column1) / 2 = Fix((Row1 + Column1) / 2) Then SquareColor1 = 0 Else SquareColor1 = 15

' Draw Cursor After Piece is Selected
PSet (BoardX(Row1, Column1), BoardY(Row1, Column1)), 4: Draw Cursor$

' Set All Playable Locations to 0
For Z = 1 To 8: For Y = 1 To 8: Playable(Z, Y) = 0: Next: Next

' Get Playable Locations
Playable(Row1, Column1) = 1

On Rotate GOSUB Check_Up, Check_Up_Left, Check_Left, Check_Down_Left, Check_Down, Check_Down_Right, Check_Right, Check_Up_Right

Locate 16, 100: Print "Choose a Location. ";

' Draw Piece Rotations
X = 0: V = 1
For Z = 1 To 7 Step 2
W = 0
For Y = 0 To 1
X1 = 810 + W: X2 = 315 + X: X3 = Player: X4 = V: GoSub DrawPiece
RotationX(Z + Y) = 810 + W: RotationY(Z + Y) = 315 + X
W = W + 110: V = V + 1
Next
X = X + 110
Next

Locate 16, 100: Print "Choose a Rotation. ";

GetRotationMouseInput:
Do While _MouseInput
For Z = 1 To 8
If _MouseX > RotationX(Z) - 44 And _MouseX < RotationX(Z) + 44 And _MouseY > RotationY(Z) - 44 And _MouseY < RotationY(Z) + 44 Then
CanSelect = 1: PSet (RotationX(Z), RotationY(Z)), 4: Draw Cursor$
Else
CanSelect = 0: PSet (RotationX(Z), RotationY(Z)), 4: Draw Cursor1$
End If
If _MouseButton(1) = -1 And CanSelect = 1 Then Rotation = Z: GoSub ReleaseMouseButton: GoTo EndChoice2
Next
Loop
GoTo GetRotationMouseInput

EndChoice2:
If Rotation <> Rotate Then MovesLeft = MovesLeft - 1: Locate 45, 104: Print "Moves Left:"; MovesLeft; 'ELSE Rotation = Rotate

If MovesLeft = 0 Then
' Remove Piece Rotations
Line (766, 271)-(964, 689), 0, BF

' Set Current Piece To New Rotation Position
BoardRotate(Row1, Column1) = Rotation

' Remove Cursor and Piece From Current Location
Line (BoardX1 - 43, BoardY1 - 43)-(BoardX1 + 43, BoardY1 + 43), SquareColor1, BF

' Redraw Piece in Current Position With New Rotation
X1 = BoardX1: X2 = BoardY1: X3 = Player: X4 = Rotation: GoSub DrawPiece: GoTo EndTurn
End If

ChooseALocationInput:
Do While _MouseInput
For Z = 1 To 8
For Y = 1 To 8
If _MouseButton(1) = -1 And _MouseX > BoardX(Z, Y) - 44 And _MouseX < BoardX(Z, Y) + 44 And _MouseY > BoardY(Z, Y) - 44 And _MouseY < BoardY(Z, Y) + 44 Then
If Playable(Z, Y) = 1 Then Row2 = Z: Column2 = Y: GoSub ReleaseMouseButton: GoTo EndChoice3
End If
Next
Next
Loop
GoTo ChooseALocationInput

EndChoice3:

' Get New Location Information
BoardX2 = BoardX(Row2, Column2): BoardY2 = BoardY(Row2, Column2)
If (Row2 + Column2) / 2 = Fix((Row2 + Column2) / 2) Then SquareColor2 = 0 Else SquareColor2 = 15

' Piece stayed at Same Location
If Row2 = Row1 And Column2 = Column1 Then
Line (BoardX1 - 43, BoardY1 - 43)-(BoardX1 + 43, BoardY1 + 43), SquareColor1, BF
BoardRotate(Row2, Column2) = Rotation: X1 = BoardX2: X2 = BoardY2: X3 = Player: X4 = Rotation: GoSub DrawPiece
Line (766, 271)-(964, 689), 0, BF: GoTo MovesLeft
End If

' Remove Piece Rotations
Line (766, 271)-(964, 689), 0, BF

' Check If Opponent's Piece is Captured
If BoardPlayer(Row2, Column2) = Opponent Then Pieces(Opponent) = Pieces(Opponent) - 1

' Assign New Location to Player
BoardPlayer(Row2, Column2) = Player: BoardRotate(Row2, Column2) = Rotation

' Set Old Location to 0
BoardPlayer(Row1, Column1) = 0: BoardRotate(Row1, Column1) = 0

' Clear Piece and Cursors From Old Location
Line (BoardX1 - 43, BoardY1 - 43)-(BoardX1 + 43, BoardY1 + 43), SquareColor1, BF

' Clear New Location
Line (BoardX2 - 43, BoardY2 - 43)-(BoardX2 + 43, BoardY2 + 43), SquareColor2, BF

' Redraw Piece at New Location
X1 = BoardX2: X2 = BoardY2: X3 = Player: X4 = Rotation: GoSub DrawPiece

' Substract 1 from MovesLeft
MovesLeft = MovesLeft - 1: Locate 45, 104: Print "Moves Left:"; MovesLeft;

' Check if a Row or Column is Empty
X1 = 0: X2 = 0: X3 = 0: X4 = 0

For Z = 1 To 8
If BoardPlayer(TopBoardEdge, Z) > 0 Then X1 = 1
If BoardPlayer(BottomBoardEdge, Z) > 0 Then X2 = 1
If BoardPlayer(Z, LeftBoardEdge) > 0 Then X3 = 1
If BoardPlayer(Z, RightBoardEdge) > 0 Then X4 = 1
Next

If X1 = 0 Then Y = TopBoardEdge: For Z = 1 To 8: Line (BoardX(Y, Z) - 43, BoardY(Y, Z) - 43)-(BoardX(Y, Z) + 43, BoardY(Y, Z) + 43), 3, BF: Next: TopBoardEdge = TopBoardEdge + 1
If X2 = 0 Then Y = BottomBoardEdge: For Z = 1 To 8: Line (BoardX(Y, Z) - 43, BoardY(Y, Z) - 43)-(BoardX(Y, Z) + 43, BoardY(Y, Z) + 43), 3, BF: Next: BottomBoardEdge = BottomBoardEdge - 1
If X3 = 0 Then Y = LeftBoardEdge: For Z = 1 To 8: Line (BoardX(Z, Y) - 43, BoardY(Z, Y) - 43)-(BoardX(Z, Y) + 43, BoardY(Z, Y) + 43), 3, BF: Next: LeftBoardEdge = LeftBoardEdge + 1
If X4 = 0 Then Y = RightBoardEdge: For Z = 1 To 8: Line (BoardX(Z, Y) - 43, BoardY(Z, Y) - 43)-(BoardX(Z, Y) + 43, BoardY(Z, Y) + 43), 3, BF: Next: RightBoardEdge = RightBoardEdge - 1

' Check for Winner
If Pieces(Opponent) = 0 Then GoTo Winner

' Check if Still Have More Moves
If MovesLeft > 0 Then GoTo MovesLeft

EndTurn:
Swap Player, Opponent: GoTo StartGame


DrawPiece:
Circle (X1, X2), 36, X3: Paint (X1, X2), X3
PSet (X1, X2), X3: Draw TA$(X4) + Arrow$
Return


DrawMessage:
Color 15, V: Locate 1, 1: Print Message$;
W = 8 * Len(Message$): X = 16

For Y = 0 To X
For Z = 0 To W
If Point(Z, Y) <> 0 Then Line (X1 + Z * X4, X2 + Y * X4)-(X1 + Z * X4 + X4, X2 + Y * X4 + X4), 15, BF
Next
Next
Return


ReleaseMouseButton:
Do While _MouseInput
If _MouseButton(1) = 0 Then Return
Loop
GoTo ReleaseMouseButton


Check_Up:
If Row1 - 1 >= TopBoardEdge Then If BoardPlayer(Row1 - 1, Column1) <> Player Then Playable(Row1 - 1, Column1) = 1
Return

Check_Up_Left:
If Row1 - 1 >= TopBoardEdge And Column1 - 1 >= LeftBoardEdge Then
If BoardPlayer(Row1 - 1, Column1 - 1) = 0 Then Playable(Row1 - 1, Column1 - 1) = 1
If BoardPlayer(Row1 - 1, Column1 - 1) = Player Then
If Row1 - 2 >= TopBoardEdge And Column1 - 2 >= LeftBoardEdge Then If BoardPlayer(Row1 - 2, Column1 - 2) = 0 Then Playable(Row1 - 2, Column1 - 2) = 1
End If
End If
Return

Check_Left:
If Column1 - 1 >= LeftBoardEdge Then If BoardPlayer(Row1, Column1 - 1) <> Player Then Playable(Row1, Column1 - 1) = 1
Return

Check_Down_Left:
If Row1 + 1 <= BottomBoardEdge And Column1 - 1 >= LeftBoardEdge Then
If BoardPlayer(Row1 + 1, Column1 - 1) = 0 Then Playable(Row1 + 1, Column1 - 1) = 1
If BoardPlayer(Row1 + 1, Column1 - 1) = Player Then
If Row1 + 2 <= BottomBoardEdge And Column1 - 2 >= LeftBoardEdge Then If BoardPlayer(Row1 + 2, Column1 - 2) = 0 Then Playable(Row1 + 2, Column1 - 2) = 1
End If
End If
Return

Check_Down:
If Row1 + 1 <= BottomBoardEdge Then If BoardPlayer(Row1 + 1, Column1) <> Player Then Playable(Row1 + 1, Column1) = 1
Return

Check_Down_Right:
If Row1 + 1 <= BottomBoardEdge And Column1 + 1 <= RightBoardEdge Then
If BoardPlayer(Row1 + 1, Column1 + 1) = 0 Then Playable(Row1 + 1, Column1 + 1) = 1
If BoardPlayer(Row1 + 1, Column1 + 1) = Player Then
If Row1 + 2 <= BottomBoardEdge And Column1 + 2 <= RightBoardEdge Then If BoardPlayer(Row1 + 2, Column1 + 2) = 0 Then Playable(Row1 + 2, Column1 + 2) = 1
End If
End If
Return

Check_Right:
If Column1 + 1 <= RightBoardEdge Then If BoardPlayer(Row1, Column1 + 1) <> Player Then Playable(Row1, Column1 + 1) = 1
Return

Check_Up_Right:
If Row1 - 1 >= TopBoardEdge And Column1 + 1 <= RightBoardEdge Then
If BoardPlayer(Row1 - 1, Column1 + 1) = 0 Then Playable(Row1 - 1, Column1 + 1) = 1
If BoardPlayer(Row1 - 1, Column1 + 1) = Player Then
If Row1 - 2 >= TopBoardEdge And Column1 + 2 <= RightBoardEdge Then If BoardPlayer(Row1 - 2, Column1 + 2) = 0 Then Playable(Row1 - 2, Column1 + 2) = 1
End If
End If
Return


Winner:
Locate 16, 96: Print " Player"; Player; "is the Winner!! ";

Locate 18, 96: Print "Play Another Game? ( Y / N )";

Locate 45, 104: Print " ";

GetYorN:
A$ = UCase$(InKey$)
If A$ = "" Then GoTo GetYorN
If A$ = "Y" Then Run
If A$ = "N" Then System
GoTo GetYorN
Reply


Messages In This Thread
Maryanne Board Game - by SMcNeill - 12-23-2023, 09:35 PM



Users browsing this thread: 1 Guest(s)