Welcome, Guest |
You have to register before you can post on our site.
|
Forum Statistics |
» Members: 485
» Latest member: zenevan
» Forum threads: 2,804
» Forum posts: 26,470
Full Statistics
|
|
|
Flappy Bird Clone by Terry Ritchie |
Posted by: SMcNeill - 12-24-2023, 04:20 AM - Forum: Games
- No Replies
|
|
Quote:Here's an oldie, my QB64 version of FlappyBird. I used this program as an introduction to game programming in the course I used to teach.
Code: (Select All)
' -----------------------------------------------
' QB64 FlappyBird Clone by Terry Ritchie 02/28/14
'
' This program was created to accompany the QB64
' Game Programming course located at:
' http://www.qb64sourcecode.com
'
' You may not sell or distribute this game! It
' was made for instructional purposes only.
'
' Update: 04/29/20
'
' Added EXE icon support in lines 18 and 19
' Any key press now starts game in line 274
' Any key press now flaps bird in line 196
'
' -----------------------------------------------
$EXEICON:'.\fbird.ico'
_ICON
'--------------------------------
'- Variable declaration section -
'--------------------------------
CONST FALSE = 0 ' boolean: truth 0
CONST TRUE = NOT FALSE ' boolean: truth -1
CONST LARGE = 0 ' large numbers
CONST SMALL = 1 ' small numbers (not used in current version of game)
CONST GOLD = 0 ' gold medal
CONST SILVER = 1 ' silver medal
CONST LIGHT = 0 ' light colored gold/silver medal
CONST DARK = 1 ' dark colored gold/silver medal
TYPE PARALLAX ' parallax scenery settings
image AS LONG ' scene image
x AS INTEGER ' scene image x location
y AS INTEGER ' scene image y location
frame AS INTEGER ' current parallax frame
fmax AS INTEGER ' maximum parallax frames allowed
END TYPE
TYPE INFLIGHT ' flappy bird inflight characterisitcs
y AS SINGLE ' flappy bird y location
yvel AS SINGLE ' flappy bird y velocity
flap AS INTEGER ' wing flap position
flapframe AS INTEGER ' wing flap frame counter
angle AS INTEGER ' angle of flappy bird
END TYPE
TYPE PIPE ' pipe characteristics
x AS INTEGER ' pipe x location
y AS INTEGER ' pipe y location
END TYPE
DIM Pipes(3) AS PIPE ' define 3 moving sets of pipes
DIM Pipe&(1) ' pipe images 0=top 1=bottom
DIM PipeImage& ' all three pipes drawn image
DIM Birdie AS INFLIGHT ' bird flight characteristics
DIM Scenery(4) AS PARALLAX ' define 4 moving scenes in parallax
DIM Fbird&(8, 3) ' flapping bird images
DIM Num&(9, 1) ' big and small numeral images
DIM Plaque& ' medal/score plaque
DIM FlappyBird& ' Flappy Bird title image
DIM GameOver& ' Game Over image
DIM GetReady& ' Get Ready image
DIM Medal&(1, 1) ' gold/silver medal images
DIM Finger& ' tap finger image
DIM ScoreButton& ' score button image
DIM ShareButton& ' share button image
DIM StartButton& ' start button image
DIM OKButton& ' OK button image
DIM RateButton& ' RATE button image
DIM MenuButton& ' MENU button image
DIM PlayButton& ' PLAY [|>] button image
DIM PauseButton& ' PAUSE [||] button image
DIM HazardBar& ' Hazard bar parallax image
DIM Clouds& ' Clouds parallax image
DIM City& ' Cityscape parallax image
DIM Bushes& ' Bushes parallax image
DIM New& ' red NEW image
DIM Clean& ' clean playing screen image
DIM HitBird% ' boolean: TRUE if bird hits something
DIM HighScore% ' high score
DIM Score% ' current score
DIM Paused% ' boolean: TRUE if game paused
DIM Ding& ' ding sound
DIM Flap& ' flapping sound
DIM Smack& ' bird smack sound
DIM Latch% ' boolean: TRUE if mouse button held down
DIM WinX% ' stops player from exiting program at will
'------------------------
'- Main Program Section -
'------------------------
SCREEN _NEWIMAGE(432, 768, 32) ' create 432x768 game screen
_TITLE "FlappyBird" ' give window a title
CLS ' clear the screen
_DELAY .5 ' slight delay before moving screen to middle
_SCREENMOVE _MIDDLE ' move window to center of desktop
WinX% = _EXIT ' program will handle all window close requests
LOADASSETS ' set/load game graphics/sounds/settings
Birdie.flap = 1 ' set initial wing position of bird
DO ' BEGIN MAIN GAME LOOP
_LIMIT 60 ' 60 frames per second
UPDATESCENERY ' update parallaxing scenery
_PUTIMAGE (40, 265), FlappyBird& ' place game title on screen
_PUTIMAGE (350, 265), Fbird&(2, FLAPTHEBIRD%) ' place flapping bird on screen
IF BUTTON%(64, 535, StartButton&) THEN PLAYGAME ' if start button pressed play game
IF BUTTON%(248, 535, ScoreButton&) THEN SHOWSCORE ' if score button pressed show scores
IF BUTTON%(248, 480, RateButton&) THEN RATEGAME ' if rate button pressed bring up browser
_DISPLAY ' update screen with changes
LOOP UNTIL _KEYDOWN(27) OR _EXIT ' END MAIN GAME LOOP when ESC pressed or window closed
CLEANUP ' clean the computer's RAM before leaving
SYSTEM ' return to Windows desktop
'-------------------------------------
'- Subroutines and Functions section -
'-------------------------------------
'----------------------------------------------------------------------------------------------------------------------
FUNCTION FLAPTHEBIRD% ()
'*
'* Returns the next index value used in Fbird&() to animate the bird's
'* flapping wings.
'*
SHARED Birdie AS INFLIGHT
Birdie.flapframe = Birdie.flapframe + 1 ' increment frame counter
IF Birdie.flapframe = 4 THEN ' hit limit?
Birdie.flapframe = 0 ' yes, reset frame counter
Birdie.flap = Birdie.flap + 1 ' increment flap counter
IF Birdie.flap = 4 THEN Birdie.flap = 1 ' reset flap counter when limit hit
END IF
FLAPTHEBIRD% = Birdie.flap ' return next index value
END SUB
'----------------------------------------------------------------------------------------------------------------------
SUB MOVEPIPES ()
'*
'* Creates and moves the pipe images across the screen.
'*
SHARED Pipes() AS PIPE, Pipe&(), PipeImage&, Paused%, Score%, Ding&
DIM p% ' counter indicating which pipe being worked on
_DEST PipeImage& ' work on this image
CLS , _RGBA32(0, 0, 0, 0) ' clear image with transparent black
_DEST 0 ' back to work on screen
DO ' BEGIN PIPE LOOP
p% = p% + 1 ' increment pipe counter
IF NOT Paused% THEN ' is game paused?
Pipes(p%).x = Pipes(p%).x - 3 ' no, move pipe to the left
IF Pipes(p%).x < -250 THEN ' hit lower limit?
Pipes(p%).x = 500 ' yes, move pipe all the way right
Pipes(p%).y = -(INT(RND(1) * 384) + 12) ' generate random pipe height position
END IF
IF Pipes(p%).x = 101 THEN ' is pipe crossing bird location?
_SNDPLAY Ding& ' play ding sound
Score% = Score% + 1 ' increment player score
END IF
END IF
IF Pipes(p%).x > -78 AND Pipes(p%).x < 432 THEN ' is pipe currently seen on screen?
_PUTIMAGE (Pipes(p%).x, Pipes(p%).y), Pipe&(0), PipeImage& ' place top pipe
_PUTIMAGE (Pipes(p%).x, Pipes(p%).y + 576), Pipe&(1), PipeImage& ' place bottom pipe
END IF
LOOP UNTIL p% = 3 ' END PIPE LOOP when all pipes moved
_PUTIMAGE (0, 0), PipeImage& ' place pipe image on screen
END SUB
'----------------------------------------------------------------------------------------------------------------------
SUB FLYBIRDIE ()
'*
'* Controls the flight of bird on screen.
'*
SHARED Birdie AS INFLIGHT, Fbird&(), Paused%, Flap&, HitBird%, Latch%, Smack&
DIM b% ' boolean: TRUE if left mouse button pressed
DIM Angle% ' angle of bird in flight
IF NOT Paused% THEN ' is game paused?
WHILE _MOUSEINPUT: WEND ' no, get latest mouse information
b% = _MOUSEBUTTON(1) ' get left mouse button status
IF _KEYHIT > 0 THEN b% = -1 ' any key will also make bird flap (added 04/29/20)
IF NOT b% THEN Latch% = FALSE ' release latch if button let go
IF NOT HitBird% THEN ' has bird hit something?
IF NOT Latch% THEN ' no, has left button been release?
IF b% THEN ' yes, was left button pressed?
Birdie.yvel = -8 ' yes, reset bird y velocity
_SNDPLAY Flap& ' play flap sound
Latch% = TRUE ' remember mouse button pressed
END IF
END IF
END IF
Birdie.yvel = Birdie.yvel + .5 ' bleed off some bird y velocity
Birdie.y = Birdie.y + Birdie.yvel ' add velocity to bird's y direction
IF NOT HitBird% THEN ' has bird hit something?
IF Birdie.y < -6 OR Birdie.y > 549 THEN ' no, has bird hit top/bottom of screen?
HitBird% = TRUE ' yes, remeber bird hit something
_SNDPLAY Smack& ' play smack sound
END IF
END IF
IF Birdie.yvel < 0 THEN ' is bird heading upward?
Birdie.angle = 1 ' yes, set angle of bird accordingly
ELSE
Angle% = INT(Birdie.yvel * .5) + 1 ' calculate angle according to bird velocity
IF Angle% > 8 THEN Angle% = 8 ' keep angle within limits
Birdie.angle = Angle% ' set bird angle
END IF
END IF
_PUTIMAGE (100, Birdie.y), Fbird&(Birdie.angle, FLAPTHEBIRD%) ' place bird on screen
END SUB
'----------------------------------------------------------------------------------------------------------------------
SUB UPDATESCORE ()
'*
'* Displays player's score on screen.
'*
SHARED Num&(), Score%
DIM s$ ' score in string format
DIM w% ' width of score string
DIM x% ' x location of score digits
DIM p% ' position counter
s$ = LTRIM$(RTRIM$(STR$(Score%))) ' convert score to string
w% = LEN(s$) * 23 ' calculate width of score
x% = (432 - w%) \ 2 ' calculate x position of score
FOR p% = 1 TO LEN(s$) ' cycle through each position in score string
_PUTIMAGE (x%, 100), Num&(ASC(MID$(s$, p%, 1)) - 48, LARGE) ' place score digit on screen
x% = x% + 23 ' move to next digit position
NEXT p%
END SUB
'----------------------------------------------------------------------------------------------------------------------
SUB READY ()
'*
'* displays instructions to the player and waits for player to start game.
'*
SHARED Fbird&(), Finger&, GetReady&
DIM b% ' boolean: TRUE if left mouse button pressed
DO ' BEGIN READY LOOP
_LIMIT 60 ' 60 frames per second
UPDATESCENERY ' move parallax scenery
_PUTIMAGE (180, 350), Finger& ' place finger instructions on screen
_PUTIMAGE (85, 225), GetReady& ' place get ready image on screen
_PUTIMAGE (100, 375), Fbird&(2, FLAPTHEBIRD%) ' place bird on screen
UPDATESCORE ' place score on screen
_DISPLAY ' update screen with changes
WHILE _MOUSEINPUT: WEND ' get latest mouse information
b% = _MOUSEBUTTON(1) ' get status of left mouse button
IF _KEYHIT > 0 THEN b% = -1 ' any key press will also begin game (added 04/29/20)
IF _EXIT THEN CLEANUP: SYSTEM ' leave game if user closes game window
LOOP UNTIL b% ' END READY LOOP when left button pressed
_DELAY .2 ' slight delay to allow mouse button release
END SUB
'----------------------------------------------------------------------------------------------------------------------
SUB PLAYGAME ()
'*
'* Allows player to play the game.
'*
SHARED Pipes() AS PIPE, Birdie AS INFLIGHT, PauseButton&, PlayButton&, Paused%, HitBird%, Score%
RANDOMIZE TIMER ' seed random number generator
Score% = 0 ' reset player score
Birdie.y = 0 ' reset bird y location
Birdie.yvel = 0 ' reset bird y velocity
Birdie.flap = 1 ' reset bird wing flap index
Pipes(1).x = 500 ' reset position of first pipe
Pipes(2).x = 749 ' reset position of second pipe
Pipes(3).x = 998 ' reset position of third pipe
Pipes(1).y = -(INT(RND(1) * 384) + 12) ' calculate random y position of pipe 1
Pipes(2).y = -(INT(RND(1) * 384) + 12) ' calculate random y position of pipe 2
Pipes(3).y = -(INT(RND(1) * 384) + 12) ' calculate random y position of pipe 3
READY ' display instructions to player
DO ' BEGIN GAME PLAY LOOP
_LIMIT 60 ' 60 frames per second
UPDATESCENERY ' move parallax scenery
MOVEPIPES ' move pipes
UPDATESCORE ' display player score
FLYBIRDIE ' move and display bird
CHECKFORHIT ' check for bird hits
IF NOT Paused% THEN ' is game paused?
IF BUTTON%(30, 100, PauseButton&) THEN ' no, was pause button pressed?
Paused% = TRUE ' yes, place game in pause state
END IF
ELSE ' no, game is not paused
IF BUTTON%(30, 100, PlayButton&) THEN ' was play button pressed?
Paused% = FALSE ' yes, take game out of pause state
END IF
END IF
_DISPLAY ' update screen with changes
IF _EXIT THEN CLEANUP: SYSTEM ' leave game if user closes game window
LOOP UNTIL HitBird% ' END GAME PLAY LOOP if bird hits something
DO ' BEGIN BIRD DROPPING LOOP
_LIMIT 60 ' 60 frames per second
Paused% = TRUE ' place game in paused state
UPDATESCENERY ' draw parallax scenery
MOVEPIPES ' draw pipes
Paused% = FALSE ' take game out of pause state
FLYBIRDIE ' move bird on screen
_DISPLAY ' update screen with changes
IF _EXIT THEN CLEANUP: SYSTEM ' leave game if user closes game window
LOOP UNTIL Birdie.y >= 546 ' END BIRD DROPPING LOOP when bird hits ground
SHOWSCORE ' display player's score plaque
HitBird% = FALSE ' reset bird hit indicator
END SUB
'----------------------------------------------------------------------------------------------------------------------
SUB CHECKFORHIT ()
'*
'* Detects if bird hits a pipe.
'*
SHARED Pipes() AS PIPE, Birdie AS INFLIGHT, HitBird%, Smack&
DIM p% ' pipe counter
FOR p% = 1 TO 3 ' cycle through all pipe positions
IF Pipes(p%).x <= 153 AND Pipes(p%).x >= 22 THEN ' is pipe in bird territory?
IF BOXCOLLISION(105, Birdie.y + 6, 43, 41, Pipes(p%).x, Pipes(p%).y, 78, 432) THEN ' collision?
HitBird% = TRUE ' yes, remember bird hit pipe
END IF
IF BOXCOLLISION(105, Birdie.y + 6, 43, 41, Pipes(p%).x, Pipes(p%).y + 576, 78, 432) THEN ' collision?
HitBird% = TRUE ' yes, remember bird hit pipe
END IF
END IF
NEXT p%
IF HitBird% THEN _SNDPLAY Smack& ' play smack sound if bird hit pipe
END SUB
'----------------------------------------------------------------------------------------------------------------------
SUB RATEGAME ()
'*
'* Allows player to rate game.
'*
SHELL "https://www.qb64.org/forum/index.php?topic=437.0" ' go to QB64 web site forum area for flappy bird
END SUB
'----------------------------------------------------------------------------------------------------------------------
SUB SHOWSCORE ()
'*
'* Display's current and high scores on score plaque
'*
SHARED Fbird&(), Num&(), Medal&(), FlappyBird&, GameOver&, Plaque&, OKButton&, ShareButton&
SHARED HitBird%, HighScore%, Score%, New&
DIM Ok% ' boolean: TRUE if OK button pressed
DIM Scores%(1) ' current and high scores
DIM sc% ' current score being drawn
DIM x% ' x location of score digits
DIM p% ' digit position counter
DIM ShowNew% ' boolean: TRUE if score is a new high score
DIM s$ ' score in string format
IF Score% > HighScore% THEN ' is this a new high score?
OPEN "fbird.sco" FOR OUTPUT AS #1 ' yes, open score file
PRINT #1, Score% ' save new high score
CLOSE #1 ' close score file
HighScore% = Score% ' remember new high score
ShowNew% = TRUE ' remember this is a new high score
END IF
Scores%(0) = Score% ' place score in array
Scores%(1) = HighScore% ' place high score in array
Ok% = FALSE ' reset OK button status indicator
DO ' BEGIN SCORE LOOP
_LIMIT 60 ' 60 frames per second
IF HitBird% THEN ' did bird hit something?
_PUTIMAGE (75, 200), GameOver& ' yes, place game over image on screen
ELSE ' no, bird did not hit anything
UPDATESCENERY ' move parallax scenery
_PUTIMAGE (40, 200), FlappyBird& ' place flappy bird title on screen
_PUTIMAGE (350, 200), Fbird&(2, FLAPTHEBIRD%) ' place flapping bird on screen
END IF
_PUTIMAGE (46, 295), Plaque& ' place plaque on screen
SELECT CASE HighScore% ' what is range of high score?
CASE 25 TO 49 ' from 25 to 49
_PUTIMAGE (85, 360), Medal&(SILVER, LIGHT) ' display a light silver medal
CASE 50 TO 99 ' from 50 to 99
_PUTIMAGE (85, 360), Medal&(SILVER, DARK) ' display a dark silver medal
CASE 100 TO 199 ' from 100 to 199
_PUTIMAGE (85, 360), Medal&(GOLD, LIGHT) ' display a light gold medal
CASE IS > 199 ' from 200 and beyond
_PUTIMAGE (85, 360), Medal&(GOLD, DARK) ' display a dark gold medal
END SELECT
FOR sc% = 0 TO 1 ' cycle through both scores
s$ = LTRIM$(RTRIM$(STR$(Scores%(sc%)))) ' convert score to string
x% = 354 - LEN(s$) * 23 ' calculate position of score digit
FOR p% = 1 TO LEN(s$) ' cycle through score string
_PUTIMAGE (x%, 346 + sc% * 64), Num&(ASC(MID$(s$, p%, 1)) - 48, LARGE) ' place digit on plaque
x% = x% + 23 ' increment digit position
NEXT p%
NEXT sc%
IF ShowNew% THEN _PUTIMAGE (250, 382), New& ' display red new image if new high score
IF BUTTON%(64, 535, OKButton&) THEN Ok% = TRUE ' remember if OK button was pressed
IF BUTTON%(248, 535, ShareButton&) THEN ' was share button pressed?
SHAREPROGRAM ' yes, share program with others
UPDATESCENERY ' draw parallax scenery
MOVEPIPES ' draw pipes
END IF
_DISPLAY ' update screen with changes
IF _EXIT THEN CLEANUP: SYSTEM ' leave game if user closes game window
LOOP UNTIL Ok% ' END SCORE LOOP when OK button pressed
END SUB
'----------------------------------------------------------------------------------------------------------------------
SUB SHAREPROGRAM ()
'*
'* Allows player to share program with others
'*
SHARED Fbird&(), FlappyBird&, OKButton&
DIM Message& ' composed message to player's friend(s)
DIM Ok% ' boolean: TRUE if OK button pressed
Message& = _NEWIMAGE(339, 174, 32) ' create image to hold message to player
_CLIPBOARD$ = "I just discovered a great game! You can download it here: http:\\www.qb64sourcecode.com\fbird.exe"
_PRINTMODE _KEEPBACKGROUND ' printed text will save background
LINE (58, 307)-(372, 453), _RGB32(219, 218, 150), BF ' clear plaque image
COLOR _RGB32(210, 170, 79) ' compose message to player on plaque
_PRINTSTRING (66, 316), "The following message has been copied"
COLOR _RGB32(82, 55, 71)
_PRINTSTRING (65, 315), "The following message has been copied"
COLOR _RGB32(210, 170, 79)
_PRINTSTRING (66, 331), "to your computer's clipboard:"
COLOR _RGB32(82, 55, 71)
_PRINTSTRING (65, 330), "to your computer's clipboard:"
COLOR _RGB32(210, 170, 79)
_PRINTSTRING (66, 351), "'I just discovered a great game! You"
COLOR _RGB32(82, 55, 71)
_PRINTSTRING (65, 350), "'I just discovered a great game! You"
COLOR _RGB32(210, 170, 79)
_PRINTSTRING (66, 366), "can download it here:"
COLOR _RGB32(82, 55, 71)
_PRINTSTRING (65, 365), "can download it here:"
COLOR _RGB32(210, 170, 79)
_PRINTSTRING (66, 381), "www.qb64sourcecode.com\fbird.exe'"
COLOR _RGB32(82, 55, 71)
_PRINTSTRING (65, 380), "www.qb64sourcecode.com\fbird.exe'"
COLOR _RGB32(210, 170, 79)
_PRINTSTRING (66, 401), "Create an email for your friends and"
COLOR _RGB32(82, 55, 71)
_PRINTSTRING (65, 400), "Create an email for your friends and"
COLOR _RGB32(210, 170, 79)
_PRINTSTRING (66, 416), "paste this message into it! Go ahead,"
COLOR _RGB32(82, 55, 71)
_PRINTSTRING (65, 415), "paste this message into it! Go ahead,"
COLOR _RGB32(210, 170, 79)
_PRINTSTRING (66, 431), "do it now before you change your mind!"
COLOR _RGB32(82, 55, 71)
_PRINTSTRING (65, 430), "do it now before you change your mind!"
_PUTIMAGE , _DEST, Message&, (46, 295)-(384, 468) ' place message in image
DO ' BEGIN SHARE LOOP
_LIMIT 60 ' 60 frames per second
UPDATESCENERY ' move parallax scenery
_PUTIMAGE (40, 200), FlappyBird& ' place flappy bird title on screen
_PUTIMAGE (350, 200), Fbird&(2, FLAPTHEBIRD%) ' place flapping bird on screen
_PUTIMAGE (46, 295), Message& ' place message on plaque
IF BUTTON%(156, 535, OKButton&) THEN Ok% = TRUE ' remeber if OK button pressed
_DISPLAY ' update screen with changes
IF _EXIT THEN CLEANUP: SYSTEM ' leave game if user closes game window
LOOP UNTIL Ok% ' END SHRE LOOP when OK button pressed
_FREEIMAGE Message& ' message image no longer needed
END SUB
'----------------------------------------------------------------------------------------------------------------------
FUNCTION BUTTON% (xpos%, ypos%, Image&)
'*
'* Creates a button on the screen the player can click with the mouse button.
'*
'* xpos% - x coordinate position of button on screen
'* ypos% - y coordinate position of button on screen
'* Image& - button image
'*
'* Returns: boolean: TRUE if button pressed
'* FALSE if button not pressed
'*
DIM x% ' current mouse x coordinate
DIM y% ' current mouse y coordinate
DIM b% ' boolean: TRUE if left mouse button pressed
_PUTIMAGE (xpos%, ypos%), Image& ' place button image on the screen
WHILE _MOUSEINPUT: WEND ' get latest mouse information
x% = _MOUSEX ' get current mouse x coordinate
y% = _MOUSEY ' get current mouse y coordinate
b% = _MOUSEBUTTON(1)
IF b% THEN ' is left mouse button pressed?
IF x% >= xpos% THEN ' yes, is mouse x within lower limit of button?
IF x% <= xpos% + _WIDTH(Image&) THEN ' yes, is mouse x within upper limit of button?
IF y% >= ypos% THEN ' yes, is mouse y within lower limit of button?
IF y% <= ypos% + _HEIGHT(Image&) THEN ' yes, is mouse y within upper limit of button?
BUTTON% = TRUE ' yes, remember that button was clicked on
_DELAY .2 ' slight delay to allow button to release
END IF
END IF
END IF
END IF
END IF
END FUNCTION
'----------------------------------------------------------------------------------------------------------------------
SUB UPDATESCENERY ()
'*
'* Updates the moving parallax scenery
'*
SHARED Scenery() AS PARALLAX, Clean&, HazardBar&, Paused%
DIM c% ' scenery index indicator
_PUTIMAGE , Clean& ' clear screen with clean image
DO ' BEGIN SCENERY LOOP
c% = c% + 1 ' increment index value
IF NOT Paused% THEN ' is game in paused state?
Scenery(c%).frame = Scenery(c%).frame + 1 ' no, update frame counter of current scenery
IF Scenery(c%).frame = Scenery(c%).fmax THEN ' frame counter hit limit?
Scenery(c%).frame = 0 ' yes, reset frame counter
Scenery(c%).x = Scenery(c%).x - 1 ' move scenery 1 pixel to left
IF Scenery(c%).x = -432 THEN ' scenery hit lower limit?
Scenery(c%).x = 0 ' yes, reset scenery to start position
END IF
END IF
END IF
_PUTIMAGE (Scenery(c%).x, Scenery(c%).y), Scenery(c%).image ' place current scenery on screen
LOOP UNTIL c% = 3 ' END SCENERY LOOP when all scenery updated
IF NOT Paused% THEN ' is game in paused state?
Scenery(4).x = Scenery(4).x - 3 ' no, move hazard bar 3 pixels to left
IF Scenery(4).x = -21 THEN Scenery(4).x = 0 ' reset to start position if lower limit hit
END IF
_PUTIMAGE (Scenery(4).x, Scenery(4).y), HazardBar& ' place hazard bar on screen
END SUB
'----------------------------------------------------------------------------------------------------------------------
SUB LOADASSETS ()
'*
'* Loads game graphics, sounds and initial settings.
'*
SHARED Scenery() AS PARALLAX, Birdie AS INFLIGHT, Pipes() AS PIPE, Pipe&(), Fbird&()
SHARED Num&(), Medal&(), Plaque&, FlappyBird&, GameOver&, GetReady&, Finger&
SHARED ScoreButton&, ShareButton&, StartButton&, OKButton&, RateButton&, MenuButton&
SHARED PlayButton&, PauseButton&, HazardBar&, Clouds&, City&, Bushes&, New&, Clean&
SHARED HighScore%, PipeImage&, Ding&, Flap&, Smack&
DIM Sheet& ' sprite sheet image
DIM x% ' generic counter
DIM y% ' generic counter
DIM PipeTop& ' temporary top of pipe image
DIM PipeTube& ' temporary pipe tube image
Ding& = _SNDOPEN("fbding.ogg", "VOL,SYNC") ' load game sounds
Flap& = _SNDOPEN("fbflap.ogg", "VOL,SYNC")
Smack& = _SNDOPEN("fbsmack.ogg", "VOL,SYNC")
Sheet& = _LOADIMAGE("fbsheet.png", 32) ' load sprite sheet
FOR y% = 0 TO 2 ' cycle through bird image rows
FOR x% = 0 TO 7 ' cycle through bird image columns
Fbird&(x% + 1, y% + 1) = _NEWIMAGE(53, 53, 32) ' create image holder then get image
_PUTIMAGE , Sheet&, Fbird&(x% + 1, y% + 1), (x% * 53, y% * 53)-(x% * 53 + 52, y% * 53 + 52)
NEXT x%
NEXT y%
FOR x% = 0 TO 9 ' cycle trough 9 numeral images
Num&(x%, 0) = _NEWIMAGE(21, 30, 32) ' create image holder for big
Num&(x%, 1) = _NEWIMAGE(18, 21, 32) ' create image holder for small
_PUTIMAGE , Sheet&, Num&(x%, 0), (x% * 21, 159)-(x% * 21 + 20, 188) ' get images
_PUTIMAGE , Sheet&, Num&(x%, 1), (x% * 18 + 210, 159)-(x% * 18 + 227, 179)
NEXT x%
Plaque& = _NEWIMAGE(339, 174, 32) ' define remaining image sizes
FlappyBird& = _NEWIMAGE(288, 66, 32)
GameOver& = _NEWIMAGE(282, 57, 32)
GetReady& = _NEWIMAGE(261, 66, 32)
PipeTop& = _NEWIMAGE(78, 36, 32)
PipeTube& = _NEWIMAGE(78, 36, 32)
Pipe&(0) = _NEWIMAGE(78, 432, 32)
Pipe&(1) = _NEWIMAGE(78, 432, 32)
PipeImage& = _NEWIMAGE(432, 596, 32)
Medal&(0, 0) = _NEWIMAGE(66, 66, 32)
Medal&(0, 1) = _NEWIMAGE(66, 66, 32)
Medal&(1, 0) = _NEWIMAGE(66, 66, 32)
Medal&(1, 1) = _NEWIMAGE(66, 66, 32)
Finger& = _NEWIMAGE(117, 147, 32)
ScoreButton& = _NEWIMAGE(120, 42, 32)
ShareButton& = _NEWIMAGE(120, 42, 32)
StartButton& = _NEWIMAGE(120, 42, 32)
OKButton& = _NEWIMAGE(120, 42, 32)
RateButton& = _NEWIMAGE(120, 42, 32)
MenuButton& = _NEWIMAGE(120, 42, 32)
PlayButton& = _NEWIMAGE(39, 42, 32)
PauseButton& = _NEWIMAGE(39, 42, 32)
HazardBar& = _NEWIMAGE(462, 24, 32)
Clouds& = _NEWIMAGE(864, 120, 32)
City& = _NEWIMAGE(864, 57, 32)
Bushes& = _NEWIMAGE(864, 27, 32)
New& = _NEWIMAGE(48, 21, 32)
_PUTIMAGE , Sheet&, Plaque&, (0, 189)-(338, 362) ' grab images from sprite sheet
_PUTIMAGE , Sheet&, FlappyBird&, (0, 363)-(287, 428)
_PUTIMAGE , Sheet&, GameOver&, (588, 246)-(869, 302)
_PUTIMAGE , Sheet&, GetReady&, (588, 303)-(847, 368)
_PUTIMAGE , Sheet&, Medal&(0, 0), (339, 327)-(404, 392)
_PUTIMAGE , Sheet&, Medal&(0, 1), (405, 327)-(470, 392)
_PUTIMAGE , Sheet&, Medal&(1, 0), (339, 261)-(404, 326)
_PUTIMAGE , Sheet&, Medal&(1, 1), (405, 261)-(470, 326)
_PUTIMAGE , Sheet&, Finger&, (471, 246)-(587, 392)
_PUTIMAGE , Sheet&, ScoreButton&, (288, 417)-(407, 458)
_PUTIMAGE , Sheet&, ShareButton&, (408, 417)-(527, 458)
_PUTIMAGE , Sheet&, StartButton&, (528, 417)-(647, 458)
_PUTIMAGE , Sheet&, OKButton&, (424, 204)-(543, 245)
_PUTIMAGE , Sheet&, RateButton&, (544, 204)-(663, 245)
_PUTIMAGE , Sheet&, MenuButton&, (664, 204)-(783, 245)
_PUTIMAGE , Sheet&, PlayButton&, (784, 204)-(822, 245)
_PUTIMAGE , Sheet&, PauseButton&, (823, 204)-(861, 245)
_PUTIMAGE , Sheet&, HazardBar&, (288, 393)-(749, 416)
_PUTIMAGE (0, 0)-(431, 119), Sheet&, Clouds&, (424, 0)-(855, 119)
_PUTIMAGE (432, 0)-(863, 119), Sheet&, Clouds&, (424, 0)-(855, 119)
_PUTIMAGE (0, 0)-(431, 56), Sheet&, City&, (424, 120)-(855, 176)
_PUTIMAGE (432, 0)-(863, 56), Sheet&, City&, (424, 120)-(855, 176)
_PUTIMAGE (0, 0)-(431, 26), Sheet&, Bushes&, (424, 177)-(855, 203)
_PUTIMAGE (432, 0)-(863, 26), Sheet&, Bushes&, (424, 177)-(855, 203)
_PUTIMAGE , Sheet&, New&, (289, 363)-(336, 383)
_PUTIMAGE , Sheet&, PipeTop&, (339, 189)-(416, 224)
_PUTIMAGE , Sheet&, PipeTube&, (339, 225)-(416, 260)
_PUTIMAGE (0, 431)-(77, 395), PipeTop&, Pipe&(0) ' create bottom of upper tube image
_PUTIMAGE (0, 0), PipeTop&, Pipe&(1) ' create top of lower tube image
FOR y% = 0 TO 395 STEP 36 ' cycle through tube body of pipes
_PUTIMAGE (0, y% + 35)-(77, y%), PipeTube&, Pipe&(0) ' draw tube on upper pipe image
_PUTIMAGE (0, 36 + y%), PipeTube&, Pipe&(1) ' draw tube on lower pipe image
NEXT y%
_FREEIMAGE PipeTop& ' temporary image no longer needed
_FREEIMAGE PipeTube& ' temporary image no longer needed
_FREEIMAGE Sheet& ' sprite sheet no longer needed
Clean& = _NEWIMAGE(432, 768, 32) ' create clean image holder
_DEST Clean& ' work on clean image
CLS , _RGB32(84, 192, 201) ' clear image with sky blue color
LINE (0, 620)-(431, 767), _RGB32(219, 218, 150), BF ' create brown ground portion of image
LINE (0, 577)-(431, 595), _RGB32(100, 224, 117), BF ' create green grass portion of image
_DEST 0 ' back to work on screen
Scenery(1).image = Clouds& ' set scenery parallax information
Scenery(1).y = 457
Scenery(1).fmax = 8
Scenery(2).image = City&
Scenery(2).y = 510
Scenery(2).fmax = 4
Scenery(3).image = Bushes&
Scenery(3).y = 550
Scenery(3).fmax = 2
Scenery(4).image = HazardBar&
Scenery(4).y = 596
IF _FILEEXISTS("fbird.sco") THEN ' does high score file exist?
OPEN "fbird.sco" FOR INPUT AS #1 ' yes, open high score file
INPUT #1, HighScore% ' get high score from file
CLOSE #1 ' close high score file
END IF
END SUB
'----------------------------------------------------------------------------------------------------------------------
FUNCTION BOXCOLLISION% (Box1X%, Box1Y%, Box1Width%, Box1Height%, Box2X%, Box2Y%, Box2Width%, Box2Height%)
'**
'** Detects if two bounding box areas are in collision
'**
'** INPUT : Box1X% - upper left corner X location of bounding box 1
'** Box1Y% - upper left corner Y location of bounding box 1
'** Box1Width% - the width of bounding box 1
'** Box1Height% - the height of bounding box 1
'** Box2X% - upper left corner X location of bounding box 2
'** Box2Y% - upper left corner Y location of bounding box 2
'** Box2Width% - the width of bounding box 2
'** Box2Height% - the height of bounding box 2
'**
'** OUTPUT: BOXCOLLISION - 0 (FALSE) for no collision, -1 (TRUE) for collision
'**
IF Box1X% <= Box2X% + Box2Width% - 1 THEN ' is box1 x within lower limit of box2 x?
IF Box1X% + Box1Width% - 1 >= Box2X% THEN ' yes, is box1 x within upper limit of box2 x?
IF Box1Y% <= Box2Y% + Box2Height% - 1 THEN ' yes, is box1 y within lower limit of box2 y?
IF Box1Y% + Box1Height% - 1 >= Box2Y% THEN ' yes, is box1 y within upper limit of box2 y?
BOXCOLLISION% = TRUE ' yes, then a collision occured, return result
END IF
END IF
END IF
END IF
END FUNCTION
'----------------------------------------------------------------------------------------------------------------------
SUB CLEANUP ()
'*
'* Removes all game assets from the computer's RAM.
'*
SHARED Fbird&(), Pipe&(), Num&(), Medal&(), Plaque&, FlappyBird&, GameOver&, GetReady&
SHARED Finger&, ScoreButton&, ShareButton&, StartButton&, OKButton&, RateButton&
SHARED MenuButton&, PlayButton&, PauseButton&, HazardBar&, Clouds&, City&, Bushes&
SHARED New&, Clean&, PipeImage&, Ding&, Flap&, Smack&
DIM x% ' generic counter
DIM y% ' generic counter
_SNDCLOSE Ding& ' remove game sounds from RAM
_SNDCLOSE Flap&
_SNDCLOSE Smack&
FOR y% = 0 TO 2 ' cycle through bird image rows
FOR x% = 0 TO 7 ' cycle through bird image columns
_FREEIMAGE Fbird&(x% + 1, y% + 1) ' remove bird image from RAM
NEXT x%
NEXT y%
FOR x% = 0 TO 9 ' cycle trough 9 numeral images
_FREEIMAGE Num&(x%, 0) ' remove large numeral image from RAM
_FREEIMAGE Num&(x%, 1) ' remove small numeral image from RAM
NEXT x%
_FREEIMAGE Plaque& ' remove all remaining images from RAM
_FREEIMAGE FlappyBird&
_FREEIMAGE GameOver&
_FREEIMAGE GetReady&
_FREEIMAGE Pipe&(0)
_FREEIMAGE Pipe&(1)
_FREEIMAGE PipeImage&
_FREEIMAGE Medal&(0, 0)
_FREEIMAGE Medal&(0, 1)
_FREEIMAGE Medal&(1, 0)
_FREEIMAGE Medal&(1, 1)
_FREEIMAGE Finger&
_FREEIMAGE ScoreButton&
_FREEIMAGE ShareButton&
_FREEIMAGE StartButton&
_FREEIMAGE OKButton&
_FREEIMAGE RateButton&
_FREEIMAGE MenuButton&
_FREEIMAGE PlayButton&
_FREEIMAGE PauseButton&
_FREEIMAGE HazardBar&
_FREEIMAGE Clouds&
_FREEIMAGE City&
_FREEIMAGE Bushes&
_FREEIMAGE New&
_FREEIMAGE Clean&
END SUB
'----------------------------------------------------------------------------------------------------------------------
Files required to run:
FLappy Bird.zip (Size: 84.04 KB / Downloads: 33)
|
|
|
Trespass Board Game 1979 Lakeside Games |
Posted by: SMcNeill - 12-24-2023, 04:05 AM - Forum: Donald Foster
- Replies (1)
|
|
Quote:Hello All,
This is the 2 player abstract strategy board game from Lakeside games 1979. There has been a few totally separate board games introduced with the same tile.
The board stands upright similar to Connect Four. Player 1, the Attacker, has 11 pieces lined up across the bottom row of the board and their goal is to try to get 1 of their pieces to top row. There are 2 boarders, 1 separating the top row from the middle and 1 separating the bottom row from the middle. Play 2, the Defender, has 4 Blocker pieces and 1 Striker piece trying to prevent player 1's piece from reaching the top row. Player 2's Blockers or Striker pieces can not cross either barrier.
No pieces may jump over other pieces. The Attacker piece can only move 1 space straight up the board per turn. No sideways, backwards or diagonal moves allowed. The Blocker piece my move in any of the 8 directions as many spaces they choose to, but can not land on any other pieces. Their job is to block the progress of the Attacker pieces. The Striker piece can move in all 8 directions also, but only 1 space. When the Striker piece lands on an Attacker piece, the Attacker piece is bumped off the board for the remainder of the game.
As mentioned previously, the Attacker wins if they can get 1 of their piece on the top row of the board. The Defender wins when they have captured all of the Attacker pieces or block the remaining Attacker pieces from making a move.
I never played this game before I wrote it and it seems to me the Attacker has the advantage. I would like to see a game play through were the Defender can beat the Attacker. It is suggested to switch rolls for alternating games. I left a copy of the rules below.
Hope you enjoy playing;
Donald
Code: (Select All)
_Title "Trespass Board Game 1979 - Programmed by Donald L. Foster Jr. 2021"
Screen _NewImage(1300, 735, 256)
_PaletteColor 1, _RGB32(0, 127, 183) ' Background Color
_PaletteColor 2, _RGB32(40, 40, 40) ' Board Frame Color
_PaletteColor 3, _RGB32(170, 160, 0) ' Yellow Striker Piece
_PaletteColor 4, _RGB32(30, 30, 30) ' Black Blocker Piece
_PaletteColor 5, _RGB32(225, 20, 20) ' Red Attacker Piece
Dim Player As Integer
Dim Opponent As Integer
Dim Row As Integer
Dim Column As Integer
Dim NewRow As Integer
Dim NewColumn As Integer
Dim PieceColor As Integer
Dim Attackers As Integer
Dim Playable As Integer
Dim Piece As Integer
Dim Z As Integer
Dim Y As Integer
Dim X As Integer
Dim W As Integer
Dim V As Integer
Dim X1 As Integer
Dim X2 As Integer
Dim X3 As Integer
Dim StorageX(11) As Integer
Dim StorageY(11) As Integer
Dim BoardX(7, 11) As Integer
Dim BoardY(7, 11) As Integer
Dim BoardPiece(7, 11) As Integer
Dim Playable(7, 11) As Integer
Player = 1: Opponent = 2: Attackers = 11
PieceColor(1) = 5: PieceColor(2) = 4: PieceColor(3) = 3
For Z = 1 To 11: BoardPiece(7, Z) = 1: Next: BoardPiece(2, 4) = 2: BoardPiece(2, 5) = 2: BoardPiece(2, 6) = 3: BoardPiece(2, 7) = 2: BoardPiece(2, 8) = 2
fontpath$ = Environ$("SYSTEMROOT") + "\fonts\Segoeuib.ttf"
Cls , 1
' Draw Board
Line (10, 10)-(1016, 725), 2, BF
X = 58
For Z = 1 To 7
W = 58
For Y = 1 To 11
X1 = W: X2 = X: X3 = BoardPiece(Z, Y): GoSub DrawPiece
BoardX(Z, Y) = W: BoardY(Z, Y) = X
W = W + 91
Next
If Z = 1 Or Z = 6 Then X = X + 127 Else X = X + 91
Next
Line (16, 106)-(1010, 136), 4, BF: Line (16, 597)-(1010, 627), 4, BF
Line (46, 106)-(980, 136), 3, BF: Line (46, 597)-(980, 627), 3, BF
Color 0, 1: font& = _LoadFont(fontpath$, 25): _Font font&: _PrintString (1050, 10), "T R E S P A S S"
' Get Captured Piece Storage
X2 = 220: X3 = 1: For Z = 1 To 11 Step 2: StorageX(Z) = 1100: StorageY(Z) = X2: X2 = X2 + 81: Next
X2 = 260: X3 = 1: For Z = 2 To 10 Step 2: StorageX(Z) = 1216: StorageY(Z) = X2: X2 = X2 + 81: Next
StartGame:
' Display Player Indicator(s)
Line (1057, 42)-(1259, 128), 1, BF
If Player = 1 Then
X1 = 1158: X2 = 85: X3 = 1: GoSub DrawPiece
Else
X1 = 1100: X2 = 85: X3 = 2: GoSub DrawPiece
X1 = 1216: X2 = 85: X3 = 3: GoSub DrawPiece
End If
font& = _LoadFont(fontpath$, 20): _Font font&: _PrintString (1115, 135), "Player: " + Str$(Player)
GetPlayables:
For Z = 1 To 7: For Y = 1 To 11: Playable(Z, Y) = 0: Next: Next
If Player = 1 Then
For Z = 1 To 7
For Y = 1 To 11
If BoardPiece(Z, Y) = 1 Then If Z > 1 Then If BoardPiece(Z - 1, Y) = 0 Then Playable(Z, Y) = 1
Next
Next
End If
ChooseAPiece:
font& = _LoadFont(fontpath$, 18): _Font font&: _PrintString (1040, 700), " Choose a Piece to Move "
GetBoardPiece:
Do While _MouseInput
For Z = 1 To 7
For Y = 1 To 11
If (Player = 1 And Playable(Z, Y) = 1) Or (Player = 2 And BoardPiece(Z, Y) > 1) Then
If _MouseX > BoardX(Z, Y) - 32 And _MouseX < BoardX(Z, Y) + 32 And _MouseY > BoardY(Z, Y) - 32 And _MouseY < BoardY(Z, Y) + 32 And _MouseButton(1) = -1 Then
GoSub ButtonRelease: Row = Z: Column = Y: Line (BoardX(Z, Y) - 44, BoardY(Z, Y) - 44)-(BoardX(Z, Y) + 44, BoardY(Z, Y) + 44), 15, B: GoTo SetupMove
End If
End If
Next
Next
Loop
A$ = InKey$: If A$ <> "" Then If Asc(A$) = 27 And Full = 0 Then _FullScreen _SquarePixels , _Smooth: Full = 1 Else If Asc(A$) = 27 Then _FullScreen _Off: Full = 0
GoTo GetBoardPiece
SetupMove:
' Remove Playables
For Z = 1 To 7: For Y = 1 To 11: Playable(Z, Y) = 0: Next: Next
' Setup Playables for Move
Playable(Row, Column) = 1: Piece = BoardPiece(Row, Column)
Select Case Piece
Case 1:
Playable(Row - 1, Column) = 1
Case 2:
X = 1
Dir1: If Row - X >= 2 Then If BoardPiece(Row - X, Column) = 0 Then Playable(Row - X, Column) = 1: X = X + 1: GoTo Dir1
X = 1
Dir2: If Row + X <= 6 Then If BoardPiece(Row + X, Column) = 0 Then Playable(Row + X, Column) = 1: X = X + 1: GoTo Dir2
X = 1
Dir3: If Column - X >= 1 Then If BoardPiece(Row, Column - X) = 0 Then Playable(Row, Column - X) = 1: X = X + 1: GoTo Dir3
X = 1
Dir4: If Column + X <= 11 Then If BoardPiece(Row, Column + X) = 0 Then Playable(Row, Column + X) = 1: X = X + 1: GoTo Dir4
X = 1
Dir5: If Row - X >= 2 And Column - X >= 1 Then If BoardPiece(Row - X, Column - X) = 0 Then Playable(Row - X, Column - X) = 1: X = X + 1: GoTo Dir5
X = 1
Dir6: If Row + X <= 6 And Column + X <= 11 Then If BoardPiece(Row + X, Column + X) = 0 Then Playable(Row + X, Column + X) = 1: X = X + 1: GoTo Dir6
X = 1
Dir7: If Row - X >= 2 And Column + X <= 11 Then If BoardPiece(Row - X, Column + X) = 0 Then Playable(Row - X, Column + X) = 1: X = X + 1: GoTo Dir7
X = 1
Dir8: If Row + X <= 6 And Column - X >= 1 Then If BoardPiece(Row + X, Column - X) = 0 Then Playable(Row + X, Column - X) = 1: X = X + 1: GoTo Dir8
Case 3:
If Row - 1 >= 2 Then If BoardPiece(Row - 1, Column) < 2 Then Playable(Row - 1, Column) = 1
If Row + 1 <= 6 Then If BoardPiece(Row + 1, Column) < 2 Then Playable(Row + 1, Column) = 1
If Column - 1 >= 1 Then If BoardPiece(Row, Column - 1) < 2 Then Playable(Row, Column - 1) = 1
If Column + 1 <= 11 Then If BoardPiece(Row, Column + 1) < 2 Then Playable(Row, Column + 1) = 1
If Row - 1 >= 2 And Column - 1 >= 1 Then If BoardPiece(Row - 1, Column - 1) < 2 Then Playable(Row - 1, Column - 1) = 1
If Row + 1 <= 6 And Column + 1 <= 11 Then If BoardPiece(Row + 1, Column + 1) < 2 Then Playable(Row + 1, Column + 1) = 1
If Row - 1 >= 2 And Column + 1 <= 11 Then If BoardPiece(Row - 1, Column + 1) < 2 Then Playable(Row - 1, Column + 1) = 1
If Row + 1 <= 6 And Column - 1 >= 1 Then If BoardPiece(Row + 1, Column - 1) < 2 Then Playable(Row + 1, Column - 1) = 1
End Select
font& = _LoadFont(fontpath$, 18): _Font font&: _PrintString (1040, 700), "Choose Location to Move to"
GetLocation:
Do While _MouseInput
For Z = 1 To 7
For Y = 1 To 11
If Playable(Z, Y) = 1 Then
If _MouseX > BoardX(Z, Y) - 32 And _MouseX < BoardX(Z, Y) + 32 And _MouseY > BoardY(Z, Y) - 32 And _MouseY < BoardY(Z, Y) + 32 And _MouseButton(1) = -1 Then
GoSub ButtonRelease: NewRow = Z: NewColumn = Y:: GoTo Location
End If
End If
Next
Next
Loop
A$ = InKey$: If A$ <> "" Then If Asc(A$) = 27 And Full = 0 Then _FullScreen _SquarePixels , _Smooth: Full = 1 Else If Asc(A$) = 27 Then _FullScreen _Off: Full = 0
GoTo GetLocation
Location:
Line (BoardX(Row, Column) - 44, BoardY(Row, Column) - 44)-(BoardX(Row, Column) + 44, BoardY(Row, Column) + 44), 2, B
' Check for Change Piece
If NewRow = Row And NewColumn = Column GoTo GetPlayables
' Check for Attacker Captured by Striker
Piece = BoardPiece(Row, Column)
If Piece = 3 And BoardPiece(NewRow, NewColumn) = 1 Then
Attackers = Attackers - 1
X1 = StorageX(11 - Attackers): X2 = StorageY(11 - Attackers): X3 = 1: GoSub DrawPiece
End If
' Move Piece to New Location
BoardPiece(Row, Column) = 0: X1 = BoardX(Row, Column): X2 = BoardY(Row, Column): X3 = 0: GoSub DrawPiece
BoardPiece(NewRow, NewColumn) = Piece: X1 = BoardX(NewRow, NewColumn): X2 = BoardY(NewRow, NewColumn): X3 = Piece: GoSub DrawPiece
' Check for Winner
If Player = 1 Then
X = 0
For Z = 1 To 11
If BoardPiece(1, Z) = 1 Then X = 1
Next
Else
V = 1: X = 0: If Attackers = 0 Then X = 1
For Z = 1 To 7
For Y = 1 To 11
If BoardPiece(Z, Y) = 1 Then If Z > 1 Then If BoardPiece(Z - 1, Y) = 0 Then V = 0
Next
Next
If V = 1 Then X = 1
End If
If X = 1 GoTo winner
Swap Player, Opponent: GoTo StartGame
ButtonRelease:
Do While _MouseInput
If _MouseButton(1) = 0 Then Return
Loop
GoTo ButtonRelease
DrawPiece:
If X3 = 0 Then V = 1 Else V = 0
Line (X1 - 42, X2 - 42)-(X1 + 42, X2 + 42), V, BF
If X3 > 0 Then Line (X1 - 37, X2 - 37)-(X1 + 37, X2 + 37), PieceColor(X3), BF: PSet (X1 + 37, X2 - 37), 15: Draw "L74D74R1U73R73"
Return
winner:
font& = _LoadFont(fontpath$, 18): _Font font&: _PrintString (1040, 700), String$(50, 32)
Color 0, 1: font& = _LoadFont(fontpath$, 16): _Font font&
_PrintString (1070, 690), "Player " + Str$(Player) + " is the Winner!"
_PrintString (1050, 712), "Play Another Game? Y or N"
GetYorN:
A$ = UCase$(InKey$): If A$ = "" GoTo GetYorN
If Asc(A$) = 27 And Full = 0 Then _FullScreen _SquarePixels , _Smooth: Full = 1 Else If Asc(A$) = 27 Then _FullScreen _Off: Full = 0
If A$ = "Y" Then Run
If A$ = "N" Then System
GoTo winner
|
|
|
Outwit Board Game |
Posted by: SMcNeill - 12-23-2023, 11:48 PM - Forum: Donald Foster
- Replies (1)
|
|
Quote:Hello all,
I've complete another game I wrote on the Tandy 2000 about 30 years ago. Outwit is a 2 player board game.
From the instruction sheet:
"EQUIPMENT: 1 playing board with 90 squares, including two corners of 9 squares each. 18 chips (9 dark and 9 light), one chip on each side has a dot on it, called the "power chip".
OBJECT: To be the first to slide all nine of your chips into your own corner of the board."
The chips are setup in the middle of the board at start. Each player plays alternately one chip in one direction only. a regular chip may move horizontally or vertically only. A power chip may move also diagonally. A regular chip must slide as far as it can go. Stopped only by reaching the edge of the board, another chip or the opponent's corner. A power chip can stop whenever it wants, but must stop for the same reasons as a regular chip.
Donald
Code: (Select All)
Option _Explicit
' I used a code snippet by bplus modified to enlarge the characters on the screen.
_Title "Outwit - Designer Unknown 1975 - Programmed by Donald L. Foster Jr. 2018 - Code Snippet by bplus"
Screen _NewImage(1084, 735, 256)
_PaletteColor 1, _RGB32(204, 124, 56) ' Player 1 Piece Color
_PaletteColor 2, _RGB32(109, 39, 0) ' Player 2 Piece Color
_PaletteColor 3, _RGB32(205, 76, 0) ' Board Background Color
_PaletteColor 4, _RGB32(245, 116, 0) ' Board Square Color
_PaletteColor 5, _RGB32(245, 205, 0) ' Player 1 Corner Color
_PaletteColor 6, _RGB32(139, 69, 19) ' Player 2 Corner Color
_PaletteColor 7, _RGB32(255, 215, 0) ' Gold Piece Color
_PaletteColor 8, _RGB32(80, 80, 80) ' Cursor Color
_Limit 10
Dim A As String
Dim U As _Unsigned Integer
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 Square 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 Piece 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(9, 10) As _Unsigned Integer
Dim BoardY(9, 10) As _Unsigned Integer
Dim BoardPlayer(9, 10) As _Unsigned _Byte
Dim BoardPiece(9, 10) As _Unsigned _Byte
Dim BoardSquare(9, 10) As _Unsigned _Byte
Dim Playable(9, 10) As _Unsigned _Byte
Dim Cursor As String
Dim Message As String
Player = 1: Opponent = 2
Pieces(1) = 0: Pieces(2) = 0
PlayerColor(1) = 1: PlayerColor(2) = 2
Cursor$ = "BU36BL36C15D72R72U72L72BF2D68R68U68L68BH1P15,15"
Cls , 15
' Draw Game Title Message
Message$ = " Outwit ": X1 = 815: X2 = 2: X3 = 0: X4 = 4: GoSub DrawMessage
Line (0, 0)-(100, 30), 15, BF
' Draw Board
Line (10, 30)-(10, 702), 0
Line (799, 30)-(799, 702), 0
Line (30, 10)-(779, 10), 0
Line (30, 722)-(779, 722), 0
Circle (30, 30), 20, 0, 1.4, 3.1
Circle (779, 30), 20, 0, 0, 1.6
Circle (30, 702), 20, 0, 2.9, 4.72
Circle (779, 702), 20, 0, 4.52, 0
Paint (30, 30), 3, 0
Line (28, 28)-(781, 706), 0, BF
X = 67: U = 9
For Z = 1 To 9
W = 67
For Y = 1 To 10
If Z < 4 And Y < 4 Then V = 6 Else If Z > 6 And Y > 7 Then V = 5 Else V = 4
Line (W - 36, X - 36)-(W + 36, X + 36), V, BF
If V = 6 Then BoardSquare(Z, Y) = 2 Else If V = 5 Then BoardSquare(Z, Y) = 1 Else BoardSquare(Z, Y) = 0
If Y = U Then BoardPlayer(Z, Y) = 1: BoardPiece(Z, Y) = 1: BoardSquare(Z, Y) = 3: Circle (W, X), 30, 0: Paint (W, X), 1, 0
If Y = U + 1 Then BoardPlayer(Z, Y) = 2: BoardPiece(Z, Y) = 1: BoardSquare(Z, Y) = 4: Circle (W, X), 30, 0: Paint (W, X), 2, 0
If Z = 5 And (Y = 5 Or Y = 6) Then BoardPiece(Z, Y) = 2: Circle (W, X), 13, 7: Paint (W, X), 7
BoardX(Z, Y) = W: BoardY(Z, Y) = X
W = W + 75
Next
X = X + 75: U = U - 1
Next
StartGame:
' Draw Player Indicator
Circle (941, 130), 30, 0: Paint (941, 130), PlayerColor(Player), 0: Circle (941, 130), 13, 7: Paint (941, 130), 7
Locate 12, 115: Print "Player"; Player;
StartMove: Locate 16, 105: Print " Choose a Piece to Move. ";
ChooseAPieceInput:
Do While _MouseInput
For Z = 1 To 9
For Y = 1 To 10
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:
Piece = BoardPiece(Row1, Column1): Square = BoardSquare(Row1, Column1): BoardX1 = BoardX(Row1, Column1): BoardY1 = BoardY(Row1, Column1)
If Square = 1 Then SquareColor1 = 5 Else If Square = 2 Then SquareColor1 = 6 Else SquareColor1 = 4
V = Point(BoardX1, BoardY1): PSet (BoardX1, BoardY1), V: Draw Cursor$
For Z = 1 To 9: For Y = 1 To 10: Playable(Z, Y) = 0: Next: Next
Playable(Row1, Column1) = 1
X = 0
CheckUp:
If Row1 - X - 1 >= 1 Then
If BoardPlayer(Row1 - X - 1, Column1) > 0 GoTo EndUp
If Square = 1 Then
If BoardSquare(Row1 - X - 1, Column1) = 0 GoTo EndUp
X = X + 1: GoTo CheckUp
Else
If BoardSquare(Row1 - X - 1, Column1) = 2 And Player = 1 GoTo EndUp
If Piece = 2 Then Playable(Row1 - X, Column1) = 1
X = X + 1: GoTo CheckUp
End If
EndUp: Playable(Row1 - X, Column1) = 1
Else
Playable(Row1 - X, Column1) = 1
End If
X = 0
CheckLeft:
If Column1 - X - 1 >= 1 Then
If BoardPlayer(Row1, Column1 - X - 1) > 0 GoTo EndLeft
If Square = 1 Then
If BoardSquare(Row1, Column1 - X - 1) = 0 GoTo EndLeft
X = X + 1: GoTo CheckLeft
Else
If BoardSquare(Row1, Column1 - X - 1) = 2 And Player = 1 GoTo EndLeft
If Piece = 2 Then Playable(Row1, Column1 - X - 1) = 1
X = X + 1: GoTo CheckLeft
End If
EndLeft: Playable(Row1, Column1 - X) = 1
Else
Playable(Row1, Column1 - X) = 1
End If
X = 0
CheckDown:
If Row1 + X + 1 <= 9 Then
If BoardPlayer(Row1 + X + 1, Column1) > 0 GoTo EndDown
If Square = 2 Then
If BoardSquare(Row1 + X + 1, Column1) = 0 GoTo EndDown
X = X + 1: GoTo CheckDown
Else
If BoardSquare(Row1 + X + 1, Column1) = 1 And Player = 2 GoTo EndDown
If Piece = 2 Then Playable(Row1 + X + 1, Column1) = 1
X = X + 1: GoTo CheckDown
End If
EndDown: Playable(Row1 + X, Column1) = 1
Else
Playable(Row1 + X, Column1) = 1
End If
X = 0
CheckRight:
If Column1 + X + 1 <= 10 Then
If BoardPlayer(Row1, Column1 + X + 1) > 0 GoTo EndRight
If Square = 2 Then
If BoardSquare(Row1, Column1 + X + 1) = 0 GoTo EndRight
X = X + 1: GoTo CheckRight
Else
If BoardSquare(Row1, Column1 + X + 1) = 1 And Player = 2 GoTo EndRight
If Piece = 2 Then Playable(Row1, Column1 + X + 1) = 1
X = X + 1: GoTo CheckRight
End If
EndRight: Playable(Row1, Column1 + X) = 1
Else
Playable(Row1, Column1 + X) = 1
End If
If Piece = 2 Then
X = 0
CheckUpLeft:
If Row1 - X - 1 >= 1 And Column1 - X - 1 >= 1 Then
If BoardPlayer(Row1 - X - 1, Column1 - X - 1) > 0 GoTo EndUpLeft
If Square = 1 Then
If BoardSquare(Row1 - X - 1, Column1 - X - 1) = 0 GoTo EndUpLeft
X = X + 1: GoTo CheckUpLeft
Else
If BoardSquare(Row1 - X - 1, Column1 - X - 1) = 2 And Player = 1 GoTo EndUpLeft
Playable(Row1 - X - 1, Column1 - X - 1) = 1: X = X + 1: GoTo CheckUpLeft
End If
EndUpLeft: Playable(Row1 - X, Column1 - X) = 1
Else
Playable(Row1 - X, Column1 - X) = 1
End If
X = 0
CheckDownLeft:
If Row1 + X + 1 <= 9 And Column1 - X - 1 >= 1 Then
If BoardPlayer(Row1 + X + 1, Column1 - X - 1) > 0 GoTo EndDownLeft
If Square = 1 Then
If BoardSquare(Row1 + X + 1, Column1 - X - 1) = 0 GoTo EndDownLeft
X = X + 1: GoTo CheckDownLeft
Else
If BoardSquare(Row1 + X + 1, Column1 - X - 1) = 2 And Player = 1 GoTo EndDownLeft
If BoardSquare(Row1 + X + 1, Column1 - X - 1) = 1 And Player = 2 GoTo EndDownLeft
Playable(Row1 + X + 1, Column1 - X - 1) = 1: X = X + 1: GoTo CheckDownLeft
End If
EndDownLeft: Playable(Row1 + X, Column1 - X) = 1
Else
Playable(Row1 + X, Column1 - X) = 1
End If
X = 0
CheckDownRight:
If Row1 + X + 1 <= 9 And Column1 + X + 1 <= 10 Then
If BoardPlayer(Row1 + X + 1, Column1 + X + 1) > 0 GoTo EndDownRight
If Square = 1 Then
If BoardSquare(Row1 + X + 1, Column1 + X + 1) = 0 GoTo EndDownRight
X = X + 1: GoTo CheckDownRight
Else
If BoardSquare(Row1 + X + 1, Column1 + X + 1) = 1 And Player = 2 GoTo EndDownRight
Playable(Row1 + X + 1, Column1 + X + 1) = 1: X = X + 1: GoTo CheckDownRight
End If
EndDownRight: Playable(Row1 + X, Column1 + X) = 1
Else
Playable(Row1 + X, Column1 + X) = 1
End If
X = 0
CheckUpRight:
If Row1 - X - 1 >= 1 And Column1 + X + 1 <= 10 Then
If BoardPlayer(Row1 - X - 1, Column1 + X + 1) > 0 GoTo EndUpRight
If Square = 1 Then
If BoardSquare(Row1 - X - 1, Column1 + X + 1) = 0 GoTo EndUpRight
X = X + 1: GoTo CheckUpRight
Else
If BoardSquare(Row1 - X - 1, Column1 + X + 1) = 1 And Player = 2 GoTo EndUpRight
If BoardSquare(Row1 - X - 1, Column1 + X + 1) = 2 And Player = 1 GoTo EndUpRight
Playable(Row1 - X - 1, Column1 + X + 1) = 1: X = X + 1: GoTo CheckUpRight
End If
EndUpRight: Playable(Row1 - X, Column1 + X) = 1
Else
Playable(Row1 - X, Column1 + X) = 1
End If
End If
Locate 16, 105: Print "Choose Location to Move to.";
ChooseALocationInput:
Do While _MouseInput
For Z = 1 To 9
For Y = 1 To 10
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 EndChoice2
End If
Next
Next
Loop
GoTo ChooseALocationInput
EndChoice2:
If Row1 = Row2 And Column1 = Column2 Then Paint (BoardX1 - 36, BoardY1 - 36), SquareColor1, 0: GoTo StartMove
BoardX2 = BoardX(Row2, Column2): BoardY2 = BoardY(Row2, Column2)
If BoardSquare(Row2, Column2) = 1 Then SquareColor2 = 5 Else If BoardSquare(Row2, Column2) = 2 Then SquareColor2 = 6 Else SquareColor2 = 4
Line (BoardX2 - 36, BoardY2 - 36)-(BoardX2 + 36, BoardY2 + 36), SquareColor2, BF
BoardPlayer(Row2, Column2) = Player: BoardPiece(Row2, Column2) = Piece
BoardPlayer(Row1, Column1) = 0: BoardPiece(Row1, Column1) = 0
Line (BoardX1 - 36, BoardY1 - 36)-(BoardX1 + 36, BoardY1 + 36), SquareColor1, BF
If Square > 2 Then
If Piece = 2 Then Circle (BoardX1, BoardY1), 30, 0: 'PAINT (BoardX1, BoardY1), 7
V = Square + 2: Circle (BoardX1, BoardY1), 13, 0: Paint (BoardX1, BoardY1), V, 0
End If
Line (BoardX2 - 36, BoardY2 - 36)-(BoardX2 + 36, BoardY2 + 36), SquareColor2, BF
Circle (BoardX2, BoardY2), 30, 0: Paint (BoardX2, BoardY2), PlayerColor(Player), 0
If Piece = 2 Then Circle (BoardX2, BoardY2), 13, 7: Paint (BoardX2, BoardY2), 7
If (Square = 0 Or Square = 3 Or Square = 4) And BoardSquare(Row2, Column2) = Player Then Pieces(Player) = Pieces(Player) + 1
If Pieces(Player) = 9 Then GoTo Winner
Swap Player, Opponent: GoTo StartGame
DrawMessage:
Color 0, 15: 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) <> 15 Then Line (X1 + Z * X4, X2 + Y * X4)-(X1 + Z * X4 + X4, X2 + Y * X4 + X4), 0, BF
Next
Next
Return
ReleaseMouseButton:
Do While _MouseInput
If _MouseButton(1) = 0 Then Return
Loop
GoTo ReleaseMouseButton
Winner:
Locate 16, 105: Print " Player"; Player; "is the Winner! ";
Locate 18, 104: Print "Play Another Game? ( Y or N )";
GetYorN:
A$ = UCase$(InKey$)
If A$ = "" Then GoTo GetYorN
If A$ = "Y" Then Run
If A$ = "N" Then System
GoTo GetYorN
|
|
|
Block It! Board Game |
Posted by: SMcNeill - 12-23-2023, 11:46 PM - Forum: Donald Foster
- No Replies
|
|
Quote:Hello all,
Block It! is a abstract strategy 2 to 4 player board game.
Object of game: To place all you blocks on the board first
Game consist of 2 game boards to choose from (black or white), 25 pieces with 4 colors arranged 5x5 on the board that can be rotated. Each player has 2 or 3 blocks of their color started off the board and a 6 sided dice showing types of moves players use on each turn.
The game starts off with the 25 pieces randomly arranged on the board. Each piece has a white stem so the pieces can be picked up and rotated. The pieces have 4 colors in each corner of the piece representing each players color. The players are trying to arrange 4 blocks in a square shape pattern trying to match the 4 inner corners colors to their color. Once all 4 corners match the player's color, that player places 1 of their blocks in the center of the 4 pieces claiming that spot on the board. Those 4 pieces a now locked down to the board and can not be rotated. If at the start of a players turn, there is already a new matching pattern with their color, the player place 1 of their blocks in that space, then the player takes their turn. If a the end of their turn, a new pattern of their color is formed, they place 1 of their blocks in the pattern.
A turn consist of rolling the the dice and performing the move indicated on the dice. The 6 moves are: rotate clockwise once, rotate clockwise twice, rotate counter clockwise once, rotate counter clockwise twice, swap any 2 pieces, and remove any players block. The rotate moves show 1x or 2x and an arrow showing the direction of rotation. on the 2x, you rotate 2 separate pieces or the same piece twice. Click on the piece you want to rotate. The swap moves has 2 arrows facing in opposite directions. You are asked to choose the 2 pieces to swap. The move a block move has a outline of a block with an X through it. Clock on any players block and it is removed from the board.
I have included a copy of the rules
Hope you enjoy playing
Donald
Block it! Rules.pdf (Size: 60.39 KB / Downloads: 48)
Code: (Select All)
_Title "Block It! - Designed by Hans van Tol 2003 - Programmed by Donald L. Foster Jr. 2018"
Screen _NewImage(1025, 735, 256)
_PaletteColor 1, _RGB32(100, 100, 100) ' background
_PaletteColor 2, _RGB32(250, 0, 0) ' Red Board
_PaletteColor 3, _RGB32(220, 0, 0) ' Red Piece
_PaletteColor 4, _RGB32(0, 150, 240) ' Blue Board
_PaletteColor 5, _RGB32(0, 120, 210) ' Blue Piece
_PaletteColor 6, _RGB32(240, 230, 0) ' Yellow Board
_PaletteColor 7, _RGB32(210, 200, 0) ' Yellow Piece
_PaletteColor 8, _RGB32(0, 190, 0) ' Green Board
_PaletteColor 9, _RGB32(0, 160, 0) ' Green Piece
_PaletteColor 10, _RGB32(30, 30, 30) ' Light Black
_PaletteColor 11, _RGB32(100, 100, 100) ' Block
Randomize Timer
DefInt A-Z
Dim Piece$(25, 4), Placed(25)
Player = 1: Blocks = 0
Blocks(1) = 0: Blocks(2) = 0: Blocks(3) = 0: Blocks(4) = 0
BoardColor(1, 1) = 2: BoardColor(1, 2) = 4: BoardColor(1, 3) = 6: BoardColor(1, 4) = 10
BoardColor(2, 1) = 2: BoardColor(2, 2) = 4: BoardColor(2, 3) = 6: BoardColor(2, 4) = 8
PlayerColor(1, 1) = 3: PlayerColor(1, 2) = 5: PlayerColor(1, 3) = 7: PlayerColor(1, 4) = 0
PlayerColor(2, 1) = 3: PlayerColor(2, 2) = 5: PlayerColor(2, 3) = 7: PlayerColor(2, 4) = 9
For Z = 1 To 5: For Y = 1 To 5: Locked = 0: Next: Next
' Setup Pieces
X$ = "3142412341323142314242312134124321344123413221432341312421432413243142132431421343124132132413243241"
Remove$(1) = "BR3BU30C0D27R30BD6L30D30BL6U30L30BU6R30U30BR2BD5P15,0"
Remove$(2) = "BR3BU30C15D27R30BD6L30D30BL6U30L30BU6R30U30R1C0D65R1U65R1D65R1U65D65R1U65D31R30L65D1R65D1L65D1R65D1L65"
X = 1: For Y = 1 To 25
W$ = Mid$(X$, X, 4):
Piece$(Y, 1) = W$
Piece$(Y, 2) = "": Piece$(Y, 2) = Mid$(W$, 3, 1) + Mid$(W$, 1, 1) + Mid$(W$, 4, 1) + Mid$(W$, 2, 1)
Piece$(Y, 3) = "": Piece$(Y, 3) = Mid$(W$, 4, 1) + Mid$(W$, 3, 1) + Mid$(W$, 2, 1) + Mid$(W$, 1, 1)
Piece$(Y, 4) = "": Piece$(Y, 4) = Mid$(W$, 2, 1) + Mid$(W$, 4, 1) + Mid$(W$, 1, 1) + Mid$(W$, 3, 1)
X = X + 4:
Next
Cls , 1: Color 15, 1: Locate 15, 52: Print "B L O C K I T !";
' Get How Many Players
Color 0, 1: Locate 20, 51: Print "How Many Players? (2 to 4) ";
GetPlayers: A$ = InKey$: If A$ = "" GoTo GetPlayers Else If Val(A$) < 2 Or Val(A$) > 4 GoTo GetPlayers Else Players = Val(A$): Print A$;
If Players > 2 Then Blocks = 2 Else Blocks = 3
For Z = 1 To Players: Blocks(Z) = Blocks: Next
' Choose Game Board
Color 0, 1: Locate 23, 47: Print "Choose Game Board. (White or Black) ";
GetGameBoard:
A$ = UCase$(InKey$)
If A$ = "" GoTo GetGameBoard
If A$ = "W" Then GameBoard = 1
If A$ = "B" Then GameBoard = 2
If GameBoard = 0 GoTo GetGameBoard
Print A$;
' Get How Many Blocks
If Players > 2 Then
Color 0: Locate 26, 52: Print "How Many Blocks? (2 or 3) ";
GetBlocks: A$ = InKey$: If A$ = "" GoTo GetBlocks Else If Val(A$) < 2 Or Val(A$) > 3 GoTo GetBlocks Else Blocks = Val(A$): Print A$;
End If
For Z = 1 To Players: Blocks(Z) = Blocks: Next
Cls , 1
' Draw Board
If GameBoard = 1 Then V1 = 0: V2 = 15 Else V1 = 15: V2 = 0
Line (30, 10)-(705, 10), V1
Line (30, 725)-(705, 725), V1
Line (10, 30)-(10, 705), V1
Line (725, 30)-(725, 705), V1
Circle (30, 30), 20, V1, 1.5, 3.1
Circle (705, 30), 20, V1, 0, 1.7
Circle (30, 705), 20, V1, 3.1, 4.8
Circle (705, 705), 20, V1, 4.6, 0
Paint (515, 515), V2, V1
' Setup Board and Draw Pieces on Board
For Z = 1 To 25: Placed(Z) = 0: Next
X = 0
For Z = 1 To 5
V = 0
For Y = 1 To 5
Placed: W = Int(Rnd * 25) + 1: If Placed(W) = 1 GoTo Placed Else Placed(W) = 1: BoardPiece(Z, Y) = W
Block: T1 = W: T2 = Int(Rnd * 4) + 1: BoardRotate(Z, Y) = T2: Rotate$ = Piece$(W, T2)
If Z > 1 And Y > 1 Then
BlockX(Z - 1, Y - 1) = 52 + V: BlockY(Z - 1, Y - 1) = 52 + X
B1 = Z - 1: B2 = Y - 1: Setup = 1: SetUpBlock = 0: GoSub CheckBlock: If SetUpBlock = 1 GoTo Block
End If
BoardX(Z, Y) = 115 + V: BoardY(Z, Y) = 115 + X: X1 = 115 + V: X2 = 115 + X: GoSub DrawPiece
V = V + 126
Next
X = X + 126
Next
Color 15, 1: Locate 2, 98: Print "B L O C K I T !";
GoSub UpdateBlockStorage
StartGame:
Setup = 0: Selected = 1: Blocks = 0
' Draw Player Indicator
X1 = 873: X2 = 100: X3 = Player: GoSub DrawBlock
Color 15, 1: Locate 10, 106: Print "Player:"; Player;
' Set Playable Moves to 0
For Z = 1 To 4: For Y = 1 To 4: Playable(Z, Y) = 0: Next: Next
' Check if Block Can be Placed
Block = 0
For Z = 1 To 4
For Y = 1 To 4
If Block(Z, Y) = 0 Then
T1 = BoardPiece(Z, Y): T2 = BoardRotate(Z, Y): Piece$ = Piece$(T1, T2): B1 = Val(Mid$(Piece$, 4, 1))
T1 = BoardPiece(Z, Y + 1): T2 = BoardRotate(Z, Y + 1): Piece$ = Piece$(T1, T2): B2 = Val(Mid$(Piece$, 3, 1))
T1 = BoardPiece(Z + 1, Y): T2 = BoardRotate(Z + 1, Y): Piece$ = Piece$(T1, T2): B3 = Val(Mid$(Piece$, 2, 1))
T1 = BoardPiece(Z + 1, Y + 1): T2 = BoardRotate(Z + 1, Y + 1): Piece$ = Piece$(T1, T2): B4 = Val(Mid$(Piece$, 1, 1))
If B1 = B2 And B2 = B3 And B3 = B4 And B1 = Player Then Block = 1: Playable(Z, Y) = B1
End If
Next
Next
' Block Can be Placed
If Block = 1 Then
Color 15, 1: Locate 23, 97: Print "You Have a Matching Pattern ";
Color 15, 1: Locate 25, 97: Print "Press <ENTER> to Place Block ";
GetENTER: A$ = InKey$: If A$ = "" GoTo GetENTER Else If Asc(A$) <> 13 GoTo GetENTER
GoSub PlaceBlock
End If
' Check if Block Can be Removed
Remove = 0
For Z = 1 To 4
For Y = 1 To 4
If Block(Z, Y) > 0 Then If Block(Z, Y) <> Player Then Remove = 1
Next
Next
RollDice:
X1 = 873: X2 = 270: For Z = 1 To 20: Dice = Int(Rnd * 6) + 1: X3 = Dice: GoSub DrawDice: _Delay .15: Next
' Display Dice Roll Message
If Dice = 5 Then
Color 15, 1: Locate 23, 97: Print " Choose a Piece to Swap ";
ElseIf Dice = 6 Then
Else
Color 15, 1: Locate 23, 97: Print " Choose a Piece to Rotate ";
End If
If Dice < 6 Then
ChoosePieceMouseInput:
If Dice = 1 Or Dice = 2 Then Color 15, 1: Locate 25, 97: Print " ";
If Dice = 3 Or Dice = 4 Then Color 15, 1: Locate 25, 97: Print " Rotating Piece"; Selected; "of 2 ";
If Dice = 5 And Selected = 1 Then Color 15, 1: Locate 25, 97: Print " Choose First Piece ";
If Dice = 5 And Selected = 2 Then Color 15, 1: Locate 25, 97: Print " Choose Second Piece ";
Do While _MouseInput
MouseX = _MouseX: MouseY = _MouseY: MouseLeftButton = _MouseButton(1)
For Z = 1 To 5
For Y = 1 To 5
If (MouseLeftButton = -1) * (MouseX > BoardX(Z, Y) - 60) * (MouseX < BoardX(Z, Y) + 60) * (MouseY > BoardY(Z, Y) - 60) * (MouseY < BoardY(Z, Y) + 60) Then
If Locked(Z, Y) = 0 Then Row = Z: Column = Y: GoSub ButtonReleased: GoTo EndChoice1
End If
Next
Next
Loop
GoTo ChoosePieceMouseInput
EndChoice1:
If Dice < 5 Then
Piece = BoardPiece(Row, Column): Rotation = BoardRotate(Row, Column)
If Dice = 1 Or Dice = 3 Then If Rotation = 4 Then Rotation = 1 Else Rotation = Rotation + 1
If Dice = 2 Or Dice = 4 Then If Rotation = 1 Then Rotation = 4 Else Rotation = Rotation - 1
T1 = BoardPiece(Row, Column): T2 = Rotation: BoardRotate(Row, Column) = Rotation
X1 = BoardX(Row, Column): X2 = BoardY(Row, Column): Rotate$ = Piece$(Piece, Rotation): GoSub DrawPiece
If Dice > 2 And Selected = 1 Then Selected = Selected + 1: GoTo ChoosePieceMouseInput
Else
If Selected = 1 Then Row1 = Row: Column1 = Column Else Row2 = Row: Column2 = Column
If GameBoard = 1 Then F1 = 0: F2 = 15 Else F1 = 15: F2 = 0
Line (BoardX(Row, Column) - 63, BoardY(Row, Column) - 63)-(BoardX(Row, Column) + 63, BoardY(Row, Column) + 63), F1, B
If Selected = 1 Then Selected = Selected + 1: GoTo ChoosePieceMouseInput
Swap BoardPiece(Row1, Column1), BoardPiece(Row2, Column2): Swap BoardRotate(Row1, Column1), BoardRotate(Row2, Column2)
T1 = BoardPiece(Row1, Column1): T2 = BoardRotate(Row1, Column1): Rotate$ = Piece$(T1, T2)
X1 = BoardX(Row1, Column1): X2 = BoardY(Row1, Column1): GoSub DrawPiece
T1 = BoardPiece(Row2, Column2): T2 = BoardRotate(Row2, Column2): Rotate$ = Piece$(T1, T2)
X1 = BoardX(Row2, Column2): X2 = BoardY(Row2, Column2): GoSub DrawPiece
Line (BoardX(Row1, Column1) - 63, BoardY(Row1, Column1) - 63)-(BoardX(Row1, Column1) + 63, BoardY(Row1, Column1) + 63), F2, B
Line (BoardX(Row2, Column2) - 63, BoardY(Row2, Column2) - 63)-(BoardX(Row2, Column2) + 63, BoardY(Row2, Column2) + 63), F2, B
End If
Else
If Remove = 0 Then
Color 15, 1: Locate 23, 97: Print " No Blocks to Ronove ";
Color 15, 1: Locate 25, 97: Print " Press <ENTER> to Continue ";
GetENTER2: A$ = InKey$: If A$ = "" GoTo GetENTER2 Else If Asc(A$) <> 13 GoTo GetENTER2
Color 15, 1: Locate 23, 97: Print " ";
Color 15, 1: Locate 25, 97: Print " ";
GoTo RollDice
End If
Color 15, 1: Locate 23, 97: Print " Choose a Block to Ronove ";
Color 15, 1: Locate 25, 97: Print " ";
RemoveBlockMouseInput:
Do While _MouseInput
MouseX = _MouseX: MouseY = _MouseY: MouseLeftButton = _MouseButton(1)
For Z = 1 To 4
For Y = 1 To 4
If (MouseLeftButton = -1) * (MouseX > BlockX(Z, Y) - 30) * (MouseX < BlockX(Z, Y) + 30) * (MouseY > BlockY(Z, Y) - 30) * (MouseY < BlockY(Z, Y) + 30) Then
If Block(Z, Y) = 0 Or Block(Z, Y) = Player GoTo RemoveBlockMouseInput
Row = Z: Column = Y: GoSub ButtonReleased: GoTo EndChoice2
End If
Next
Next
Loop
GoTo RemoveBlockMouseInput
EndChoice2:
F1 = Block(Row, Column): F2 = BoardColor(GameBoard, F1): Block(Row, Column) = 0
Locked(Row, Column) = 0: Locked(Row, Column + 1) = 0: Locked(Row + 1, Column) = 0: Locked(Row + 1, Column + 1) = 0
X3 = F1: Blocks(F1) = Blocks(F1) + 1: GoSub UpdateBlockStorage
Line (BlockX(Row, Column) - 30, BlockY(Row, Column) - 30)-(BlockX(Row, Column) + 30, BlockY(Row, Column) + 30), F2, BF
PSet (BlockX(Row, Column), BlockY(Row, Column)), 1: Draw Remove$(GameBoard): Remove = 0: GoTo EndTurn
End If
' Set Playable Moves to 0
For Z = 1 To 4: For Y = 1 To 4: Playable(Z, Y) = 0: Next: Next
' Check if Block Can be Placed
Block = 0
For Z = 1 To 4
For Y = 1 To 4
If Block(Z, Y) = 0 Then
T1 = BoardPiece(Z, Y): T2 = BoardRotate(Z, Y): Piece$ = Piece$(T1, T2): B1 = Val(Mid$(Piece$, 4, 1))
T1 = BoardPiece(Z, Y + 1): T2 = BoardRotate(Z, Y + 1): Piece$ = Piece$(T1, T2): B2 = Val(Mid$(Piece$, 3, 1))
T1 = BoardPiece(Z + 1, Y): T2 = BoardRotate(Z + 1, Y): Piece$ = Piece$(T1, T2): B3 = Val(Mid$(Piece$, 2, 1))
T1 = BoardPiece(Z + 1, Y + 1): T2 = BoardRotate(Z + 1, Y + 1): Piece$ = Piece$(T1, T2): B4 = Val(Mid$(Piece$, 1, 1))
If B1 = B2 And B2 = B3 And B3 = B4 And B1 = Player Then Block = 1: Playable(Z, Y) = B1
End If
Next
Next
' Block Can be Placed
If Block = 1 Then
Color 15, 1: Locate 23, 97: Print "You Have a Matching Pattern ";
Color 15, 1: Locate 25, 97: Print "Press <ENTER> to Place Block ";
GetENTER1: A$ = InKey$: If A$ = "" GoTo GetENTER1 Else If Asc(A$) <> 13 GoTo GetENTER1
GoSub PlaceBlock
End If
EndTurn:
X1 = 873: X2 = 270: Line (X1 - 35, X2 - 35)-(X1 + 35, X2 + 35), 1, BF
' Remove Messages
Color 15, 1: Locate 23, 97: Print " ";
Color 15, 1: Locate 25, 97: Print " ";
If Blocks(Player) = 0 Then Winner = Player: GoTo Winner
' Get Next Player
If Player = Players Then Player = 1 Else Player = Player + 1
GoTo StartGame
ButtonReleased:
Do While _MouseInput
If _MouseButton(1) = 0 Then Return
Loop
GoTo ButtonReleased
DrawPiece:
If GameBoard = 1 Then X5 = 0 Else X5 = 15
W3 = -60: W5 = 1
For W1 = 1 To 2
W4 = -60
For W2 = 1 To 2
X4 = BoardColor(GameBoard, Val(Mid$(Rotate$, W5, 1)))
Line (X1, X2)-(X1 + W4, X2 + W3), X4, BF
W4 = W4 + 120: W5 = W5 + 1
Next
W3 = W3 + 120
Next
Circle (X1, X2), 10, 15: Paint (X1, X2), 15
Line (X1 - 60, X2 - 60)-(X1 + 60, X2 + 60), X5, B
Return
CheckBlock:
B3 = 0: B = 0
T1 = BoardPiece(B1, B2): T2 = BoardRotate(B1, B2): Piece$ = Piece$(T1, T2): B11 = Val(Mid$(Piece$, 4, 1))
T1 = BoardPiece(B1, B2 + 1): T2 = BoardRotate(B1, B2 + 1): Piece$ = Piece$(T1, T2): B12 = Val(Mid$(Piece$, 3, 1))
T1 = BoardPiece(B1 + 1, B2): T2 = BoardRotate(B1 + 1, B2): Piece$ = Piece$(T1, T2): B13 = Val(Mid$(Piece$, 2, 1))
T1 = BoardPiece(B1 + 1, B2 + 1): T2 = BoardRotate(B1 + 1, B2 + 1): Piece$ = Piece$(T1, T2): B14 = Val(Mid$(Piece$, 1, 1))
If B11 = B12 And B12 = B13 And B13 = B14 Then
If Block(B1, B2) = 0 Then
If Setup = 1 Then SetUpBlock = 1
If B11 = Player Then Block = 1: HasBlock(B11) = 1: Playable(B1, B2) = B11
End If
If Block(B1, B2) > 0 Then If Block(B1, B2) = Player Then Remove = 0 Else If Block(B1, B2) <> Player Then Remove = 1
End If
Return
UpdateBlockStorage:
Line (765, 420)-(985, 720), 1, BF
X2 = 450
For Z1 = 1 To Players
If Blocks = 2 Then X1 = 838 Else X1 = 795
For Z2 = 1 To Blocks(Z1)
X3 = Z1: GoSub DrawBlock
X1 = X1 + 80
Next
X2 = X2 + 80
Next
Return
PlaceBlock:
For Z = 1 To 4
For Y = 1 To 4
If Playable(Z, Y) = Player And Block(Z, Y) = 0 Then
Locked(Z, Y) = 1: Locked(Z, Y + 1) = 1: Locked(Z + 1, Y) = 1: Locked(Z + 1, Y + 1) = 1
Blocks(Player) = Blocks(Player) - 1: GoSub UpdateBlockStorage: Playable(Z, Y) = 0
Block(Z, Y) = Player: X1 = BlockX(Z, Y): X2 = BlockY(Z, Y): X3 = Player: GoSub DrawBlock
End If
Next
Next
Return
DrawBlock:
For C = 1 To 2
If C = 1 Then C1 = 11: C2 = 11 Else C1 = 0: C2 = PlayerColor(GameBoard, X3)
Line (X1 - 20, X2 - 30)-(X1 + 20, X2 - 30), C1
Line (X1 - 20, X2 + 30)-(X1 + 20, X2 + 30), C1
Line (X1 - 30, X2 - 20)-(X1 - 30, X2 + 20), C1
Line (X1 + 30, X2 - 20)-(X1 + 30, X2 + 20), C1
Circle (X1 - 20, X2 - 20), 10, C1, 1.5, 3.1
Circle (X1 + 20, X2 - 20), 10, C1, 0, 1.7
Circle (X1 - 20, X2 + 20), 10, C1, 3.1, 4.8
Circle (X1 + 20, X2 + 20), 10, C1, 4.6, 0
Paint (X1, X2), C2, C1
Next
Return
DrawDice:
Line (X1 - 35, X2 - 35)-(X1 + 35, X2 + 35), 1, BF
Line (X1 - 25, X2 - 35)-(X1 + 25, X2 - 35), 0
Line (X1 - 25, X2 + 35)-(X1 + 25, X2 + 35), 0
Line (X1 - 35, X2 - 25)-(X1 - 35, X2 + 25), 0
Line (X1 + 35, X2 - 25)-(X1 + 35, X2 + 25), 0
Circle (X1 - 25, X2 - 25), 10, 0, 1.5, 3.1
Circle (X1 + 25, X2 - 25), 10, 0, 0, 1.7
Circle (X1 - 25, X2 + 25), 10, 0, 3.1, 4.8
Circle (X1 + 25, X2 + 25), 10, 0, 4.6, 0
Paint (X1, X2), 15, 0
If X3 < 5 Then
Circle (X1, X2 - 3), 17, 0: Paint (X1, X2 - 3), 0: Circle (X1, X2 - 3), 15, 15: Paint (X1, X2 - 3), 15
If X3 = 1 Or X3 = 3 Then Line (X1 + 20, X2 - 3)-(X1, X2 - 25), 15, BF: PSet (X1, X2 - 17), 0: Draw "U10F8G8U10BR3P0,0"
If X3 = 2 Or X3 = 4 Then Line (X1 - 20, X2 - 3)-(X1, X2 - 25), 15, BF: PSet (X1, X2 - 17), 0: Draw "U10G8F8U10BL3P0,0"
Color 0, 15: Locate 19, 109: If X3 < 3 Then Print "1x"; Else Print "2x";
End If
If X3 = 5 Then PSet (X1, X2 + 10), 0: Draw "NU40R20U20NL40BG5P0,0E5U20L40D20BE5P0,0G5D20R20BD7NL15R20D1L35D5H5E5D5BL2P0,0BL3BD7R35D1NL35D5E5H5D5BR2P0,0"
If X3 = 6 Then PSet (X1, X2 - 5), 2: Draw "E15R15G20F20L15H15G15L15E20H20R15F15BD5P2,2BL18BU8C0D25R25U25L25E10R25NG10D25G10"
Return
Winner:
X1 = 873: X2 = 100: X3 = Winner: GoSub DrawBlock
Color 15, 1: Locate 10, 106: Print "Player:"; Winner;
Color 15, 1: Locate 23, 97: Print " Player"; Winner; "is the Winner! ";
Color 15, 1: Locate 25, 97: Print "Play Another Game? (Y or N) ";
GetYorN: A$ = UCase$(InKey$): If A$ = "" GoTo GetYorN
If A$ = "Y" Then Run
If A$ = "N" Then System
If Asc(A$) <> 13 GoTo GetYorN
|
|
|
Quixo |
Posted by: SMcNeill - 12-23-2023, 11:43 PM - Forum: Donald Foster
- No Replies
|
|
Quote:Hello All,
Quixo is a 2 player abstract board game played with 25 woodeb cube blocks arranged in a 5 X 5 square with the blank sides of the cube facing up. Player 1 is the X on 1 side of the cube and player 2 is the O on the other side. There are 4 blank sides which are neutral sides.
The object of the game is to get 5 pieces in a row with your side facing up, horizontal, vertical or diagnol.
How to play:
On your turn, pick uo 1 of the blocks on 1 of the sides with your symbol or the neutral piece pattern facing up and remove it form it's location. Then place that block with your symbol facing up on 1 of the opposite sides of the board by clicking on 1 of the arrows that will appear on the outside of the board pointing to a piece that will push that your piece into the row of pieces and causing that row to shift their position to the next location until the empty location, where you took your piece from, is filled. Arrow appear to show your legal moves. you are not allowed to place the piece back where you just took it from and your not allowed to pick up a pieces with you opponent's symbol on top.
You win by getting 5 pieces of your symbol in a row, how if on your move you shift your opponents pieces and causes them to get 5 of their pieces facing up in a row, they win the game even if you made a 5 in a row for yourself also.
Hope you enjoy playing,
Donald
Code: (Select All)
_Title "QUIXO - Designed by Thierry Chapeau 1995 - Programmed by Donald L. Foster Jr. 2017"
Screen _NewImage(1025, 735, 256)
_PaletteColor 1, _RGB32(109, 39, 0) ' background
_PaletteColor 2, _RGB32(205, 134, 66) ' LT Square
_PaletteColor 3, _RGB32(184, 104, 36) ' MED Piece
_PaletteColor 4, _RGB32(154, 74, 6) ' DK Piece
DefInt A-Z
Player = 1: Opponant = 2: Move = 0
Arrow$ = "BU25C15L15D25L15F30E30L15U25L15BD10P0,15"
B$(1) = "TA0": B$(2) = "TA90": B$(3) = "TA180": B$(4) = "TA270"
Line (0, 0)-(1025, 735), 1, BF
' Draw Board
X = 0
For Z = 1 To 7
W = 0
For Y = 1 To 7
Line (55 - 51 + W, 55 - 51 + X)-(55 + 51 + W, 55 + 51 + X), 1, B
Board(Z, Y) = 0: X1 = 55 + W: X2 = 55 + X: X3 = 0
If Z > 1 And Z < 7 And Y > 1 And Y < 7 Then Board(Z, Y) = 2: BoardPlayer(Z, Y) = 0: GoSub DrawPiece
If Z = 2 And Y > 1 And Y < 7 Then X3 = 1: Board(Z, Y) = 1
If Y = 2 And Z > 1 And Z < 7 Then X3 = 2: Board(Z, Y) = 1
If Z = 6 And Y > 1 And Y < 7 Then X3 = 3: Board(Z, Y) = 1
If Y = 6 And Z > 1 And Z < 7 Then X3 = 4: Board(Z, Y) = 1
BoardX(Z, Y) = 55 + W: BoardY(Z, Y) = 55 + X
W = W + 104
Next
X = X + 104
Next
Color 15, 1: Locate 2, 100: Print "Q U I X O";
StartGame:
' Draw Player Indicator
X1 = 873: X2 = 159: X3 = Player: GoSub DrawPiece
Color 15, 1: Locate 15, 106: Print "Player:"; Player;
Color 15, 1: Locate 45, 97: Print " Choose a Piece to Remove ";
ChooseALocationMouseInput:
Do While _MouseInput
MouseX = _MouseX: MouseY = _MouseY: MouseLeftButton = _MouseButton(1)
For Z = 1 To 7
For Y = 1 To 7
If (MouseLeftButton = -1) * (MouseX > BoardX(Z, Y) - 51) * (MouseX < BoardX(Z, Y) + 51) * (MouseY > BoardY(Z, Y) - 51) * (MouseY < BoardY(Z, Y) + 51) Then
If Board(Z, Y) = 1 And BoardPlayer(Z, Y) <> Opponant Then Row = Z: Column = Y: GoTo EndChoice1
End If
Next
Next
Loop
GoTo ChooseALocationMouseInput
EndChoice1:
' Remove Piece from Board
Line (BoardX(Z, Y) - 51, BoardY(Z, Y) - 51)-(BoardX(Z, Y) + 51, BoardY(Z, Y) + 51), 1, BF
' Draw Piece Under Indicator
X1 = 873: X2 = 367: X3 = Player: GoSub DrawPiece
' Set Arrows to 0
For Z = 2 To 6: Arrow(1, Z) = 0: Arrow(7, Z) = 0: Arror(Z, 1) = 0: Arrow(Z, 7) = 0: Next
' Get Arrows
If Row = 2 And Column = 2 Then Arrow(2, 7) = 4: Arrow(7, 2) = 3: GoTo DrawArrows
If Row = 2 And Column = 6 Then Arrow(2, 1) = 2: Arrow(7, 6) = 3: GoTo DrawArrows
If Row = 6 And Column = 2 Then Arrow(6, 7) = 4: Arrow(1, 2) = 1: GoTo DrawArrows
If Row = 6 And Column = 6 Then Arrow(6, 1) = 2: Arrow(1, 6) = 1: GoTo DrawArrows
If Row = 2 Then Arrow(2, 1) = 2: Arrow(2, 7) = 4: Arrow(7, Column) = 3
If Row = 6 Then Arrow(6, 1) = 2: Arrow(6, 7) = 4: Arrow(1, Column) = 1
If Column = 2 Then Arrow(1, 2) = 1: Arrow(7, 2) = 3: Arrow(Row, 7) = 4
If Column = 6 Then Arrow(1, 6) = 1: Arrow(7, 6) = 3: Arrow(Row, 1) = 2
DrawArrows:
For Z = 1 To 7
For Y = 1 To 7
If Arrow(Z, Y) > 0 Then X1 = BoardX(Z, Y): X2 = BoardY(Z, Y): X3 = Arrow(Z, Y): GoSub DrawArrow
Next
Next
' Choose Arrow
Color 15, 1: Locate 45, 97: Print "Choose Arrow to Place Piece";
GetArrowInput:
Do While _MouseInput
MouseX = _MouseX: MouseY = _MouseY: MouseLeftButton = _MouseButton(1)
For Z = 1 To 7
For Y = 1 To 7
If (Arrow(Z, Y) > 0) * (MouseX > BoardX(Z, Y) - 40) * (MouseX < BoardX(Z, Y) + 40) * (MouseY > BoardY(Z, Y) - 40) * (MouseY < BoardY(Z, Y) + 40) Then
CanSelect = 1: Line (BoardX(Z, Y) - 40, BoardY(Z, Y) - 40)-(BoardX(Z, Y) + 40, BoardY(Z, Y) + 40), 15, B
ElseIf Board(Z, Y) = 0 Then
CanSelect = 0: Line (BoardX(Z, Y) - 40, BoardY(Z, Y) - 40)-(BoardX(Z, Y) + 40, BoardY(Z, Y) + 40), 1, B
End If
If MouseLeftButton = -1 And CanSelect = 1 Then Row2 = Z: Column2 = Y: Arrow = Arrow(Z, Y): GoTo EndChoice2
Next
Next
Loop
GoTo GetArrowInput
EndChoice2:
' Shift Pieces on Board
If Arrow = 1 Then
X = 0
Arrow1: If Row - X - 1 = 1 Then W1 = 2: W2 = Column: GoTo MovePieceToBoard
BoardPlayer(Row - X, Column) = BoardPlayer(Row - X - 1, Column)
X1 = BoardX(Row - X, Column): X2 = BoardY(Row - X, Column): X3 = BoardPlayer(Row - X, Column): GoSub DrawPiece: X = X + 1: GoTo Arrow1
End If
If Arrow = 2 Then
X = 0
Arrow2: If Column - X - 1 = 1 Then W1 = Row: W2 = 2: GoTo MovePieceToBoard
BoardPlayer(Row, Column - X) = BoardPlayer(Row, Column - X - 1)
X1 = BoardX(Row, Column - X): X2 = BoardY(Row, Column - X): X3 = BoardPlayer(Row, Column - X): GoSub DrawPiece: X = X + 1: GoTo Arrow2
End If
If Arrow = 3 Then
X = 0
Arrow3: If Row + X + 1 = 7 Then W1 = 6: W2 = Column: GoTo MovePieceToBoard
BoardPlayer(Row + X, Column) = BoardPlayer(Row + X + 1, Column)
X1 = BoardX(Row + X, Column): X2 = BoardY(Row + X, Column): X3 = BoardPlayer(Row + X, Column): GoSub DrawPiece: X = X + 1: GoTo Arrow3
End If
If Arrow = 4 Then
X = 0
Arrow4: If Column + X + 1 = 7 Then W1 = Row: W2 = 6: GoTo MovePieceToBoard
BoardPlayer(Row, Column + X) = BoardPlayer(Row, Column + X + 1)
X1 = BoardX(Row, Column + X): X2 = BoardY(Row, Column + X): X3 = BoardPlayer(Row, Column + X): GoSub DrawPiece: X = X + 1: GoTo Arrow4
End If
MovePieceToBoard:
Line (822, 316)-(924, 418), 1, BF
BoardPlayer(W1, W2) = Player: X1 = BoardX(W1, W2): X2 = BoardY(W1, W2): X3 = Player: GoSub DrawPiece
' Remove Arrows
For Z = 1 To 7
For Y = 1 To 7
If Arrow(Z, Y) > 0 Then Arrow(Z, Y) = 0: Line (BoardX(Z, Y) - 51, BoardY(Z, Y) - 51)-(BoardX(Z, Y) + 51, BoardY(Z, Y) + 51), 1, BF
Next
Next
' Check for Winner
Winner = 0: Winner(1) = 0: Winner(2) = 0
For Z = 2 To 6
If BoardPlayer(Z, 2) = BoardPlayer(Z, 3) And BoardPlayer(Z, 3) = BoardPlayer(Z, 4) And BoardPlayer(Z, 4) = BoardPlayer(Z, 5) And BoardPlayer(Z, 5) = BoardPlayer(Z, 6) Then Winner(BoardPlayer(Z, 2)) = 1
If BoardPlayer(2, Z) = BoardPlayer(3, Z) And BoardPlayer(3, Z) = BoardPlayer(4, Z) And BoardPlayer(4, Z) = BoardPlayer(5, Z) And BoardPlayer(5, Z) = BoardPlayer(6, Z) Then Winner(BoardPlayer(2, Z)) = 1
Next
If BoardPlayer(2, 2) = BoardPlayer(3, 3) And BoardPlayer(3, 3) = BoardPlayer(4, 4) And BoardPlayer(4, 4) = BoardPlayer(5, 5) And BoardPlayer(5, 5) = BoardPlayer(6, 6) Then Winner(BoardPlayer(Z, 2)) = 1
If BoardPlayer(2, 6) = BoardPlayer(3, 5) And BoardPlayer(3, 5) = BoardPlayer(4, 4) And BoardPlayer(4, 4) = BoardPlayer(5, 3) And BoardPlayer(5, 3) = BoardPlayer(6, 2) Then Winner(BoardPlayer(2, 6)) = 1
' Is there a Winner?
If Winner(Opponant) = 1 Then Winner = Opponant Else If Winner(Player) Then Winner = Player
If Winner > 0 Then GoTo Winner
Swap Player, Opponant: GoTo StartGame
DrawPiece:
Line (X1 - 51, X2 - 51)-(X1 + 51, X2 + 51), 1, BF: V = 3
Line (X1 - 41, X2 - 51)-(X1 + 41, X2 - 51), 3
Line (X1 - 51, X2 - 41)-(X1 - 51, X2 + 41), 3
Line (X1 - 41, X2 + 51)-(X1 + 41, X2 + 51), 3
Line (X1 + 51, X2 - 41)-(X1 + 51, X2 + 41), 3
Circle (X1 - 41, X2 - 41), 10, 3, 1.5, 3.1
Circle (X1 - 41, X2 + 41), 10, 3, 3.1, 4.8
Circle (X1 + 41, X2 + 41), 10, 3, 4.6, 0
Circle (X1 + 41, X2 - 41), 10, 3, 0, 1.7
PSet (X1 - 41, X2 - 41), 3: Draw "TA0D83NG6R83U83NE6L83BL5BD10P2,3BR45P3,3BR48P4,3"
If X3 = 1 Then
Circle (X1 - 94, X2 - 94), 140, 0, 5.17, 5.82: Circle (X1 + 94, X2 + 94), 140, 0, 2.02, 2.68: Paint (X1, X2), 0
Circle (X1 - 94, X2 + 94), 140, 0, .46, 1.11: Circle (X1 + 94, X2 - 94), 140, 0, 3.6, 4.26: Paint (X1 - 20, X2 - 20), 0: Paint (X1 + 20, X2 + 20), 0
PSet (X1, X2 + 23), 0: Draw "TA0G5F5E5H5BD3P0,0"
ElseIf X3 = 2 Then
Circle (X1, X2), 34, 0: Circle (X1, X2), 31, 0, , , 1.4: Paint (X1 + 28, X2), 0
Circle (X1, X2 + 22), 5, 0: Paint (X1, X2 + 22), 0
End If
Return
DrawArrow:
PSet (X1, X2), 1: Draw B$(X3) + Arrow$
Return
Winner:
X1 = 873: X2 = 159: X3 = Winner: GoSub DrawPiece
Color 15, 1: Locate 15, 106: Print "Player:"; Winner;
Color 15, 1: Locate 43, 97: Print " Player"; Winner; "is the Winner! ";
Color 15, 1: Locate 45, 97: Print " Play Another Game? Y or N ";
GetYesNo: A$ = UCase$(InKey$): If A$ = "" GoTo GetYesNo
If A$ = "Y" Then Run
If A$ = "N" Then System
GoTo GetYesNo
|
|
|
Barragoon Board Game |
Posted by: SMcNeill - 12-23-2023, 11:41 PM - Forum: Donald Foster
- No Replies
|
|
Quote:Hello All,
Barragoon is a 2 player board game. This is a very complex game and you will need to read the all the rules carefully. I have included a copy of the rules.
Hope you enjoy playing.
Donald
Barragoon Rules.pdf (Size: 2.94 MB / Downloads: 59)
Code: (Select All)
_TITLE "Barragoon by Robert Witter and Frank Warneke - Programmed by Donald L. Foster Jr. 2017"
_Limit 50
Screen _NewImage(1210, 737, 256)
_PaletteColor 2, _RGB32(89, 19, 0) ' Board Seporator
_PaletteColor 3, _RGB32(225, 201, 165) ' Board Light Square
_PaletteColor 4, _RGB32(192, 154, 105) ' Board Dark Square
_PaletteColor 5, _RGB32(100, 100, 100) ' Barragon Top
_PaletteColor 6, _RGB32(135, 111, 75) ' Barragoon Sides
_PaletteColor 7, _RGB32(255, 255, 255) ' White Tile Top
_PaletteColor 8, _RGB32(115, 85, 55) ' White Tile Side
_PaletteColor 9, _RGB32(190, 85, 10) ' Brown Tile Top
_PaletteColor 10, _RGB32(255, 0, 0) ' Brown Tile Side
Player = 1: Opponant = 2
Tiles(1) = 7: Tiles(2) = 7
Barragoon(1, 5) = 1: Barragoon(2, 4) = 1: Barragoon(2, 6) = 1: Barragoon(3, 5) = 1: Barragoon(5, 5) = 1: Barragoon(6, 4) = 1: Barragoon(6, 6) = 1: Barragoon(7, 5) = 1
Rotation(1, 5) = 1: Rotation(2, 4) = 1: Rotation(2, 6) = 1: Rotation(3, 5) = 1: Rotation(5, 5) = 1: Rotation(6, 4) = 1: Rotation(6, 6) = 1: Rotation(7, 5) = 1
Rotate(1) = 1: Rotate(2) = 4: Rotate(3) = 2: Rotate(4) = 4: Rotate(5) = 4: Rotate(6) = 1
TileColor(2, 1) = 1: TileColor(3, 1) = 1: TileColor(3, 2) = 1: TileColor(4, 2) = 1: TileColor(5, 1) = 1: TileColor(5, 2) = 1: TileColor(6, 1) = 1
TileColor(2, 9) = 2: TileColor(3, 8) = 2: TileColor(3, 9) = 2: TileColor(4, 8) = 2: TileColor(5, 9) = 2: TileColor(5, 8) = 2: TileColor(6, 9) = 2
TilePiece(2, 1) = 4: TilePiece(3, 1) = 3: TilePiece(3, 2) = 2: TilePiece(4, 2) = 3: TilePiece(5, 1) = 3: TilePiece(5, 2) = 2: TilePiece(6, 1) = 4
TilePiece(2, 9) = 4: TilePiece(3, 9) = 3: TilePiece(3, 8) = 2: TilePiece(4, 8) = 3: TilePiece(5, 9) = 3: TilePiece(5, 8) = 2: TilePiece(6, 9) = 4
Arrow$ = "BH4BU2BL1C15E1U8R2H4G4R2D7L7U2G4F4U2R8E1BH1P15,15BF7"
Barragoon$(1, 1) = "BL3C15H12E4F11E11F4G11F11G4H11G11H4E11BR5P15,15"
Barragoon$(2, 1) = "BD16C15L3U25L6E9F9L6D25L4BU5P15,15"
Barragoon$(2, 2) = "BL16C15U3R25U6F9G9U6L25U4BR5P15,15"
Barragoon$(2, 3) = "BU16C15R3D25R6G9H9R6U25R4BD5P15,15"
Barragoon$(2, 4) = "BR16C15D3L25D6H9E9D6R25D4BL5P15,15"
Barragoon$(3, 2) = "BL3C15U8L6E9F9L6D16R6G9H9R6U8BR3P15,15"
Barragoon$(3, 1) = "BU3C15R8U6F9G9U6L16D6H9E9D6R8BD3P15,15"
Barragoon$(4, 1) = "BL6BU3C15R12D6E9H9D6L18D24R6U18BU3P15,15"
Barragoon$(4, 2) = "BU6BR3C15D12L6F9E9L6U18L24D6R18BR3P15,15"
Barragoon$(4, 3) = "BR6BD3C15L12U6G9F9U6R18U24L6D18BD3P15,15"
Barragoon$(4, 4) = "BD6BL3C15U12R6H9G9R6D18R24U6L18BL3P15,15"
Barragoon$(5, 1) = "BR6BU3C15L12D6H9E9D6R18D24L6U18BU3P15,15"
Barragoon$(5, 2) = "BU6BL3C15D12R6G9H9R6U18R24D6L18BL3P15,15"
Barragoon$(5, 3) = "BD3BL6C15R12U6F9G9U6L18U24R6D18BD3P15,15"
Barragoon$(5, 4) = "BD6BR3C15U12L6E9F9L6D18L24U6R18BR3P15,15"
Barragoon$(6, 1) = "TA0" + Arrow$ + "TA90" + Arrow$ + "TA180" + Arrow$ + "TA270" + Arrow$
YesNo$(1) = "Yes": YesNo$(2) = " No "
' Setup Background
Line (0, 0)-(1210, 737), 1, BF
Color 15, 1: Locate 2, 122: Print "B A R R A G O O N";
' Setup Instruction Button
Line (1005, 695)-(1130, 725), 15, BF
Color 0, 15: Locate 45, 129: Print "Game Rules";
' Draw Board
Line (11, 11)-(917, 725), 3, BF: Line (29, 29)-(899, 707), 2, BF
X = 0
For Z = 1 To 7
V = 0
For Y = 1 To 9
If (Z + Y) / 2 = Fix((Z + Y) / 2) Then U = 4 Else U = 3
Line (80 - 46 + V, 80 - 46 + X)-(80 + 46 + V, 80 + 46 + X), U, BF
If TilePiece(Z, Y) > 0 Then X1 = 80 + V: X2 = 80 + X: X3 = TileColor(Z, Y): X4 = TilePiece(Z, Y): X5 = U: GoSub DrawTile
If Barragoon(Z, Y) > 0 Then X1 = 80 + V: X2 = 80 + X: X3 = Barragoon(Z, Y): X4 = Rotation(Z, Y): GoSub DrawBarragoon
BoardX(Z, Y) = 80 + V: BoardY(Z, Y) = 80 + X
V = V + 96
Next
X = X + 96
Next
' Ask if players want alternative setup for Barragoon pieces.
Color 15, 1: Locate 13, 125: Print "Alternative Setup?";
' Setup Yes and No Buttons.
X = 0: V = 0
For Z = 1 To 2
Line (1005, 280 + X)-(1130, 310 + X), 15, BF
Color 0, 15: Locate 19 + V, 133: Print YesNo$(Z);
VariationY(Z) = 280 + X
X = X + 80: V = V + 5
Next
' Get Mouse Input for Buttons and Game Rules Button.
AlternativeSetup:
Do While _MouseInput
MouseX = _MouseX: MouseY = _MouseY: MouseLeftButton = _MouseButton(1)
If (MouseLeftButton = -1) * (MouseX > 1005) * (MouseX < 1130) * (MouseY > 695) * (MouseY < 725) Then GoSub ReleaseMouseButton: Shell "Barragoon Rules.pdf"
For Z = 1 To 2
If (MouseLeftButton = -1) * (MouseX > 1005) * (MouseX < 1130) * (MouseY > VariationY(Z) - 1) * (MouseY < VariationY(Z) + 31) Then Alternative = Z: GoTo EndChoice1
Next
Loop
GoTo AlternativeSetup
EndChoice1:
Line (1005, 280)-(1130, 390), 1, BF
' If Alternative Setup, change Barragoons to All Turn.
If Alternative = 1 Then
For Z = 1 To 7
For Y = 1 To 9
If Barragoon(Z, Y) = 1 Then Barragoon(Z, Y) = 6: X1 = BoardX(Z, Y): X2 = BoardY(Z, Y): X3 = 6: X4 = 1: GoSub DrawBarragoon
Next
Next
End If
StartGame:
' Draw Player Indicator
X1 = 1067: X2 = 100: X3 = Player: X4 = 2: X5 = 1: GoSub DrawTile
Color 15, 1: Locate 10, 130: Print "Player:"; Player;
' Check for Can't Play
X = 0
For Z = 1 To 7
For Y = 1 To 9
If TileColor(Z, Y) = Player Then X1 = Z: X2 = Y: Piece = TilePiece(Z, Y): On Piece GOSUB Piece1, Piece2, Piece3, Piece4
Next
Next
' Player Has No Playable Moves, Declare Opponant Winner
If X = 0 Then
Color 15, 1: Locate 13, 121: Print " You Have No Legal Moves ";
Color 15, 1: Locate 15, 121: Print " Press <ENTER> To Continue ";
GetENTER: A$ = InKey$: If A$ = "" GoTo GetENTER
If Asc(A$) <> 13 GoTo GetENTER
Winner = Opponant: GoTo Winner
End If
' Set All Playable Locations to 0
For Z = 1 To 7: For Y = 1 To 9: Playable(Z, Y) = 0: Next: Next
Capture = 0: Barragoon = 0
Color 15, 1: Locate 13, 121: Print " Choose A Piece To Move ";
' Get Choose a Piece to Move Mouse Input and Game Rules Button.
ChooseAPieceMouseInput:
Do While _MouseInput
MouseX = _MouseX: MouseY = _MouseY: MouseLeftButton = _MouseButton(1)
If (MouseLeftButton = -1) * (MouseX > 1005) * (MouseX < 1130) * (MouseY > 695) * (MouseY < 725) Then GoSub ReleaseMouseButton: Shell "Barragoon Rules.pdf"
For Z = 1 To 7
For Y = 1 To 9
If (MouseLeftButton = -1) * (MouseX > BoardX(Z, Y) - 47) * (MouseX < BoardX(Z, Y) + 47) * (MouseY > BoardY(Z, Y) - 47) * (MouseY < BoardY(Z, Y) + 47) Then
If TileColor(Z, Y) = Player Then Row1 = Z: Column1 = Y: Piece = TilePiece(Z, Y): GoTo EndChoice2
End If
Next
Next
Loop
GoTo ChooseAPieceMouseInput
EndChoice2:
' Check for Playable Moves
X = 0: X1 = Row1: X2 = Column1: On Piece GOSUB Piece1, Piece2, Piece3, Piece4
' Is Move Playable?
If X = 0 GoTo ChooseAPieceMouseInput
' Highlight Selected Square
Paint (BoardX(Row1, Column1), BoardY(Row1, Column1) + 40), 6, 2
' Highlight Playable Squares
For Z = 1 To 7
For Y = 1 To 9
If Playable(Z, Y) = 1 Then Paint (BoardX(Z, Y), BoardY(Z, Y) + 40), 8, 2
Next
Next
Color 15, 1: Locate 13, 121: Print "Choose A Location To Move To";
' Get Choose a Piece to Move Mouse Input and Game Rules Button.
ChooseALocationMouseInput:
Do While _MouseInput
MouseX = _MouseX: MouseY = _MouseY: MouseLeftButton = _MouseButton(1)
If (MouseLeftButton = -1) * (MouseX > 1005) * (MouseX < 1130) * (MouseY > 695) * (MouseY < 725) Then GoSub ReleaseMouseButton: Shell "Barragoon Rules.pdf"
For Z = 1 To 7
For Y = 1 To 9
If (MouseLeftButton = -1) * (MouseX > BoardX(Z, Y) - 47) * (MouseX < BoardX(Z, Y) + 47) * (MouseY > BoardY(Z, Y) - 47) * (MouseY < BoardY(Z, Y) + 47) Then
If Playable(Z, Y) = 1 Then Row2 = Z: Column2 = Y: GoTo EndChoice3
End If
Next
Next
Loop
GoTo ChooseALocationMouseInput
EndChoice3:
' Remove Playable Squares
For Z = 1 To 7
For Y = 1 To 9
If (Z + Y) / 2 = Fix((Z + Y) / 2) Then U = 4 Else U = 3
If Playable(Z, Y) = 1 Then Playable(Z, Y) = 0: Paint (BoardX(Z, Y), BoardY(Z, Y) + 40), U, 2
Next
Next
' Remove Selected Piece
If (Row1 + Column1) / 2 = Fix((Row1 + Column1) / 2) Then U = 4 Else U = 3
Line (BoardX(Row1, Column1) - 46, BoardY(Row1, Column1) - 46)-(BoardX(Row1, Column1) + 46, BoardY(Row1, Column1) + 46), U, BF
' Check for Capture or Barragoon at New Square
If TileColor(Row2, Column2) = Opponant Then Capture = 1: Tiles(Opponant) = Tiles(Opponant) - 1
If Barragoon(Row2, Column2) > 0 Then Barragoon = 1
' Move Piece to New Square
TileColor(Row2, Column2) = Player: TilePiece(Row2, Column2) = Piece
Barragoon(Row2, Column2) = 0: Rotation(Row2, Column2) = 0
TileColor(Row1, Column1) = 0: TilePiece(Row1, Column1) = 0
' Draw Player's Tile at New Square
If (Row2 + Column2) / 2 = Fix((Row2 + Column2) / 2) Then X5 = 4 Else X5 = 3
X1 = BoardX(Row2, Column2): X2 = BoardY(Row2, Column2): X3 = Player: X4 = Piece: GoSub DrawTile
' Check for Barragoon Placement
BarragoonPlayer = 0
If Barragoon = 1 Then BarragoonPlayer = Player
If Capture = 1 Then BarragoonPlayer = Opponant
' No Barragoons Needs to be Placed
If BarragoonPlayer = 0 GoTo CheckWinner
ChooseBarragoonPiece:
' Draw Player Indicator
X1 = 1067: X2 = 100: X3 = BarragoonPlayer: X4 = 2: X5 = 1: GoSub DrawTile
Color 15, 1: Locate 10, 130: Print "Player:"; BarragoonPlayer;
Color 15, 1: Locate 13, 121: Print " Choose A Barragoon ";
' Draw Barragoon List
W = 0
For Z = 1 To 6
X1 = 1067: X2 = 250 + W: X3 = Z: X4 = 1: X5 = 1: GoSub DrawBarragoon
BarragoonY(Z) = 250 + W: W = W + 80
Next
' Get Barragoon Piece Input
ChooseBarragoonMouseInput:
Do While _MouseInput
MouseX = _MouseX: MouseY = _MouseY: MouseLeftButton = _MouseButton(1)
If (MouseLeftButton = -1) * (MouseX > 1005) * (MouseX < 1130) * (MouseY > 695) * (MouseY < 725) Then GoSub ReleaseMouseButton: Shell "Barragoon Rules.pdf"
For Z = 1 To 6
If (MouseX > 1032) * (MouseX < 1102) * (MouseY > BarragoonY(Z) - 35) * (MouseY < BarragoonY(Z) + 35) Then
CanSelect = 1: Line (1032, BarragoonY(Z) - 35)-(1102, BarragoonY(Z) + 35), 15, B
Else
CanSelect = 0: Line (1032, BarragoonY(Z) - 35)-(1102, BarragoonY(Z) + 35), 1, B
End If
If (MouseLeftButton = -1) * (CanSelect = 1) Then BarragoonPiece = Z: GoSub ReleaseMouseButton: GoTo EndChoice4
Next
Loop
GoTo ChooseBarragoonMouseInput
EndChoice4:
' Skip Get Rotation if Barragoon only has 1 Rotation
If Rotate(BarragoonPiece) = 1 Then BarragoonRotation = 1: GoTo ChooseLocation
' Remove Barragoon Pieces List
Line (1032, 215)-(1102, 685), 1, BF
Color 15, 1: Locate 13, 121: Print " Choose A Rotation ";
' Draw Barragoon Rotations
W = 0
For Z = 1 To Rotate(BarragoonPiece)
X1 = 1067: X2 = 250 + W: X3 = BarragoonPiece: X4 = Z: X5 = 1: GoSub DrawBarragoon
BarragoonY(Z) = 250 + W: W = W + 80
Next
' Get Barragoon Rotation Input
ChooseRotationMouseInput:
Do While _MouseInput
MouseX = _MouseX: MouseY = _MouseY: MouseLeftButton = _MouseButton(1)
If (MouseLeftButton = -1) * (MouseX > 1005) * (MouseX < 1130) * (MouseY > 695) * (MouseY < 725) Then GoSub ReleaseMouseButton: Shell "Barragoon Rules.pdf"
For Z = 1 To Rotate(BarragoonPiece)
If (MouseX > 1032) * (MouseX < 1102) * (MouseY > BarragoonY(Z) - 35) * (MouseY < BarragoonY(Z) + 35) Then
CanSelect = 1: Line (1032, BarragoonY(Z) - 35)-(1102, BarragoonY(Z) + 35), 15, B
Else
CanSelect = 0: Line (1032, BarragoonY(Z) - 35)-(1102, BarragoonY(Z) + 35), 1, B
End If
If (MouseLeftButton = -1) * (CanSelect = 1) Then BarragoonRotation = Z: GoSub ReleaseMouseButton: GoTo EndChoice5
Next
Loop
GoTo ChooseRotationMouseInput
EndChoice5:
ChooseLocation:
Color 15, 1: Locate 13, 121: Print " Choose A Location ";
' Get Choose a Piece to Move Mouse Input and Game Rules Button.
ChooseALocationMouseInput2:
Do While _MouseInput
MouseX = _MouseX: MouseY = _MouseY: MouseLeftButton = _MouseButton(1)
If (MouseLeftButton = -1) * (MouseX > 1005) * (MouseX < 1130) * (MouseY > 695) * (MouseY < 725) Then GoSub ReleaseMouseButton: Shell "Barragoon Rules.pdf"
For Z = 1 To 7
For Y = 1 To 9
If (MouseLeftButton = -1) * (MouseX > BoardX(Z, Y) - 47) * (MouseX < BoardX(Z, Y) + 47) * (MouseY > BoardY(Z, Y) - 47) * (MouseY < BoardY(Z, Y) + 47) Then
If (TileColor(Z, Y) = 0) * (Barragoon(Z, Y) = 0) Then Row2 = Z: Column2 = Y: Selected = 1: GoTo EndChoice6
End If
Next
Next
Loop
GoTo ChooseALocationMouseInput2
EndChoice6:
Line (1032, 215)-(1102, 685), 1, BF
' Place Barragoon on the Board
Barragoon(Row2, Column2) = BarragoonPiece: Rotation(Row2, Column2) = BarragoonRotation
' Draw Barragoon
X1 = BoardX(Row2, Column2): X2 = BoardY(Row2, Column2): X3 = BarragoonPiece: X4 = BarragoonRotation: GoSub DrawBarragoon
' If Opponant Placed a Barragoon, Go Back so Player Can Place Barragoon
If BarragoonPlayer = Opponant Then BarragoonPlayer = Player: GoTo ChooseBarragoonPiece
CheckWinner:
' Declare Player Winner if Opponant Has No Tiles Left
If Tiles(Opponant) = 0 Then Winner = Player: GoTo Winner
Swap Player, Opponant: GoTo StartGame
ReleaseMouseButton:
Do While _MouseInput
If _MouseButton(1) = 0 Then Return
Loop
GoTo ReleaseMouseButton
DrawTile:
Line (X1 - 40, X2 - 40)-(X1 + 40, X2 + 40), X5, BF
If X3 = 1 Then X5 = 7: X6 = 0 Else X5 = 9: X6 = 15
Circle (X1, X2), 35, 2: Paint (X1, X2), X5, 2
If (X4 = 2) + (X4 = 4) Then Circle (X1 - 12, X2 - 12), 6, X6: Paint (X1 - 12, X2 - 12), X6: Circle (X1 + 12, X2 + 12), 6, X6: Paint (X1 + 12, X2 + 12), X6
If (X4 = 4) + ((X4 = 3) * (X3 = 1)) Then Circle (X1 - 12, X2 - 12), 6, X6: Paint (X1 - 12, X2 - 12), X6: Circle (X1 - 12, X2 + 12), 6, X6: Paint (X1 - 12, X2 + 12), X6
If (X4 = 4) + ((X4 = 3) * (X3 = 2)) Then Circle (X1 + 12, X2 - 12), 6, X6: Paint (X1 + 12, X2 - 12), X6: Circle (X1 + 12, X2 + 12), 6, X6: Paint (X1 + 12, X2 + 10), X6
If (X4 = 3) * (X3 = 1) Then Circle (X1 + 12, X2), 6, X6: Paint (X1 + 12, X2), X6 Else If X4 = 3 Then Circle (X1 - 12, X2), 6, X6: Paint (X1 - 12, X2), X6
If X4 = 2 Then PSet (X1 - 12, X2 - 12), X6: Draw "TA0E1F25G3H25E2": Paint (X1, X2), X6
If (X4 = 4) + ((X4 = 3) * (X3 = 1)) Then Line (X1 - 13, X2 - 12)-(X1 - 10, X2 + 12), X6, BF
If (X4 = 4) + ((X4 = 3) * (X3 = 2)) Then Line (X1 + 13, X2 - 12)-(X1 + 10, X2 + 12), X6, BF
If (X4 = 3) * (X3 = 1) Then
Line (X1 - 10, X2 - 12)-(X1 + 12, X2 - 2), X6: Line (X1 - 12, X2 - 10)-(X1 + 12, X2 + 2), X6: Paint (X1, X2 - 6), X6
Line (X1 - 10, X2 + 12)-(X1 + 12, X2 + 2), X6: Line (X1 - 12, X2 + 10)-(X1 + 12, X2 - 2), X6: Paint (X1, X2 + 6), X6
End If
If (X4 = 3) * (X3 = 2) Then
Line (X1 + 10, X2 - 12)-(X1 - 12, X2 - 2), X6: Line (X1 + 12, X2 - 10)-(X1 - 12, X2 + 2), X6: Paint (X1, X2 - 6), X6
Line (X1 + 10, X2 + 12)-(X1 - 12, X2 + 2), X6: Line (X1 + 12, X2 + 10)-(X1 - 12, X2 - 2), X6: Paint (X1, X2 + 6), X6
End If
If X4 = 4 Then Line (X1 - 12, X2 - 13)-(X1 + 12, X2 - 10), X6, BF: Line (X1 - 12, X2 + 13)-(X1 + 12, X2 + 10), X6, BF
Return
DrawBarragoon:
Line (X1 - 25, X2 - 25)-(X1 + 25, X2 + 25), 2, B: Paint (X1, X2), 0, 2: PSet (X1, X2), 0: Draw Barragoon$(X3, X4): Return
Piece1: Return
Piece2: GoSub Start1Space: Return
Piece3: GoSub Start1Space: GoSub Start2Spaces: Return
Piece4: GoSub Start1Space: GoSub Start2Spaces: GoSub Start3Spaces: Return
Start1Space:
' 1 Start Up Direction
If X1 - 1 >= 1 Then
If (TileColor(X1 - 1, X2) = 0) * ((Barragoon(X1 - 1, X2) = 0) + ((Barragoon(X1 - 1, X2) = 5) * (Rotation(X1 - 1, X2) = 1)) + (Barragoon(X1 - 1, X2) = 6)) Then Y1 = X1 - 1: Y2 = X2: Moves = 1: V = 0: GoSub CheckLeft
If (TileColor(X1 - 1, X2) = 0) * ((Barragoon(X1 - 1, X2) = 0) + ((Barragoon(X1 - 1, X2) = 2) * (Rotation(X1 - 1, X2) = 1)) + ((Barragoon(X1 - 1, X2) = 3) * (Rotation(X1 - 1, X2) = 2))) Then Y1 = X1 - 1: Y2 = X2: Moves = 1: V = 0: GoSub CheckUp
If (TileColor(X1 - 1, X2) = 0) * ((Barragoon(X1 - 1, X2) = 0) + ((Barragoon(X1 - 1, X2) = 4) * (Rotation(X1 - 1, X2) = 1)) + (Barragoon(X1 - 1, X2) = 6)) Then Y1 = X1 - 1: Y2 = X2: Moves = 1: V = 0: GoSub CheckRight
End If
' 1 Start Right Direction
If X2 + 1 <= 9 Then
If (TileColor(X1, X2 + 1) = 0) * ((Barragoon(X1, X2 + 1) = 0) + ((Barragoon(X1, X2 + 1) = 4) * (Rotation(X1, X2 + 1) = 2)) + (Barragoon(X1, X2 + 1) = 6)) Then Y1 = X1: Y2 = X2 + 1: Moves = 1: V = 0: GoSub CheckDown
If (TileColor(X1, X2 + 1) = 0) * ((Barragoon(X1, X2 + 1) = 0) + ((Barragoon(X1, X2 + 1) = 5) * (Rotation(X1, X2 + 1) = 2)) + (Barragoon(X1, X2 + 1) = 6)) Then Y1 = X1: Y2 = X2 + 1: Moves = 1: V = 0: GoSub CheckUp
If (TileColor(X1, X2 + 1) = 0) * ((Barragoon(X1, X2 + 1) = 0) + ((Barragoon(X1, X2 + 1) = 2) * (Rotation(X1, X2 + 1) = 2)) + ((Barragoon(X1, X2 + 1) = 3) * (Rotation(X1, X2 + 1) = 1))) Then Y1 = X1: Y2 = X2 + 1: Moves = 1: V = 0: GoSub CheckRight
End If
' 1 Start Down Direction
If X1 + 1 <= 7 Then
If (TileColor(X1 + 1, X2) = 0) * ((Barragoon(X1 + 1, X2) = 0) + ((Barragoon(X1 + 1, X2) = 4) * (Rotation(X1 + 1, X2) = 3)) + (Barragoon(X1 + 1, X2) = 6)) Then Y1 = X1 + 1: Y2 = X2: Moves = 1: V = 0: GoSub CheckLeft
If (TileColor(X1 + 1, X2) = 0) * ((Barragoon(X1 + 1, X2) = 0) + ((Barragoon(X1 + 1, X2) = 2) * (Rotation(X1 + 1, X2) = 3)) + ((Barragoon(X1 + 1, X2) = 3) * (Rotation(X1 + 1, X2) = 2))) Then Y1 = X1 + 1: Y2 = X2: Moves = 1: V = 0: GoSub CheckDown
If (TileColor(X1 + 1, X2) = 0) * ((Barragoon(X1 + 1, X2) = 0) + ((Barragoon(X1 + 1, X2) = 5) * (Rotation(X1 + 1, X2) = 3)) + (Barragoon(X1 + 1, X2) = 6)) Then Y1 = X1 + 1: Y2 = X2: Moves = 1: V = 0: GoSub CheckRight
End If
' 1 Start Left Direction
If X2 - 1 >= 1 Then
If (TileColor(X1, X2 - 1) = 0) * ((Barragoon(X1, X2 - 1) = 0) + ((Barragoon(X1, X2 - 1) = 2) * (Rotation(X1, X2 - 1) = 4)) + ((Barragoon(X1, X2 - 1) = 3) * (Rotation(X1, X2 - 1) = 1))) Then Y1 = X1: Y2 = X2 - 1: Moves = 1: V = 0: GoSub CheckLeft
If (TileColor(X1, X2 - 1) = 0) * ((Barragoon(X1, X2 - 1) = 0) + ((Barragoon(X1, X2 - 1) = 4) * (Rotation(X1, X2 - 1) = 4)) + (Barragoon(X1, X2 - 1) = 6)) Then Y1 = X1: Y2 = X2 - 1: Moves = 1: V = 0: GoSub CheckUp
If (TileColor(X1, X2 - 1) = 0) * ((Barragoon(X1, X2 - 1) = 0) + ((Barragoon(X1, X2 - 1) = 5) * (Rotation(X1, X2 - 1) = 4)) + (Barragoon(X1, X2 - 1) = 6)) Then Y1 = X1: Y2 = X2 - 1: Moves = 1: V = 0: GoSub CheckDown
End If
Return
Start2Spaces:
' 2 Start Up Then Turn
If X1 - 2 >= 1 Then
If (TileColor(X1 - 1, X2) = 0) * (TileColor(X1 - 2, X2) = 0) * ((Barragoon(X1 - 1, X2) = 0) + ((Barragoon(X1 - 1, X2) = 2) * (Rotation(X1 - 1, X2) = 1)) + ((Barragoon(X1 - 1, X2) = 3) * (Rotation(X1 - 1, X2) = 2))) * ((Barragoon(X1 - 2, X2) = 0) + ((Barragoon(X1 - 2, X2) = 5) * (Rotation(X1 - 2, X2) = 1)) + (Barragoon(X1 - 2, X2) = 6)) Then Y1 = X1 - 2: Y2 = X2: Moves = 2: V = 0: GoSub CheckLeft
If (TileColor(X1 - 1, X2) = 0) * (TileColor(X1 - 2, X2) = 0) * ((Barragoon(X1 - 1, X2) = 0) + ((Barragoon(X1 - 1, X2) = 2) * (Rotation(X1 - 1, X2) = 1)) + ((Barragoon(X1 - 1, X2) = 3) * (Rotation(X1 - 1, X2) = 2))) * ((Barragoon(X1 - 2, X2) = 0) + ((Barragoon(X1 - 2, X2) = 2) * (Rotation(X1 - 2, X2) = 1)) + ((Barragoon(X1 - 2, X2) = 3) * (Rotation(X1 - 1, X2) = 2))) Then Y1 = X1 - 2: Y2 = X2: Moves = 2: V = 0: GoSub CheckUp
If (TileColor(X1 - 1, X2) = 0) * (TileColor(X1 - 2, X2) = 0) * ((Barragoon(X1 - 1, X2) = 0) + ((Barragoon(X1 - 1, X2) = 2) * (Rotation(X1 - 1, X2) = 1)) + ((Barragoon(X1 - 1, X2) = 3) * (Rotation(X1 - 1, X2) = 2))) * ((Barragoon(X1 - 2, X2) = 0) + ((Barragoon(X1 - 2, X2) = 4) * (Rotation(X1 - 2, X2) = 1)) + (Barragoon(X1 - 2, X2) = 6)) Then Y1 = X1 - 2: Y2 = X2: Moves = 2: V = 0: GoSub CheckRight
End If
' 2 Start Right Then Turn
If X2 + 2 <= 9 Then
If (TileColor(X1, X2 + 1) = 0) * (TileColor(X1, X2 + 2) = 0) * ((Barragoon(X1, X2 + 1) = 0) + ((Barragoon(X1, X2 + 1) = 2) * (Rotation(X1, X2 + 1) = 2)) + ((Barragoon(X1, X2 + 1) = 3) * (Rotation(X1, X2 + 1) = 1))) * ((Barragoon(X1, X2 + 2) = 0) + ((Barragoon(X1, X2 + 2) = 4) * (Rotatiom(X1, X2 + 2) = 2)) + (Barragoon(X1, X2 + 2) = 6)) Then Y1 = X1: Y2 = X2 + 2: Moves = 2: V = 0: GoSub CheckDown
If (TileColor(X1, X2 + 1) = 0) * (TileColor(X1, X2 + 2) = 0) * ((Barragoon(X1, X2 + 1) = 0) + ((Barragoon(X1, X2 + 1) = 2) * (Rotation(X1, X2 + 1) = 2)) + ((Barragoon(X1, X2 + 1) = 3) * (Rotation(X1, X2 + 1) = 1))) * ((Barragoon(X1, X2 + 2) = 0) + ((Barragoon(X1, X2 + 2) = 5) * (Rotatiom(X1, X2 + 2) = 2)) + (Barragoon(X1, X2 + 2) = 6)) Then Y1 = X1: Y2 = X2 + 2: Moves = 2: V = 0: GoSub CheckUp
If (TileColor(X1, X2 + 1) = 0) * (TileColor(X1, X2 + 2) = 0) * ((Barragoon(X1, X2 + 1) = 0) + ((Barragoon(X1, X2 + 1) = 2) * (Rotation(X1, X2 + 1) = 2)) + ((Barragoon(X1, X2 + 1) = 3) * (Rotation(X1, X2 + 1) = 1))) * ((Barragoon(X1, X2 + 2) = 0) + ((Barragoon(X1, X2 + 2) = 2) * (Rotatiom(X1, X2 + 2) = 2)) + ((Barragoon(X1, X2 + 2) = 3) * (Rotation(X1, X2 + 2) = 1))) Then Y1 = X1: Y2 = X2 + 2: Moves = 2: V = 0: GoSub CheckRight
End If
' 2 Start Down Then Turn
If X1 + 2 <= 7 Then
If (TileColor(X1 + 1, X2) = 0) * (TileColor(X1 + 2, X2) = 0) * ((Barragoon(X1 + 1, X2) = 0) + ((Barragoon(X1 + 1, X2) = 2) * (Rotation(X1 + 1, X2) = 3)) + ((Barragoon(X1 + 1, X2) = 3) * (Rotation(X1 + 1, X2) = 2))) * ((Barragoon(X1 + 2, X2) = 0) + ((Barragoon(X1 + 2, X2) = 4) * (Rotation(X1 + 2, X2) = 3)) + (Barragoon(X1 + 2, X2) = 6)) Then Y1 = X1 + 2: Y2 = X2: Moves = 2: V = 0: GoSub CheckLeft
If (TileColor(X1 + 1, X2) = 0) * (TileColor(X1 + 2, X2) = 0) * ((Barragoon(X1 + 1, X2) = 0) + ((Barragoon(X1 + 1, X2) = 2) * (Rotation(X1 + 1, X2) = 3)) + ((Barragoon(X1 + 1, X2) = 3) * (Rotation(X1 + 1, X2) = 2))) * ((Barragoon(X1 + 2, X2) = 0) + ((Barragoon(X1 + 2, X2) = 2) * (Rotation(X1 + 2, X2) = 3)) + ((Barragoon(X1 + 2, X2) = 3) * (Rotation(X1 + 2, X2) = 2))) Then Y1 = X1 + 2: Y2 = X2: Moves = 2: V = 0: GoSub CheckDown
If (TileColor(X1 + 1, X2) = 0) * (TileColor(X1 + 2, X2) = 0) * ((Barragoon(X1 + 1, X2) = 0) + ((Barragoon(X1 + 1, X2) = 2) * (Rotation(X1 + 1, X2) = 3)) + ((Barragoon(X1 + 1, X2) = 3) * (Rotation(X1 + 1, X2) = 2))) * ((Barragoon(X1 + 2, X2) = 0) + ((Barragoon(X1 + 2, X2) = 5) * (Rotation(X1 + 2, X2) = 3)) + (Barragoon(X1 + 2, X2) = 6)) Then Y1 = X1 + 2: Y2 = X2: Moves = 2: V = 0: GoSub CheckRight
End If
' 2 Start Left Then Turn
If X2 - 2 >= 1 Then
If (TileColor(X1, X2 - 1) = 0) * (TileColor(X1, X2 - 2) = 0) * ((Barragoon(X1, X2 - 1) = 0) + ((Barragoon(X1, X2 - 1) = 2) * (Roatation(X1, X2 - 1) = 4)) + ((Barragoon(X1, X2 - 1) = 3) * (Rotation(X1, X2 - 1) = 1))) * ((Barragoon(X1, X2 - 2) = 0) + ((Barragoon(X1, X2 - 2) = 2) * (Rotation(X1, X2 - 2) = 2)) + ((Barragoon(X1, X2 - 2) = 3) * (Rotation(X1, X2 - 2) = 1))) Then Y1 = X1: Y2 = X2 - 2: Moves = 2: V = 0: GoSub CheckLeft
If (TileColor(X1, X2 - 1) = 0) * (TileColor(X1, X2 - 2) = 0) * ((Barragoon(X1, X2 - 1) = 0) + ((Barragoon(X1, X2 - 1) = 2) * (Roatation(X1, X2 - 1) = 4)) + ((Barragoon(X1, X2 - 1) = 3) * (Rotation(X1, X2 - 1) = 1))) * ((Barragoon(X1, X2 - 2) = 0) + ((Barragoon(X1, X2 - 2) = 4) * (Rotation(X1, X2 - 2) = 4)) + (Barragoon(X1, X2 - 2) = 6)) Then Y1 = X1: Y2 = X2 - 2: Moves = 2: V = 0: GoSub CheckUp
If (TileColor(X1, X2 - 1) = 0) * (TileColor(X1, X2 - 2) = 0) * ((Barragoon(X1, X2 - 1) = 0) + ((Barragoon(X1, X2 - 1) = 2) * (Roatation(X1, X2 - 1) = 4)) + ((Barragoon(X1, X2 - 1) = 3) * (Rotation(X1, X2 - 1) = 1))) * ((Barragoon(X1, X2 - 2) = 0) + ((Barragoon(X1, X2 - 2) = 5) * (Rotation(X1, X2 - 2) = 4)) + (Barragoon(X1, X2 - 2) = 6)) Then Y1 = X1: Y2 = X2 - 2: Moves = 2: V = 0: GoSub CheckDown
End If
Return
Start3Spaces:
' 3 Start Up Then Turn
If X1 - 3 >= 1 Then
If (TileColor(X1 - 1, X2) = 0) * (TileColor(X1 - 2, X2) = 0) * (TileColor(X1 - 3, X2) = 0) * ((Barragoon(X1 - 1, X2) = 0) + ((Barragoon(X1 - 1, X2) = 2) * (Rotation(X1 - 1, X2) = 1)) + ((Barragoon(X1 - 1, X2) = 3) * (Rotation(X1 - 1, X2) = 2))) * ((Barragoon(X1 - 2, X2) = 0) + ((Barragoon(X1 - 2, X2) = 2) * (Rotation(X1 - 2, X2) = 1)) + ((Barragoon(X1 - 2, X2) = 3) * (Rotation(X1 - 2, X2) = 2))) * ((Barragoon(X1 - 3, X2) = 0) + ((Barragoon(X1 - 3, X2) = 5) * (Rotation(X1 - 3, X2) = 1)) + (Barragoon(X1 - 3, X2) = 6)) Then Y1 = X1 - 3: Y2 = X2: Moves = 3: V = 0: GoSub CheckLeft
If (TileColor(X1 - 1, X2) = 0) * (TileColor(X1 - 2, X2) = 0) * (TileColor(X1 - 3, X2) = 0) * ((Barragoon(X1 - 1, X2) = 0) + ((Barragoon(X1 - 1, X2) = 2) * (Rotation(X1 - 1, X2) = 1)) + ((Barragoon(X1 - 1, X2) = 3) * (Rotation(X1 - 1, X2) = 2))) * ((Barragoon(X1 - 2, X2) = 0) + ((Barragoon(X1 - 2, X2) = 2) * (Rotation(X1 - 2, X2) = 1)) + ((Barragoon(X1 - 2, X2) = 3) * (Rotation(X1 - 1, X2) = 2))) * ((Barragoon(X1 - 3, X2) = 0) + ((Barragoon(X1 - 3, X2) = 2) * (Rotation(X1 - 3, X2) = 1)) + ((Barragoon(X1 - 3, X2) = 2) * (Rotation(X1 - 3, X2) = 2))) Then Y1 = X1 - 3: Y2 = X2: Moves = 3: V = 0: GoSub CheckUp
If (TileColor(X1 - 1, X2) = 0) * (TileColor(X1 - 2, X2) = 0) * (TileColor(X1 - 3, X2) = 0) * ((Barragoon(X1 - 1, X2) = 0) + ((Barragoon(X1 - 1, X2) = 2) * (Rotation(X1 - 1, X2) = 1)) + ((Barragoon(X1 - 1, X2) = 3) * (Rotation(X1 - 1, X2) = 2))) * ((Barragoon(X1 - 2, X2) = 0) + ((Barragoon(X1 - 2, X2) = 2) * (Rotation(X1 - 2, X2) = 1)) + ((Barragoon(X1 - 2, X2) = 3) * (Rotation(X1 - 2, X2) = 2))) * ((Barragoon(X1 - 3, X2) = 0) + ((Barragoon(X1 - 3, X2) = 4) * (Rotation(X1 - 3, X2) = 1)) + (Barragoon(X1 - 3, X2) = 6)) Then Y1 = X1 - 3: Y2 = X2: Moves = 3: V = 0: GoSub CheckRight
End If
' 3 Start Right Then Turn
If X2 + 3 <= 9 Then
If (TileColor(X1, X2 + 1) = 0) * (TileColor(X1, X2 + 2) = 0) * (TileColor(X1, X2 + 3) = 0) * ((Barragoon(X1, X2 + 1) = 0) + ((Barragoon(X1, X2 + 1) = 2) * (Rotation(X1, X2 + 1) = 2)) + ((Barragoon(X1, X2 + 1) = 3) * (Rotation(X1, X2 + 1) = 1))) * ((Barragoon(X1, X2 + 2) = 0) + ((Barragoon(X1, X2 + 2) = 2) * (Rotatiom(X1, X2 + 2) = 2)) + ((Barragoon(X1, X2 + 2) = 3) * (Rotation(X1, X2 + 2) = 1))) * ((Barragoon(X1, X2 + 3) = 0) + ((Barragoon(X1, X2 + 3) = 4) * (Rotation(X1, X2 + 3) = 2)) + (Barragoon(X1, X2 + 3) = 6)) Then Y1 = X1: Y2 = X2 + 3: Moves = 3: V = 0: GoSub CheckDown
If (TileColor(X1, X2 + 1) = 0) * (TileColor(X1, X2 + 2) = 0) * (TileColor(X1, X2 + 3) = 0) * ((Barragoon(X1, X2 + 1) = 0) + ((Barragoon(X1, X2 + 1) = 2) * (Rotation(X1, X2 + 1) = 2)) + ((Barragoon(X1, X2 + 1) = 3) * (Rotation(X1, X2 + 1) = 1))) * ((Barragoon(X1, X2 + 2) = 0) + ((Barragoon(X1, X2 + 2) = 2) * (Rotatiom(X1, X2 + 2) = 2)) + ((Barragoon(X1, X2 + 2) = 6) * (Rotation(X1, X2 + 2) = 1))) * ((Barragoon(X1, X2 + 3) = 0) + ((Barragoon(X1, X2 + 3) = 5) * (Rotation(X1, X2 + 3) = 2)) + (Barragoon(X1, X2 + 3) = 6)) Then Y1 = X1: Y2 = X2 + 3: Moves = 3: V = 0: GoSub CheckUp
If (TileColor(X1, X2 + 1) = 0) * (TileColor(X1, X2 + 2) = 0) * (TileColor(X1, X2 + 3) = 0) * ((Barragoon(X1, X2 + 1) = 0) + ((Barragoon(X1, X2 + 1) = 2) * (Rotation(X1, X2 + 1) = 2)) + ((Barragoon(X1, X2 + 1) = 3) * (Rotation(X1, X2 + 1) = 1))) * ((Barragoon(X1, X2 + 2) = 0) + ((Barragoon(X1, X2 + 2) = 2) * (Rotatiom(X1, X2 + 2) = 2)) + ((Barragoon(X1, X2 + 2) = 3) * (Rotation(X1, X2 + 2) = 1))) * ((Barragoon(X1, X2 + 3) = 0) + ((Barragoon(X1, X2 + 3) = 2) * (Rotation(X1, X2 + 3) = 2)) + ((Barragoon(X1, X2 + 3) = 3) * (Rotation(X1, X2 + 3) = 1))) Then Y1 = X1: Y2 = X2 + 3: Moves = 3: V = 0: GoSub CheckRight
End If
' 3 Start Down Then Turn
If X1 + 3 <= 7 Then
If (TileColor(X1 + 1, X2) = 0) * (TileColor(X1 + 2, X2) = 0) * (TileColor(X1 + 3, X2) = 0) * ((Barragoon(X1 + 1, X2) = 0) + ((Barragoon(X1 + 1, X2) = 2) * (Rotation(X1 + 1, X2) = 3)) + ((Barragoon(X1 + 1, X2) = 3) * (Rotation(X1 + 1, X2) = 2))) * ((Barragoon(X1 + 2, X2) = 0) + ((Barragoon(X1 + 2, X2) = 2) * (Rotation(X1 + 2, X2) = 3)) + ((Barragoon(X1 + 2, X2) = 3) * (Rotation(X1 + 2, X2) = 2))) * ((Barragoon(X1 + 3, X2) = 0) + ((Barragoon(X1 + 3, X2) = 4) * (Rotation(X1 + 3, X2) = 3)) + (Barragoon(X1 + 3, X2) = 6)) Then Y1 = X1 + 3: Y2 = X2: Moves = 3: V = 0: GoSub CheckLeft
If (TileColor(X1 + 1, X2) = 0) * (TileColor(X1 + 2, X2) = 0) * (TileColor(X1 + 3, X2) = 0) * ((Barragoon(X1 + 1, X2) = 0) + ((Barragoon(X1 + 1, X2) = 2) * (Rotation(X1 + 1, X2) = 3)) + ((Barragoon(X1 + 1, X2) = 3) * (Rotation(X1 + 1, X2) = 2))) * ((Barragoon(X1 + 2, X2) = 0) + ((Barragoon(X1 + 2, X2) = 2) * (Rotation(X1 + 2, X2) = 3)) + ((Barragoon(X1 + 2, X2) = 3) * (Rotation(X1 + 2, X2) = 2))) * ((Barragoon(X1 + 3, X2) = 0) + ((Barragoon(X1 + 3, X2) = 2) * (Rotation(X1 + 3, X2) = 3)) + ((Barragoon(X1 + 3, X2) = 3) * (Rotation(X1 + 3, X2) = 1))) Then Y1 = X1 + 3: Y2 = X2: Moves = 3: V = 0: GoSub CheckDown
If (TileColor(X1 + 1, X2) = 0) * (TileColor(X1 + 2, X2) = 0) * (TileColor(X1 + 3, X2) = 0) * ((Barragoon(X1 + 1, X2) = 0) + ((Barragoon(X1 + 1, X2) = 2) * (Rotation(X1 + 1, X2) = 3)) + ((Barragoon(X1 + 1, X2) = 3) * (Rotation(X1 + 1, X2) = 2))) * ((Barragoon(X1 + 2, X2) = 0) + ((Barragoon(X1 + 2, X2) = 2) * (Rotation(X1 + 2, X2) = 3)) + ((Barragoon(X1 + 2, X2) = 3) * (Rotation(X1 + 2, X2) = 2))) * ((Barragoon(X1 + 3, X2) = 0) + ((Barragoon(X1 + 3, X2) = 5) * (Rotation(X1 + 3, X2) = 3)) + (Barragoon(X1 + 3, X2) = 6)) Then Y1 = X1 + 3: Y2 = X2: Moves = 3: V = 0: GoSub CheckRight
End If
' 3 Start Left Then Turn
If X2 - 3 >= 1 Then
If (TileColor(X1, X2 - 1) = 0) * (TileColor(X1, X2 - 2) = 0) * (TileColor(X1, X2 - 3) = 0) * ((Barragoon(X1, X2 - 1) = 0) + ((Barragoon(X1, X2 - 1) = 2) * (Rotation(X1, X2 - 1) = 4)) + ((Barragoon(X1, X2 - 1) = 3) * (Rotation(X1, X2 - 1) = 1))) * ((Barragoon(X1, X2 - 2) = 0) + ((Barragoon(X1, X2 - 2) = 2) * (Rotation(X1, X2 - 2) = 4)) + ((Barragoon(X1, X2 - 2) = 3) * (Rotation(X1, X2 - 2) = 1))) * ((Barragoon(X1, X2 - 3) = 0) + ((Barragoon(X1, X2 - 3) = 2) * (Rotation(X1, X2 - 3) = 4)) + ((Barragoon(X1, X2 - 3) = 3) * (Rotation(X1, X2 - 3) = 1))) Then Y1 = X1: Y2 = X2 - 3: Moves = 3: V = 0: GoSub CheckLeft
If (TileColor(X1, X2 - 1) = 0) * (TileColor(X1, X2 - 2) = 0) * (TileColor(X1, X2 - 3) = 0) * ((Barragoon(X1, X2 - 1) = 0) + ((Barragoon(X1, X2 - 1) = 2) * (Rotation(X1, X2 - 1) = 4)) + ((Barragoon(X1, X2 - 1) = 3) * (Rotation(X1, X2 - 1) = 1))) * ((Barragoon(X1, X2 - 2) = 0) + ((Barragoon(X1, X2 - 2) = 2) * (Rotation(X1, X2 - 2) = 4)) + ((Barragoon(X1, X2 - 2) = 3) * (Rotation(X1, X2 - 2) = 1))) * ((Barragoon(X1, X2 - 3) = 0) + ((Barragoon(X1, X2 - 3) = 4) * (Rotation(X1, X2 - 3) = 4)) + (Barragoon(X1, X2 - 3) = 6)) Then Y1 = X1: Y2 = X2 - 3: Moves = 3: V = 0: GoSub CheckUp
If (TileColor(X1, X2 - 1) = 0) * (TileColor(X1, X2 - 2) = 0) * (TileColor(X1, X2 - 3) = 0) * ((Barragoon(X1, X2 - 1) = 0) + ((Barragoon(X1, X2 - 1) = 2) * (Rotation(X1, X2 - 1) = 4)) + ((Barragoon(X1, X2 - 1) = 3) * (Rotation(X1, X2 - 1) = 1))) * ((Barragoon(X1, X2 - 2) = 0) + ((Barragoon(X1, X2 - 2) = 2) * (Rotation(X1, X2 - 2) = 4)) + ((Barragoon(X1, X2 - 2) = 3) * (Rotation(X1, X2 - 2) = 1))) * ((Barragoon(X1, X2 - 3) = 0) + ((Barragoon(X1, X2 - 3) = 5) * (Rotation(X1, X2 - 3) = 4)) + (Barragoon(X1, X2 - 3) = 6)) Then Y1 = X1: Y2 = X2 - 3: Moves = 3: V = 0: GoSub CheckDown
End If
Return
CheckUp:
If Moves + V = Piece - 1 Then If TileColor(Y1 - V, Y2) + Barragoon(Y1 - V, Y2) = 0 Then X = 1: Playable(Y1 - V, Y2) = 1: ' Short Move Up
If Y1 - V - 1 >= 1 Then
V = V + 1
If Moves + V = Piece Then
If TileColor(Y1 - V, Y2) = Player Then Return
If (Piece = 2) * (Barragoon(Y1 - V, Y2) = 6) Then Return
Playable(Y1 - V, Y2) = 1: X = 1: Return
Else
If (TileColor(Y1 - V, Y2) = 0) * ((Barragoon(Y1 - V, Y2) = 0) + ((Barragoon(Y1 - V, Y2) = 2) * (Rotation(Y1 - V, Y2) = 1)) + ((Barragoon(Y1 - V, Y2) = 3) * (Rotation(Y1 - V, Y2) = 2))) GoTo CheckUp
Return
End If
End If
Return
CheckRight:
If Moves + V = Piece - 1 Then If TileColor(Y1, Y2 + V) + Barragoon(Y1, Y2 + V) = 0 Then X = 1: Playable(Y1, Y2 + V) = 1: ' Short Move Right
If Y2 + V + 1 <= 9 Then
V = V + 1
If Moves + V = Piece Then
If TileColor(Y1, Y2 + V) = Player Then Return
If (Piece = 2) * (Barragoon(Y1, Y2 + V) = 6) Then Return
Playable(Y1, Y2 + V) = 1: X = 1: Return
Else
If (TileColor(Y1, Y2 + V) = 0) * ((Barragoon(Y1, Y2 + V) = 0) + ((Barragoon(Y1, Y2 + V) = 2) * (Rotation(Y1, Y2 + V) = 2)) + ((Barragoon(Y1, Y2 + V) = 3) * (Rotation(Y1, Y2 + V) = 1))) GoTo CheckRight
Return
End If
End If
Return
CheckDown:
If Moves + V = Piece - 1 Then If TileColor(Y1 + V, Y2) + Barragoon(Y1 + V, Y2) = 0 Then X = 1: Playable(Y1 + V, Y2) = 1: ' Short Move Right
If Y1 + V + 1 <= 7 Then
V = V + 1
If Moves + V = Piece Then
If TileColor(Y1 + V, Y2) = Player Then Return
If (Piece = 2) * (Barragoon(Y1 + V, Y2) = 6) Then Return
Playable(Y1 + V, Y2) = 1: X = 1: Return
Else
If (TileColor(Y1 + V, Y2) = 0) * ((Barragoon(Y1 + V, Y2) = 0) + ((Barragoon(Y1 + V, Y2) = 2) * (Rotation(Y1 + V, Y2) = 3)) + ((Barragoon(Y1 + V, Y2) = 3) * (Rotation(Y1 + V, Y2) = 2))) GoTo CheckDown
Return
End If
End If
Return
CheckLeft:
If Moves + V = Piece - 1 Then If TileColor(Y1, Y2 - V) + Barragoon(Y1, Y2 - V) = 0 Then X = 1: Playable(Y1, Y2 - V) = 1: ' Short Move Left
If Y2 - V - 1 >= 1 Then
V = V + 1
If Moves + V = Piece Then
If TileColor(Y1, Y2 - V) = Player Then Return
If (Piece = 2) * (Barragoon(Y1, Y2 - V) = 6) Then Return
Playable(Y1, Y2 - V) = 1: X = 1: Return
Else
If (TileColor(Y1, Y2 - V) = 0) * ((Barragoon(Y1, Y2 - V) = 0) + ((Barragoon(Y1, Y2 - V) = 2) * (Rotation(Y1, Y2 - V) = 4)) + ((Barragoon(Y1, Y2 - V) = 3) * (Rotation(V1, Y2 - V) = 1))) GoTo CheckLeft
Return
End If
End If
Return
Winner:
X1 = 1067: X2 = 100: X3 = Winner: X4 = 2: X5 = 1: GoSub DrawTile
Color 15, 1: Locate 10, 130: Print "Player:"; Winner;
Color 15, 1: Locate 13, 121: Print " Player"; Winner; "is the Winner! ";
Color 15, 1: Locate 15, 121: Print " Play Another Game? Y or N ";
GetYesNo: A$ = UCase$(InKey$): If A$ = "" GoTo GetYesNo
If A$ = "Y" Then Run
If A$ = "N" Then System
GoTo GetYesNo
|
|
|
The Brain Game from Australia |
Posted by: SMcNeill - 12-23-2023, 10:02 PM - Forum: Donald Foster
- No Replies
|
|
Quote:Hello All,.
The Brain from Australia is a 2 player board game originally made on my Tandy 2000. I could not find a copy of the rules, I peeked at my source code from the Tandy 2000 printout to figure out the rules. Hopefully I got it right.
The Game is played on a 13x13 game board with alternating orange and green spots on the board for players to place their pieces on. There are also groups of 2x2 grey squares grouped under the color spots around the board. One player plays with 26 white pieces and the other plays with 26 black pieces.
The game came be won by placing 4 of your pieces in a row and skipping one space in between each of your pieces or by occupying all 4 grey squares that are grouped of your color.
If after each player has placed all 26 of their pieces on the board and there is no winner yet, places can move the their pieces already on the board.
Hope you enjoy playing.
Donald
Code: (Select All)
_Title "The Brain Game From Australia by Donald L. Foster Jr. 2018"
Screen _NewImage(1020, 735, 256)
_PaletteColor 1, _RGB32(200, 200, 200) ' Lt Grey
_PaletteColor 2, _RGB32(180, 180, 180) ' Med Grey
_PaletteColor 3, _RGB32(255, 100, 0) ' Orange
_PaletteColor 4, _RGB32(0, 200, 50) ' Green
_PaletteColor 5, _RGB32(0, 50, 255) ' Blue
Dim Player As Integer
Dim Opponent As Integer
Dim V As Integer
Dim W As Integer
Dim X As Integer
Dim Y As Integer
Dim Z As Integer
Dim PlayerColor(2) As Integer
Dim PlayerPieces(2) As Integer
Dim X(2) As Integer
Dim BoardX(13, 13) As Integer
Dim BoardY(13, 13) As Integer
Dim StorageX(2, 26) As Integer
Dim StorageY(2, 26) As Integer
Dim BoardPlayer(13, 13) As Integer
Dim BoardSquare(13, 13) As Integer
Dim WinningSquare(13, 13) As Integer
Dim C(2) As String
Dim Cursor As String
Player = 1: Opponent = 2
PlayerColor(1) = 15: PlayerColor(2) = 0
PlayerPieces(1) = 1: PlayerPieces(2) = 1
C$(1) = "C15": C$(2) = "C0"
Cursor$ = "C0BU25RL26D50R50U50L51D51R52U52L52"
' Setup Grey Board Squares
For Z = 2 To 11 Step 3: For Y = 2 To 11 Step 3: BoardSquare(Z, Y) = 1: BoardSquare(Z, Y + 1) = 1: BoardSquare(Z + 1, Y) = 1: BoardSquare(Z + 1, Y + 1) = 1: Next: Next
Cls , 5
Color 15, 5: Locate 2, 96: Print "The Brain Game from Australia";
' Daw Board
Line (10, 10)-(725, 725), 2, BF: Line (16, 16)-(719, 719), 3, BF: Line (20, 20)-(715, 715), 15, BF
X = 56
For Z = 1 To 13
W = 56
For Y = 1 To 13
If BoardSquare(Z, Y) = 1 Then Line (W - 25, X - 25)-(W + 25, X + 25), 1, BF
If (Z + Y) / 2 = Fix((Z + Y) / 2) Then V = 3 Else V = 4
Circle (W, X), 24, V: Paint (W, X), V
BoardX(Z, Y) = W: BoardY(Z, Y) = X
W = W + 52
Next
X = X + 52
Next
' Setup Storage Pieces
X = 145: X(1) = 1: X(2) = 1
For Z = 1 To 13
W = 780
For Y = 1 To 4
If Y < 3 Then V = 1 Else V = 2
Circle (W, X), 20, PlayerColor(V): Paint (W, X), PlayerColor(V)
StorageX(V, X(V)) = W: StorageY(V, X(V)) = X
W = W + 60: X(V) = X(V) + 1
Next
X = X + 44
Next
StartGame:
' Display Player Indicator
Circle (872, 65), 21, PlayerColor(Player): Paint (872, 65), PlayerColor(Player)
Locate 7, 106: Print "Player:"; Player;
Locate 45, 94: If PlayerPieces(Player) = 27 Then Print " Choose a Piece to Move. "; Else Print " Choose Location to Place Piece. ";
GetMouseInput1:
While (_MouseInput)
For Z = 1 To 13
For Y = 1 To 13
If _MouseX > BoardX(Z, Y) - 26 And _MouseX < BoardX(Z, Y) + 26 And _MouseY > BoardY(Z, Y) - 26 And _MouseY < BoardY(Z, Y) + 26 And _MouseButton(1) = -1 Then
If (BoardPlayer(Z, Y) = 0 And PlayerPieces(Player) < 27) Or (BoardPlayer(Z, Y) = Player And PlayerPieces(Player) = 27) Then
Row1 = Z: Column1 = Y: GoSub ButtonRelease: GoTo EndMouseInput1
End If
End If
Next
Next
Wend
GoTo GetMouseInput1
EndMouseInput1:
If PlayerPieces(Player) < 27 Then
Pieces = PlayerPieces(Player)
BoardPlayer(Row1, Column1) = Player
Circle (BoardX(Row1, Column1), BoardY(Row1, Column1)), 20, PlayerColor(Player): Paint (BoardX(Row1, Column1), BoardY(Row1, Column1)), PlayerColor(Player)
Line (StorageX(Player, Pieces) - 21, StorageY(Player, Pieces) - 21)-(StorageX(Player, Pieces) + 21, StorageY(Player, Pieces) + 21), 5, BF
PlayerPieces(Player) = PlayerPieces(Player) + 1
GoTo EndTurn
End If
' Place Cursor Around Select Piece
PSet (BoardX(Row1, Column1), BoardY(Row1, Column1)), PlayerColor(Player): Draw C$(Player) + Cursor$
Locate 45, 94: Print " Choose a Location to Move to. ";
GetMouseInput2:
While (_MouseInput)
For Z = 1 To 13
For Y = 1 To 13
If _MouseX > BoardX(Z, Y) - 26 And _MouseX < BoardX(Z, Y) + 26 And _MouseY > BoardY(Z, Y) - 26 And _MouseY < BoardY(Z, Y) + 26 And _MouseButton(1) = -1 Then
If BoardPlayer(Z, Y) = 0 Then Row2 = Z: Column2 = Y: GoSub ButtonRelease: GoTo EndMouseInput2
End If
Next
Next
Wend
GoTo GetMouseInput2
EndMouseInput2:
BoardPlayer(Row1, Column1) = 0: BoardPlayer(Row2, Column2) = Player
Line (BoardX(Row1, Column1) - 26, BoardY(Row1, Column1) - 26)-(BoardX(Row1, Column1) + 26, BoardY(Row1, Column1) + 26), 15, BF
If BoardSquare(Row1, Column1) = 1 Then Line (BoardX(Row1, Column1) - 25, BoardY(Row1, Column1) - 25)-(BoardX(Row1, Column1) + 25, BoardY(Row1, Column1) + 25), 1, BF
If (Row1 + Column1) / 2 = Fix((Row1 + Column1) / 2) Then V = 3 Else V = 4
Circle (BoardX(Row1, Column1), BoardY(Row1, Column1)), 24, V: Paint (BoardX(Row1, Column1), BoardY(Row1, Column1)), V
Circle (BoardX(Row2, Column2), BoardY(Row2, Column2)), 20, PlayerColor(Player): Paint (BoardX(Row2, Column2), BoardY(Row2, Column2)), PlayerColor(Player)
EndTurn:
' Set WinningSquares to Zero
For Z = 1 To 13: For Y = 1 To 13: WinningSquare(Z, Y) = 0: Next: Next
' Check for Winner
X = 0
For Z = 2 To 11 Step 3
For Y = 2 To 11 Step 3
If BoardPlayer(Z, Y) = Player And BoardPlayer(Z, Y + 1) = Player And BoardPlayer(Z + 1, Y) = Player And BoardPlayer(Z + 1, Y + 1) = Player Then
X = 1: WinningSquare(Z, Y) = 1: WinningSquare(Z, Y + 1) = 1: WinningSquare(Z + 1, Y) = 1: WinningSquare(Z + 1, Y + 1) = 1
End If
Next
Next
For Z = 1 To 7
For Y = 1 To 13
If BoardPlayer(Y, Z) = Player And BoardPlayer(Y, Z + 2) = Player And BoardPlayer(Y, Z + 4) = Player And BoardPlayer(Y, Z + 6) = Player Then
X = 1: WinningSquare(Y, Z) = 1: WinningSquare(Y, Z + 2) = 1: WinningSquare(Y, Z + 4) = 1: WinningSquare(Y, Z + 6) = 1
End If
If BoardPlayer(Z, Y) = Player And BoardPlayer(Z + 2, Y) = Player And BoardPlayer(Z + 4, Y) = Player And BoardPlayer(Z + 6, Y) = Player Then
X = 1: WinningSquare(Z, Y) = 1: WinningSquare(Z + 2, Y) = 1: WinningSquare(Z + 4, Y) = 1: WinningSquare(Z + 6, Y) = 1
End If
Next
Next
For Z = 1 To 7
For Y = 1 To 7
If BoardPlayer(Z, Y) = Player And BoardPlayer(Z + 2, Y + 2) = Player And BoardPlayer(Z + 4, Y + 4) = Player And BoardPlayer(Z + 6, Y + 6) = Player Then
X = 1: WinningSquare(Z, Y) = 1: WinningSquare(Z + 2, Y + 2) = 1: WinningSquare(Z + 4, Y + 4) = 1: WinningSquare(Z + 6, Y + 6) = 1
End If
If BoardPlayer(14 - Y, Z) = Player And BoardPlayer(12 - Y, Z + 2) = Player And BoardPlayer(10 - Y, Z + 4) = Player And BoardPlayer(8 - Y, Z + 6) = Player Then
X = 1: WinningSquare(14 - Y, Z) = 1: WinningSquare(12 - Y, Z + 2) = 1: WinningSquare(10 - Y, Z + 4) = 1: WinningSquare(8 - Y, Z + 6) = 1
End If
Next
Next
If X = 1 GoTo Winner
Swap Player, Opponent: GoTo StartGame
ButtonRelease:
While (_MouseInput)
If _MouseButton(1) = 0 Then Return
Wend
GoTo ButtonRelease
Winner:
For Z = 1 To 13
For Y = 1 To 13
If WinningSquare(Z, Y) = 1 Then PSet (BoardX(Z, Y), BoardY(Z, Y)), PlayerColor(Player): Draw C$(Player) + Cursor$
Next
Next
Locate 45, 94: Print " Winner! Play Again? ( Y / N ) ";
YorN:
A$ = UCase$(InKey$)
If A$ = "" GoTo YorN
If A$ = "Y" Then Run
If A$ = "N" Then System
GoTo YorN
|
|
|
|