Post by Rod on Jan 20, 2023 10:37:35 GMT -5
This is a collection of programs submitted by Dave. He is busy joining the forum.
First off a Match Blox game.
First off a Match Blox game.
'Match Blox by Dave De Yoreo
'Windows version created December 2009
'No Rights Reserved - CopyLeft
'Windows version in Liberty Basic for Windows
'Windows version compiled using the BBC Liberty Basic Booster
'Amiga version created in 1987
'Originally from Comodore magazine March, 1987
'ALso appeared in Compute's Gazette, Nov 1987
[main]
nomainwin 'no output window
'regen due to duplicate pattern flag
recast = 0:patts = 1
WindowWidth = 1366/2
WindowHeight = 790/1.3
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)
'Draw the winning pattern boxes
graphicbox #main.graphicbox10, 335, 7, 100, 100
graphicbox #main.graphicbox20, 335, 107, 100, 100
graphicbox #main.graphicbox30, 335, 207, 100, 100
graphicbox #main.graphicbox40, 435, 7, 100, 100
graphicbox #main.graphicbox50, 435, 107, 100, 100
graphicbox #main.graphicbox60, 435, 207, 100, 100
graphicbox #main.graphicbox70, 535, 7, 100, 100
graphicbox #main.graphicbox80, 535, 107, 100, 100
graphicbox #main.graphicbox90, 535, 207, 100, 100
' calculate 1 of 8 random winning patterns
[randPattern]
pattern = int(rnd(1)*8)+1 'ran number 1 to 8
if pattern = lastPattern then ' same pattern as last time, regen rand number
goto [randPattern]
else
lastPattern = pattern 'remember the last pattern so there's no 2 in a row
end if
'Draw the player boxes
graphicbox #main.graphicbox9, 215, 207, 100, 100
graphicbox #main.graphicbox8, 115, 207, 100, 100
graphicbox #main.graphicbox7, 15, 207, 100, 100
graphicbox #main.graphicbox6, 215, 107, 100, 100
graphicbox #main.graphicbox5, 115, 107, 100, 100
graphicbox #main.graphicbox4, 15, 107, 100, 100
graphicbox #main.graphicbox3, 215, 7, 100, 100
graphicbox #main.graphicbox2, 115, 7, 100, 100
graphicbox #main.graphicbox1, 15, 7, 100, 100
'Add buttons
button #main.button1,"1",[button1Click], UL, 40, 42, 57, 25
button #main.button2,"2",[button2Click], UL, 135, 42, 57, 25
button #main.button3,"3",[button3Click], UL, 240, 42, 57, 25
button #main.button4,"4",[button4Click], UL, 35, 147, 57, 25
button #main.button5,"5",[button5Click], UL, 135, 147, 57, 25
button #main.button6,"6",[button6Click], UL, 235, 147, 57, 25
button #main.button7,"7",[button7Click], UL, 40, 242, 57, 25
button #main.button8,"8",[button8Click], UL, 135, 242, 57, 25
button #main.button9,"9",[button9Click], UL, 235, 242, 57, 25
'Zero out win and move counters
win = 0
moves = 0
'Move counter display
statictext #main.moves, "Total Moves:", 240, 385, 105, 20
textbox #main.movecounter, 345, 385, 40, 20
'Center the Playfield and Winning Pattern message
statictext #main.center, "Playfield", 125, 315, 130, 20
statictext #main.center1, "Winning Pattern", 420, 315, 130, 20
'Title and Instructions text color
ForegroundColor$= "blue"
BackgroundColor$= "buttonface"
'Title
statictext #main.title, "[]Match BloX[]", 185, 335, 290, 50
' Regen pattern buttons
button #main.regen, "Generate A New Playfield", [regen], UL, 13, 350, 150, 30
button #main.regen2, "Generate A New Pattern", [randPat], UL, 480, 350, 150, 30
groupbox #main.group, "", 5, 430, 515, 105
'Instructions
statictext #main.line1, "Click the numbered squares to make the left block match the right block", 110, 420, 490, 25
statictext #main.line2, "Rules:", 13, 440, 50, 20
statictext #main.line3, "1) Clicking a corner square (1,3,7,9) changes each two adjacent squares plus the center square (5).", 12, 460, 490, 25
statictext #main.line4, "2) Clicking a square in the center of each side (2,4,6,8) changes each adjacent corner square (1, 3, 7, 9).", 12, 485, 530, 25
statictext #main.line5, "3) Clicking the center square changes the adjacent squares (2,4,6,8).", 12, 510, 418, 20
menu #main, "Generate Patterns", "Generate a New Playfield", [regen], "Generate A New Winning Pattern", [randPat], "Quit", [quit]
menu #main, "Match BloX Help", "Match BloX Instructions", [blox], "About Match BloX", [info]
button #main.quit, "Quit", [quit], UL, 570, 510, 60, 30
'Block color vars
green$ = "down; fill green; flush"
red$ = "down; fill red; flush"
'-------------------- Open the Window -------------------
open "Match BloX Swap Colors Game" for window as #main 'no frame
'trap X close icon and send to quit
print #main, "trapclose [quit]"
on error goto [errmsg]
'Make Match Blox title big and bold
fontSize$ = "!font ms_sans_serif 30 bold"
print #main.title, fontSize$
'Make Total Moves text bigger
fontSize$ = "!font ms_sans_serif 12 bold"
print #main.moves, fontSize$
'Winning Pattern
print #main.center, fontSize$
print #main.center1, fontSize$
'Make Rules text bigger
fontSize$ = "!font ms_sans_serif 8 bold"
print #main.line1, fontSize$
[winningpats]
'Winning Pattern Colors
if pattern = 1 then
'All Red
print #main.graphicbox10, red$
print #main.graphicbox20, red$
print #main.graphicbox30, red$
print #main.graphicbox40, red$
print #main.graphicbox50, red$
print #main.graphicbox60, red$
print #main.graphicbox70, red$
print #main.graphicbox80, red$
print #main.graphicbox90, red$
end if
if pattern = 2 then
'All Green
print #main.graphicbox10, green$
print #main.graphicbox20, green$
print #main.graphicbox30, green$
print #main.graphicbox40, green$
print #main.graphicbox50, green$
print #main.graphicbox60, green$
print #main.graphicbox70, green$
print #main.graphicbox80, green$
print #main.graphicbox90, green$
end if
if pattern = 3 then
'Red X
print #main.graphicbox10, red$
print #main.graphicbox20, green$
print #main.graphicbox30, red$
print #main.graphicbox40, green$
print #main.graphicbox50, red$
print #main.graphicbox60, green$
print #main.graphicbox70, red$
print #main.graphicbox80, green$
print #main.graphicbox90, red$
end if
if pattern = 4 then
'Green X
print #main.graphicbox10, green$
print #main.graphicbox20, red$
print #main.graphicbox30, green$
print #main.graphicbox40, red$
print #main.graphicbox50, green$
print #main.graphicbox60, red$
print #main.graphicbox70, green$
print #main.graphicbox80, red$
print #main.graphicbox90, green$
end if
if pattern = 5 then
'Green Center
print #main.graphicbox10, red$
print #main.graphicbox20, red$
print #main.graphicbox30, red$
print #main.graphicbox40, red$
print #main.graphicbox50, green$
print #main.graphicbox60, red$
print #main.graphicbox70, red$
print #main.graphicbox80, red$
print #main.graphicbox90, red$
end if
if pattern = 6 then
'Red Center
print #main.graphicbox10, green$
print #main.graphicbox20, green$
print #main.graphicbox30, green$
print #main.graphicbox40, green$
print #main.graphicbox50, red$
print #main.graphicbox60, green$
print #main.graphicbox70, green$
print #main.graphicbox80, green$
print #main.graphicbox90, green$
end if
if pattern = 7 then
'Green Cross
print #main.graphicbox10, red$
print #main.graphicbox20, green$
print #main.graphicbox30, red$
print #main.graphicbox40, green$
print #main.graphicbox50, green$
print #main.graphicbox60, green$
print #main.graphicbox70, red$
print #main.graphicbox80, green$
print #main.graphicbox90, red$
end if
if pattern = 8 then
'Red Cross
print #main.graphicbox10, green$
print #main.graphicbox20, red$
print #main.graphicbox30, green$
print #main.graphicbox40, red$
print #main.graphicbox50, red$
print #main.graphicbox60, red$
print #main.graphicbox70, green$
print #main.graphicbox80, red$
print #main.graphicbox90, green$
end if
if regenpatt = 1 then goto [movecounter]
'-------------------- Draw game Boxes ----------------------
[blockz]
regen = 0
for blockz = 1 to patts 'random block colors
colorcount = 0
boxcolor1$ = green$
color = int(rnd(1)*2)+1 'random block color
if color = 1 then boxcolor1$ = red$
print #main.graphicbox1, boxcolor1$
colorcount = colorcount + color
boxcolor2$ = green$
color = int(rnd(1)*2)+1
if color = 1 then boxcolor2$ = red$
print #main.graphicbox2, boxcolor2$
colorcount = colorcount + color
boxcolor3$ = green$
color = int(rnd(1)*2)+1
if color = 1 then boxcolor3$ = red$
print #main.graphicbox3, boxcolor3$
colorcount = colorcount + color
boxcolor4$ = green$
color = int(rnd(1)*2)+1
if color = 1 then boxcolor4$ = red$
print #main.graphicbox4, boxcolor4$
colorcount = colorcount + color
boxcolor5$ = green$
color = int(rnd(1)*2)+1
if color = 1 then boxcolor5$ = red$
print #main.graphicbox5, boxcolor5$
colorcount = colorcount + color
boxcolor6$ = green$
color = int(rnd(1)*2)+1
if color = 1 then boxcolor6$ = red$
print #main.graphicbox6, boxcolor6$
colorcount = colorcount + color
boxcolor7$ = green$
color = int(rnd(1)*2)+1
if color = 1 then boxcolor7$ = red$
print #main.graphicbox7, boxcolor7$
colorcount = colorcount + color
boxcolor8$ = green$
color = int(rnd(1)*2)+1
if color = 1 then boxcolor8$ = red$
print #main.graphicbox8, boxcolor8$
colorcount = colorcount + color
boxcolor9$ = green$
color = int(rnd(1)*2)+1
if color = 1 then boxcolor9$ = red$
print #main.graphicbox9, boxcolor9$
colorcount = colorcount + color
next blockz 'color
if colorcount = 9 then goto [blockz]
if colorcount = 18 then goto [blockz]
'-------------- Display Number of Moves --------------
[movecounter]
print #main.movecounter, moves
if regen or regenpatt = 1 then
regen = 0
regenpatt = 0
'goto [wait]
end if
'------------------- Winner Loop -----------------------
[loop]
'------------------------- Center Red Winner Check --------------------------------------
'1 all_Red
if pattern = 1 then
if boxcolor1$ = red$ then
if boxcolor2$ = red$ then
if boxcolor3$ = red$ then
if boxcolor4$ = red$ then
if boxcolor5$ = red$ then
if boxcolor6$ = red$ then
if boxcolor7$ = red$ then
if boxcolor8$ = red$ then
if boxcolor9$ = red$ then
win = 1
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
'2 all Green
if pattern = 2 then
if boxcolor1$ = green$ then
if boxcolor2$ = green$ then
if boxcolor3$ = green$ then
if boxcolor4$ = green$ then
if boxcolor5$ = green$ then
if boxcolor6$ = green$ then
if boxcolor7$ = green$ then
if boxcolor8$ = green$ then
if boxcolor9$ = green$ then
win = 1
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
'3 Red X
if pattern = 3 then
if boxcolor1$ = red$ then
if boxcolor2$ = green$ then
if boxcolor3$ = red$ then
if boxcolor4$ = green$ then
if boxcolor5$ = red$ then
if boxcolor6$ = green$ then
if boxcolor7$ = red$ then
if boxcolor8$ = green$ then
if boxcolor9$ = red$ then
win = 1
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
'4 Green X
if pattern = 4 then
if boxcolor1$ = green$ then
if boxcolor2$ = red$ then
if boxcolor3$ = green$ then
if boxcolor4$ = red$ then
if boxcolor5$ = green$ then
if boxcolor6$ = red$ then
if boxcolor7$ = green$ then
if boxcolor8$ = red$ then
if boxcolor9$ = green$ then
win = 1
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
'5 Center Green
if pattern = 5 then
if boxcolor1$ = red$ then
if boxcolor2$ = red$ then
if boxcolor3$ = red$ then
if boxcolor4$ = red$ then
if boxcolor5$ = green$ then
if boxcolor6$ = red$ then
if boxcolor7$ = red$ then
if boxcolor8$ = red$ then
if boxcolor9$ = red$ then
win = 1
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
'6 Center Red
if pattern = 6 then
if boxcolor1$ = green$ then
if boxcolor2$ = green$ then
if boxcolor3$ = green$ then
if boxcolor4$ = green$ then
if boxcolor5$ = red$ then
if boxcolor6$ = green$ then
if boxcolor7$ = green$ then
if boxcolor8$ = green$ then
if boxcolor9$ = green$ then
win = 1
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
'7 Green Cross
if pattern = 7 then
if boxcolor1$ = red$ then
if boxcolor2$ = green$ then
if boxcolor3$ = red$ then
if boxcolor4$ = green$ then
if boxcolor5$ = green$ then
if boxcolor6$ = green$ then
if boxcolor7$ = red$ then
if boxcolor8$ = green$ then
if boxcolor9$ = red$ then
win = 1
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
'8 Red Cross
if pattern = 8 then
if boxcolor1$ = green$ then
if boxcolor2$ = red$ then
if boxcolor3$ = green$ then
if boxcolor4$ = red$ then
if boxcolor5$ = red$ then
if boxcolor6$ = red$ then
if boxcolor7$ = green$ then
if boxcolor8$ = red$ then
if boxcolor9$ = green$ then
win = 1
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
'-------------------- Winner -----------------
[winner]
if win = 1 then
if moves = 0 then
recast = 1
end if
end if
if recast = 1 then goto [regen]
moves$ = str$(moves) 'move counter as string for winner text in Confirm box
if win = 1 then
if moves < 10 then confirmText$ = moves$+" Moves Is Expert Level" + chr$(13)
if moves > 9 and moves < 21 then confirmText$ = moves$+" Moves Is Professional Level" + chr$(13)
if moves > 20 and moves < 31 then confirmText$ = moves$+" Moves Is Amateur Level" + chr$(13)
if moves > 30 then confirmText$ = moves$+" Moves Is Baby Level" + chr$(13)
confirmText$ = confirmText$ + "Play Again?"
confirm confirmText$; answer$
if answer$ = "yes" then 'play again
close #main 'close GUI
goto [main] 'restart
else
goto [quit]
end if
end if
'----------------------- Wait Here for Mouse Clicks --------------------
[wait]
wait
' ------------------Button 1 -----------------
[button1Click]
'if button 1 then 2,4,5 also
if boxcolor1$ = green$ then
boxcolor1$ = red$
else
boxcolor1$ = green$
end if
print #main.graphicbox1, boxcolor1$
if boxcolor2$ = green$ then
boxcolor2$ = red$
else
boxcolor2$ = green$
end if
print #main.graphicbox2, boxcolor2$
if boxcolor4$ = green$ then
boxcolor4$ = red$
else
boxcolor4$ = green$
end if
print #main.graphicbox4, boxcolor4$
if boxcolor5$ = green$ then
boxcolor5$ = red$
else
boxcolor5$ = green$
end if
print #main.graphicbox5, boxcolor5$
goto [movecount]
' ------------------Button 2 -----------------
[button2Click]
'if button 2 then 1 & 3 also
if boxcolor2$ = green$ then
boxcolor2$ = red$
else
boxcolor2$ = green$
end if
print #main.graphicbox2, boxcolor2$
if boxcolor1$ = green$ then
boxcolor1$ = red$
else
boxcolor1$ = green$
end if
print #main.graphicbox1, boxcolor1$
if boxcolor3$ = green$ then
boxcolor3$ = red$
else
boxcolor3$ = green$
end if
print #main.graphicbox3, boxcolor3$
goto [movecount]
' ------------------Button 3 -----------------
[button3Click]
'if button 3 then 2,5,6 also
if boxcolor3$ = green$ then
boxcolor3$ = red$
else
boxcolor3$ = green$
end if
print #main.graphicbox3, boxcolor3$
if boxcolor2$ = green$ then
boxcolor2$ = red$
else
boxcolor2$ = green$
end if
print #main.graphicbox2, boxcolor2$
if boxcolor5$ = green$ then
boxcolor5$ = red$
else
boxcolor5$ = green$
end if
print #main.graphicbox5, boxcolor5$
if boxcolor6$ = green$ then
boxcolor6$ = red$
else
boxcolor6$ = green$
end if
print #main.graphicbox6, boxcolor6$
goto [movecount]
' ------------------Button 4 -----------------
[button4Click]
'if button 4 then 1 & 7 too
if boxcolor4$ = green$ then
boxcolor4$ = red$
else
boxcolor4$ = green$
end if
print #main.graphicbox4, boxcolor4$
if boxcolor1$ = green$ then
boxcolor1$ = red$
else
boxcolor1$ = green$
end if
print #main.graphicbox1, boxcolor1$
if boxcolor7$ = green$ then
boxcolor7$ = red$
else
boxcolor7$ = green$
end if
print #main.graphicbox7, boxcolor7$
goto [movecount]
' ------------------Button 5 Center -----------------
[button5Click]
'if button 5 then 2,4,6,8 as well
if boxcolor5$ = green$ then
boxcolor5$ = red$
else
boxcolor5$ = green$
end if
print #main.graphicbox5, boxcolor5$
if boxcolor2$ = green$ then
boxcolor2$ = red$
else
boxcolor2$ = green$
end if
print #main.graphicbox2, boxcolor2$
if boxcolor4$ = green$ then
boxcolor4$ = red$
else
boxcolor4$ = green$
end if
print #main.graphicbox4, boxcolor4$
if boxcolor6$ = green$ then
boxcolor6$ = red$
else
boxcolor6$ = green$
end if
print #main.graphicbox6, boxcolor6$
if boxcolor8$ = green$ then
boxcolor8$ = red$
else
boxcolor8$ = green$
end if
print #main.graphicbox8, boxcolor8$
goto [movecount]
' ------------------Button 6 -----------------
[button6Click]
'if button 6 then 3,9
if boxcolor6$ = green$ then
boxcolor6$ = red$
else
boxcolor6$ = green$
end if
print #main.graphicbox6, boxcolor6$
if boxcolor3$ = green$ then
boxcolor3$ = red$
else
boxcolor3$ = green$
end if
print #main.graphicbox3, boxcolor3$
if boxcolor9$ = green$ then
boxcolor9$ = red$
else
boxcolor9$ = green$
end if
print #main.graphicbox9, boxcolor9$
goto [movecount]
' ------------------Button 7 -----------------
[button7Click]
'if button 7 then 4,5,8
if boxcolor7$ = green$ then
boxcolor7$ = red$
else
boxcolor7$ = green$
end if
print #main.graphicbox7, boxcolor7$
if boxcolor4$ = green$ then
boxcolor4$ = red$
else
boxcolor4$ = green$
end if
print #main.graphicbox4, boxcolor4$
if boxcolor5$ = green$ then
boxcolor5$ = red$
else
boxcolor5$ = green$
end if
print #main.graphicbox5, boxcolor5$
if boxcolor8$ = green$ then
boxcolor8$ = red$
else
boxcolor8$ = green$
end if
print #main.graphicbox8, boxcolor8$
goto [movecount]
' ------------------Button 8 -----------------
[button8Click]
'if button 8 then 7,9
if boxcolor8$ = green$ then
boxcolor8$ = red$
else
boxcolor8$ = green$
end if
print #main.graphicbox8, boxcolor8$
if boxcolor7$ = green$ then
boxcolor7$ = red$
else
boxcolor7$ = green$
end if
print #main.graphicbox7, boxcolor7$
if boxcolor9$ = green$ then
boxcolor9$ = red$
else
boxcolor9$ = green$
end if
print #main.graphicbox9, boxcolor9$
goto [movecount]
' ------------------Button 9 -----------------
[button9Click]
'if button 9 then 5,6,8
if boxcolor9$ = green$ then
boxcolor9$ = red$
else
boxcolor9$ = green$
end if
print #main.graphicbox9, boxcolor9$
if boxcolor5$ = green$ then
boxcolor5$ = red$
else
boxcolor5$ = green$
end if
print #main.graphicbox5, boxcolor5$
if boxcolor6$ = green$ then
boxcolor6$ = red$
else
boxcolor6$ = green$
end if
print #main.graphicbox6, boxcolor6$
if boxcolor8$ = green$ then
boxcolor8$ = red$
else
boxcolor8$ = green$
end if
print #main.graphicbox8, boxcolor8$
goto [movecount]
'------------------------------------ Move Count --------------
[movecount]
moves = moves + 1
print #main.movecounter, moves
goto [loop]
'----------------------- Center Win Info Button NOP ----------
[buttoncenter]
goto [wait]
'----------------------- Regenerate the Pattern ---------------
[regen]
regen = 1
win = 0
moves = 0
recast = 0
goto [blockz]
'------------------------------------ Quit --------------
[quit]
close #main
end
[info]
Notice "Match BloX" +chr$(13)+ "Match BloX was created using Liberty Basic for Windows:"_
+chr$(13)+ "(www.libertybasic.com)"_
+chr$(13)+ " "_
+chr$(13)+ "Open Source - No Rights Reserved by Dave De Yoreo, 2009"
wait
[blox]
Notice "About Match BloX"+chr$(13)+"Match Blox is a block-swap-colors game."_
+chr$(13) +" "_
+chr$(13)+ "Match BloX starts with a Playfield block on the left and a Winning Pattern block on the right."_
+chr$(13) +" "_
+chr$(13)+ "The object is to make the Playfield block match the Winning Pattern block by clicking the playfield numbered squares."_
+chr$(13) +" "_
+chr$(13)+ "- Game Play:"_
+chr$(13)+ "Clicking a numbered square causes certain squares to change in the following ways:"_
+chr$(13) +" "_
+chr$(13)+ "1) Clicking a corner square (1,3,7,9) swaps the color of that square, each adjacent square, and the center square (5)."_
+chr$(13) +" "_
+chr$(13)+ "2) Clicking a square in the center of each side (2,4,6,8) swaps the colors of that square and of each corner square (1, 3, 7, 9)."_
+chr$(13) +" "_
+chr$(13) +"3) Clicking the center square (5) swaps the colors of the center square and the adjacent squares (2,4,6,8) - Forms a cross."_
+chr$(13) +" "_
+chr$(13) +"- Generating New Patterns:"_
+chr$(13) +"Click the Generate A New Playfield or Generate A New Pattern button to display a new playfield or winning pattern. In this case, the Total Moves counter is set to 0 for a new game."
wait
[errmsg]
notice "Unknown Error"+chr$(13)+"An unknown error occured"
wait
' calculate 1 of 8 random winning patterns
[randPat]
regenpatt= 1
moves = 0
pattern = int(rnd(1)*8)+1 'ran number 1 to 8
if pattern = lastPattern then ' same pattern as last time, regen rand number
goto [randPat]
else
lastPattern = pattern 'remember the last pattern so there's no 2 in a row
end if
goto [winningpats]