View.Set ("graphics:787;492;nocursor")
%%%%%%%%%%%%%%%%%%%%%%
%% GLOBAL VARIABLES %%
%%%%%%%%%%%%%%%%%%%%%%
var playerName : array 1 .. 4 of string := init ("Comp 1", "Comp 2", "Comp 3", "Comp 4")
var font1 := Font.New ("Arial:40:bold")
var font2 := Font.New ("Arial:15:bold")
var font3 := Font.New ("Arial:12:bold")
var players : int := 0
var Roll : int
var turn : int := 0
var playerx : array 1 .. 4, 1 .. 4 of int
var playery : array 1 .. 4, 1 .. 4 of int
var playerCounter : array 1 .. 4 of int := init (0, 0, 0, 0)
var circleCounter : array 1 .. 4, 1 .. 4 of int
var mousex, mousey : int
var button : int
var stream : int
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Stets all circleCounters to 0
for row : 1 .. 4
for col : 1 .. 4
circleCounter (row, col) := 0
end for
end for
%%%putting numbers into array from file%%%
%into x array%
open : stream, "playerarrayx.t", get
for row : 1 .. 4
for col : 1 .. 4
get : stream, playerx (row, col)
end for
end for
close : stream
%into y array%
open : stream, "playerarrayy.t", get
for row : 1 .. 4
for col : 1 .. 4
get : stream, playery (row, col)
end for
end for
close : stream
proc menu
var input : string (1)
%%MENU PART%%
loop
loop
Draw.Fill (1, 1, black, black)
Font.Draw ("TROUBLE!!", 250, maxy - 50, font1, Rand.Int (9, 14)) %title
locate (maxrow div 2 - 1, maxcol div 2 - 6)
colour (Rand.Int (9, 14))
colourback (black)
Draw.Box (294, 266, 473, 285, Rand.Int (9, 14))
put "Start Game!!" .. %%button
locate (maxrow div 2 + 1, maxcol div 2 - 6)
colour (Rand.Int (9, 14))
colourback (black)
Draw.Box (294, 234, 480, 253, Rand.Int (9, 14))
put "Instructions." .. %%button
locate (maxrow, 2)
Draw.Box (5, 8, 43, 29, Rand.Int (9, 14))
put "Back" .. %%button
loop
Mouse.Where (mousex, mousey, button)
if button = 1 and mousex >= 294 and mousex <= 473 and mousey > 266 and mousey < 285 then
Draw.Cls
exit
elsif button = 1 and mousex >= 294 and mousex <= 480 and mousey > 234 and mousey < 253 then
%%%Instructions%%%
locate (7, maxcol div 2 - 15)
put "This is the game of TROUBLE!!!"
locate (8, maxcol div 2 - 36)
put "All you have to do is get you're players (there's 4)around the board once!!"
locate (9, maxcol div 2 - 39)
put "The first thing you have to do is write how many players are going to play(1-4)."
locate (10, maxcol div 2 - 21)
put "Then you need to choose who will go first."
locate (11, maxcol div 2 - 33)
put "You do this by rolling the little die in the middle of the screen."
locate (12, maxcol div 2 - 31)
put "You will then wait for you're turn and when it starts you roll."
locate (13, maxcol div 2 - 16)
put "(press any button to roll the die again)"
locate (14, maxcol div 2 - 23)
put "Next you choose which player you want to move."
locate (15, maxcol div 2 - 21)
put "(On the first turn it will move player #1.)"
locate (16, maxcol div 2 - 29)
put "You just do that until someone wins, then the game is done."
put ""
locate (18, maxcol div 2 - 29)
put "click to go back"
Time.Delay (500)
button := 0
loop
Mouse.Where (mousex, mousey, button)
exit when button = 1
end loop
Draw.Cls
exit
elsif button = 1 and mousex >= 5 and mousex <= 43 and mousey >= 8 and mousey <= 29 then
exit
elsif button = 1 then
exit
end if
end loop
if button = 1 and mousex >= 294 and mousex <= 473 and mousey > 266 and mousey < 285 then
exit
elsif button = 1 and mousex >= 5 and mousex <= 43 and mousey >= 8 and mousey <= 29 then
exit
end if
end loop
if button = 1 and mousex >= 294 and mousex <= 473 and mousey > 266 and mousey < 285 then
exit
elsif button = 1 and mousex >= 5 and mousex <= 43 and mousey >= 8 and mousey <= 29 then
exit
end if
end loop
end menu
%%% WHEN USER WANTS TO START %%%
proc startGame
var numPlayers : string (1)
locate (maxrow div 2, 1)
colour (white)
Draw.Fill (1, 1, black, black)
put "How many players are going to play today? (1-4)"
getch (numPlayers)
%% in case they don't put 1-4
if numPlayers = "1" or numPlayers = "2" or numPlayers = "3" or numPlayers = "4" then
else
locate (maxrow div 2 + 1, 1)
put "You can only have 1-4 players!"
getch (numPlayers)
end if
players := strint (numPlayers)
Draw.Cls
locate (maxrow div 2, 1)
Draw.Fill (1, 1, black, black)
%%putting in names
if numPlayers = "1" then
put "What is player 1's name? "
get playerName (1)
put "Hello ", playerName (1)
elsif numPlayers = "2" then
put "What is player 1's name? "
get playerName (1)
put "What is player 2's name? "
get playerName (2)
put "Hello ", playerName (1), " , ", playerName (2)
elsif numPlayers = "3" then
put "What is player 1's name? "
get playerName (1)
put "What is player 2's name? "
get playerName (2)
put "What is player 3's name? "
get playerName (3)
put "Hello ", playerName (1), " , ", playerName (2), " , ", playerName (3)
elsif numPlayers = "4" then
put "What is player 1's name? "
get playerName (1)
put "What is player 2's name? "
get playerName (2)
put "What is player 3's name? "
get playerName (3)
put "What is player 4's name? "
get playerName (4)
put "Hello ", playerName (1), " , ", playerName (2), " , ", playerName (3), " , ", playerName (4)
end if
Time.Delay (2000)
Draw.Cls
end startGame
procedure board
%%%BOARD FOR TROUBLE%%%
Draw.Box (maxx - 5, maxy - 5, 5, 5, black)
Draw.Oval (maxx div 2, maxy div 2, 56, 56, black)
%%TOP%%
Draw.Arc (maxx div 2, maxy div 2, 59, 59, 35, -215, brightgreen)
Draw.ThickLine (maxx div 2 + 49, maxy div 2 + 35, maxx - 7, maxy - 7, 5, brightgreen)
Draw.ThickLine (maxx - 7, maxy - 7, 7, maxy - 7, 5, brightgreen)
Draw.ThickLine (maxx div 2 - 49, maxy div 2 + 35, 7, maxy - 7, 5, brightgreen)
Draw.Fill (maxx div 2, maxy div 2 + 70, brightgreen, brightgreen)
%%RIGHT%%
Draw.Arc (maxx div 2, maxy div 2, 60, 60, -45, 32, blue)
Draw.ThickLine (maxx div 2 + 49, maxy div 2 + 33, maxx - 7, maxy - 9, 5, blue)
Draw.ThickLine (maxx div 2 + 47, maxy div 2 - 43, maxx - 7, 7, 5, blue)
Draw.ThickLine (maxx - 7, 7, maxx - 7, maxy - 9, 5, blue)
Draw.Fill (maxx div 2 + 70, maxy div 2, blue, blue)
%%BOTTOM%%
Draw.Arc (maxx div 2, maxy div 2, 59, 59, -143, -46, brightred)
Draw.ThickLine (maxx div 2 + 43, maxy div 2 - 41, maxx - 7, 7, 5, brightred)
Draw.ThickLine (maxx div 2 - 49, maxy div 2 - 35, 7, 7, 5, brightred)
Draw.ThickLine (maxx - 7, 7, 7, 7, 5, brightred)
Draw.Fill (maxx div 2, maxy div 2 - 70, brightred, brightred)
%%LEFT%%
Draw.Arc (maxx div 2, maxy div 2, 59, 59, -214, -145, yellow)
Draw.ThickLine (maxx div 2 - 48, maxy div 2 + 33, 7, maxy - 7, 5, yellow)
Draw.ThickLine (maxx div 2 - 48, maxy div 2 - 33, 7, 7, 5, yellow)
Draw.ThickLine (7, 7, 7, maxy - 7, 5, yellow)
Draw.Fill (maxx div 2 - 70, maxy div 2, yellow, yellow)
%%%CIRCLES%%%
var y : int := 25
var x : int := 35
%% left
for z : 1 .. 10
Draw.FillOval (x, y, 15, 15, white)
Draw.Oval (x, y, 15, 15, black)
if z = 10 then
exit
else
y += 49
end if
end for
%% top
for z : 1 .. 10
Draw.FillOval (x, y, 15, 15, white)
Draw.Oval (x, y, 15, 15, black)
if z = 10 then
exit
else
x += 79
end if
end for
%% right
for z : 1 .. 10
Draw.FillOval (x, y, 15, 15, white)
Draw.Oval (x, y, 15, 15, black)
if z = 10 then
exit
else
y -= 49
end if
end for
%% bottom
for z : 1 .. 10
Draw.FillOval (x, y, 15, 15, white)
Draw.Oval (x, y, 15, 15, black)
if z = 10 then
exit
else
x -= 79
end if
end for
%% from bottom left to top right
for z : 1 .. 10
Draw.FillOval (x + 47, y + 26, 15, 15, white)
if z = 5 then
else
Draw.Oval (x + 47, y + 26, 15, 15, black)
end if
y += 49
x += 79
end for
y := 460
x := 35
%% from top left to bottom right
for z : 1 .. 10
Draw.FillOval (x + 47, y - 26, 15, 15, white)
if z = 5 then
else
Draw.Oval (x + 47, y - 26, 15, 15, black)
end if
y -= 49
x += 79
end for
end board
%% putting number on die
proc num (var Bx, By : int)
var rollDie : int := Rand.Int (1, 6)
if rollDie = 1 then
Font.Draw ("1", Bx + 15, By + 15, font2, Rand.Int (9, 14))
elsif rollDie = 2 then
Font.Draw ("2", Bx + 15, By + 15, font2, Rand.Int (9, 14))
elsif rollDie = 3 then
Font.Draw ("3", Bx + 15, By + 15, font2, Rand.Int (9, 14))
elsif rollDie = 4 then
Font.Draw ("4", Bx + 15, By + 15, font2, Rand.Int (9, 14))
elsif rollDie = 5 then
Font.Draw ("5", Bx + 15, By + 15, font2, Rand.Int (9, 14))
elsif rollDie = 6 then
Font.Draw ("6", Bx + 15, By + 15, font2, Rand.Int (9, 14))
end if
Roll := rollDie
end num
proc dieRoll (player : int)
Draw.FillOval (maxx div 2, maxy div 2, 54, 54, white)
var roll : string (1)
var Bx, By, Tx, Ty : int
var BxChange, ByChange : int
BxChange := Rand.Int (1,5) %% makes it bounce different every time
ByChange := Rand.Int (1,5)
Bx := maxx div 2 - 20
By := maxy div 2 - 20
Tx := Bx + 40
Ty := By + 40
var hits : int := 0
locate (4, 15)
put repeat (" ", 70) ..
%% if it's comp.'s turn
if playerName (player) = "Comp 2" or playerName (player) = "Comp 3" or playerName (player) = "Comp 4" then
locate (4, 15)
put "The computer will roll automatically " ..
else
locate (4, 15)
put "click in the circle to roll " ..
loop
Mouse.Where (mousex, mousey, button)
exit when button = 1 and mousex > maxx div 2 - 55 and mousex < maxx div 2 + 55 and mousey < maxy div 2 + 55 and mousey > maxy div 2 - 55
end loop
end if
loop
Draw.Oval (maxx div 2, maxy div 2, 55, 55, black)
Time.Delay (100)
Draw.Box (Bx, By, Tx, Ty, black)
num (Bx, By)
Draw.FillOval (maxx div 2, maxy div 2, 54, 54, white)
Bx += BxChange
By += ByChange
Tx := Bx + 40
Ty := By + 40
Draw.Box (Bx, By, Tx, Ty, black)
num (Bx, By)
%% if it hits the side
if whatdotcolour (Bx - 5, By) = black or whatdotcolour (Bx, By - 5) = black or whatdotcolour (Bx - 5, By - 5) = black or whatdotcolour (Bx - 5, By - 5) not= colourbg then
BxChange := -BxChange
ByChange := -ByChange
hits += 1
elsif whatdotcolour (Tx + 5, Ty) = black or whatdotcolour (Tx, Ty + 5) = black or whatdotcolour (Tx + 5, Ty + 5) = black or whatdotcolour (Tx + 5, Ty + 5) not= colourbg then
BxChange := -BxChange
ByChange := -ByChange
hits += 1
end if
Bx += BxChange
By += ByChange
Tx := Bx + 40
Ty := By + 40
exit when hits = 4
end loop
locate (4, 15)
put repeat (" ", 70) ..
locate (4, 15)
put " You rolled a ", Roll ..
Time.Delay (500)
end dieRoll
%%% FIRST TURN %%%
proc firstRoll
var playerRoll : array 1 .. 4 of int
var high, low : int := 0
low := 100
board
for x : 1 .. 4
turn := (x)
locate (4, 15)
put repeat (" ", 70) ..
locate (4, 15)
put "Roll to see who goes first, " ..
put playerName (x), " its your turn " ..
Time.Delay (2000)
dieRoll (turn)
playerRoll (x) := Roll
if Roll > high then
high := Roll
elsif Roll < low then
low := Roll
end if
end for
locate (4, 15)
put repeat (" ", 70) ..
locate (4, 15)
if playerRoll (1) > playerRoll (2) and playerRoll (1) > playerRoll (3) and playerRoll (1) > playerRoll (4) then
put playerName (1), " goes first" ..
turn := 1
elsif playerRoll (2) > playerRoll (3) and playerRoll (2) > playerRoll (4) then
put playerName (2), " goes first" ..
turn := 2
elsif playerRoll (3) > playerRoll (4) then
put playerName (3), " goes first" ..
turn := 3
else
put playerName (4), " goes first" ..
turn := 4
end if
end firstRoll
%%%%%
proc lastMove (player, playerMove : int)
if circleCounter (player, playerMove) >= 35 then
%%% for red to get to end
if whatdotcolour (playerx (player, playerMove), playery (player, playerMove)) = brightred then
Draw.FillOval (playerx (player, playerMove), playery (player, playerMove), 14, 14, white)
playerx (player, playerMove) := 319
playery (player, playerMove) := 198
loop
%% if spaces are taken
if whatdotcolour (playerx (player, playerMove), playery (player, playerMove)) = brightred and playerCounter (player) > 1 then
if playerCounter (player) = 2 then
playerx (player, playerMove) := 240
playerx (player, playerMove) := 149
elsif playerCounter (player) = 3 then
playerx (player, playerMove) := 161
playery (player, playerMove) := 100
elsif playerCounter (player) = 4 then
playerx (player, playerMove) := 82
playery (player, playerMove) := 51
end if
end if
exit when whatdotcolour (playerx (player, playerMove), playery (player, playerMove)) = white
end loop
playerCounter (player) += 1
end if
%%% for yellow to get to end
if whatdotcolour (playerx (player, playerMove), playery (player, playerMove)) = yellow then
playerx (player, playerMove) := 319
playery (player, playerMove) := 339
loop
%% if spaces are taken
if whatdotcolour (playerx (player, playerMove), playery (player, playerMove)) = yellow and playerCounter (player) > 1 then
if playerCounter (player) = 2 then
playerx (player, playerMove) := 240
playery (player, playerMove) := 388
elsif playerCounter (player) = 3 then
playerx (player, playerMove) := 161
playery (player, playerMove) := 437
elsif playerCounter (player) = 4 then
playerx (player, playerMove) := 82
playery (player, playerMove) := 486
end if
end if
exit when whatdotcolour (playerx (player, playerMove), playery (player, playerMove)) = white
end loop
playerCounter (player) += 1
end if
%%% for green to get to end
if whatdotcolour (playerx (player, playerMove), playery (player, playerMove)) = brightgreen then
playerx (player, playerMove) := 477
playery (player, playerMove) := 296
loop
%% if spaces are taken
if whatdotcolour (playerx (player, playerMove), playery (player, playerMove)) = brightgreen and playerCounter (player) > 1 then
if playerCounter (player) = 2 then
playerx (player, playerMove) := 556
playery (player, playerMove) := 345
elsif playerCounter (player) = 3 then
playerx (player, playerMove) := 635
playery (player, playerMove) := 394
elsif playerCounter (player) = 4 then
playerx (player, playerMove) := 714
playery (player, playerMove) := 443
end if
end if
exit when whatdotcolour (playerx (player, playerMove), playery (player, playerMove)) = white
end loop
playerCounter (player) += 1
end if
%%% for blue to get to end
if whatdotcolour (playerx (player, playerMove), playery (player, playerMove)) = blue then
playerx (player, playerMove) := 477
playery (player, playerMove) := 241
loop
%% if spaces are taken
if whatdotcolour (playerx (player, playerMove), playery (player, playerMove)) = blue and playerCounter (player) > 1 then
if playerCounter (player) = 2 then
playerx (player, playerMove) := 556
playery (player, playerMove) := 192
elsif playerCounter (player) = 3 then
playerx (player, playerMove) := 635
playery (player, playerMove) := 143
elsif playerCounter (player) = 4 then
playerx (player, playerMove) := 714
playery (player, playerMove) := 94
end if
end if
exit when whatdotcolour (playerx (player, playerMove), playery (player, playerMove)) = white
end loop
playerCounter (player) += 1
end if
end if
end lastMove
%% if you land on your own player
proc jump (player, playerMove : int)
if playery (player, playerMove) >= 25 and playery (player, playerMove) < 466 and playerx (player, playerMove) = 35 then
playery (player, playerMove) += 49
circleCounter (turn, playerMove) += 1
elsif playery (player, playerMove) = 466 and playerx (player, playerMove) < 746 and playerx (player, playerMove) >= 35 then
playerx (player, playerMove) += 79
circleCounter (turn, playerMove) += 1
elsif playery (player, playerMove) > 25 and playery (player, playerMove) <= 466 and playerx (player, playerMove) = 746 then
playery (player, playerMove) -= 49
circleCounter (turn, playerMove) += 1
elsif playery (player, playerMove) = 25 and playerx (player, playerMove) <= 746 and playerx (player, playerMove) > 35 then
playerx (player, playerMove) -= 79
circleCounter (turn, playerMove) += 1
end if
end jump
proc moveAround (player, playerMove, Roll : int)
if whatdotcolour (playerx (player, playerMove), playery (player, playerMove)) not= colourbg and circleCounter (player, playerMove) = 0 then
else
Draw.FillOval (playerx (player, playerMove), playery (player, playerMove), 14, 14, white)
end if
lastMove (player, playerMove)
for go : 1 .. Roll
lastMove (player, playerMove)
%%up
if playery (player, playerMove) >= 25 and playery (player, playerMove) < 466 and playerx (player, playerMove) = 35 then
playery (player, playerMove) += 49
%%right
elsif playery (player, playerMove) = 466 and playerx (player, playerMove) < 746 and playerx (player, playerMove) >= 35 then
playerx (player, playerMove) += 79
%%down
elsif playery (player, playerMove) > 25 and playery (player, playerMove) <= 466 and playerx (player, playerMove) = 746 then
playery (player, playerMove) -= 49
%%left
elsif playery (player, playerMove) = 25 and playerx (player, playerMove) <= 746 and playerx (player, playerMove) > 35 then
playerx (player, playerMove) -= 79
end if
lastMove (player, playerMove)
if go = Roll then
lastMove (player, playerMove)
%% in case you land on someone elses piece
if whatdotcolour (playerx (player, playerMove), playery (player, playerMove)) not= colourbg then
loop
%% if you land on red
if whatdotcolour (playerx (player, playerMove) - 12, playery (player, playerMove)) = brightred then
if playerx (player, playerMove) = playerx (1, playerMove) and playery (player,
playerMove) = playery (1, playerMove) then
jump (player, playerMove)
elsif playerx (player, playerMove) = playerx (1, 1) and playery (player, playerMove) = playery (1, 1) then
playerx (1, 1) := 35
playery (1, 1) := 74
circleCounter (1, 1) := 0
locate (25, maxcol div 2 - 19)
colourback (brightred)
put "You sent ", playerName (1), "'s 1 back to the beginning" ..
Draw.FillOval (playerx (player, playerMove), playery (player, playerMove), 14, 14, white)
Time.Delay (2000)
locate (25, maxcol div 2 - 25)
put repeat (" ", 52) ..
elsif playerx (player, playerMove) = playerx (1, 2) and playery (player, playerMove) = playery (1, 2) then
playerx (1, 2) := 35
playery (1, 2) := 74
circleCounter (1, 2) := 0
locate (25, maxcol div 2 - 19)
colourback (brightred)
put "You sent ", playerName (1), "'s 2 back to the beginning" ..
Time.Delay (2000)
Draw.FillOval (playerx (player, playerMove), playery (player, playerMove), 14, 14, white)
Time.Delay (2000)
locate (25, maxcol div 2 - 25)
put repeat (" ", 52) ..
elsif playerx (player, playerMove) = playerx (1, 3) and playery (player, playerMove) = playery (1, 3) then
playerx (1, 3) := 35
playery (1, 3) := 74
circleCounter (1, 3) := 0
locate (25, maxcol div 2 - 19)
colourback (brightred)
put "You sent ", playerName (1), "'s 3 back to the beginning" ..
Time.Delay (2000)
Draw.FillOval (playerx (player, playerMove), playery (player, playerMove), 14, 14, white)
Time.Delay (2000)
locate (25, maxcol div 2 - 25)
put repeat (" ", 52) ..
elsif playerx (player, playerMove) = playerx (1, 4) and playery (player, playerMove) = playery (1, 4) then
playerx (1, 4) := 35
playery (1, 4) := 74
circleCounter (1, 4) := 0
locate (25, maxcol div 2 - 19)
colourback (brightred)
put "You sent ", playerName (1), "'s 4 back to the beginning" ..
Time.Delay (2000)
Draw.FillOval (playerx (player, playerMove), playery (player, playerMove), 14, 14, white)
Time.Delay (2000)
locate (25, maxcol div 2 - 25)
put repeat (" ", 52) ..
end if
end if
%% if you land on yellow
if whatdotcolour (playerx (player, playerMove) - 12, playery (player, playerMove)) = yellow then
if playerx (player, playerMove) = playerx (2, playerMove) and playery (player,
playerMove) = playery (2, playerMove) then
jump (player, playerMove)
elsif playerx (player, playerMove) = playerx (2, 1) and playery (player, playerMove) = playery (2, 1) then
playerx (2, 1) := 114
playery (2, 1) := 466
circleCounter (2, 1) := 0
locate (25, maxcol div 2 - 19)
colourback (brightred)
put "You sent ", playerName (2), "'s 1 back to the beginning" ..
Time.Delay (2000)
Draw.FillOval (playerx (player, playerMove), playery (player, playerMove), 14, 14, white)
Time.Delay (2000)
locate (25, maxcol div 2 - 25)
put repeat (" ", 52) ..
elsif playerx (player, playerMove) = playerx (2, 2) and playery (player, playerMove) = playery (2, 2) then
playerx (2, 2) := 114
playery (2, 2) := 466
circleCounter (2, 2) := 0
locate (25, maxcol div 2 - 19)
colourback (brightred)
put "You sent ", playerName (2), "'s 2 back to the beginning" ..
Time.Delay (2000)
Draw.FillOval (playerx (player, playerMove), playery (player, playerMove), 14, 14, white)
Time.Delay (2000)
locate (25, maxcol div 2 - 25)
put repeat (" ", 52) ..
elsif playerx (player, playerMove) = playerx (2, 3) and playery (player, playerMove) = playery (2, 3) then
playerx (2, 3) := 114
playery (2, 3) := 466
circleCounter (2, 3) := 0
locate (25, maxcol div 2 - 19)
colourback (brightred)
put "You sent ", playerName (2), "'s 3 back to the beginning" ..
Time.Delay (2000)
Draw.FillOval (playerx (player, playerMove), playery (player, playerMove), 14, 14, white)
Time.Delay (2000)
locate (25, maxcol div 2 - 25)
put repeat (" ", 52) ..
elsif playerx (player, playerMove) = playerx (2, 4) and playery (player, playerMove) = playery (2, 4) then
playerx (2, 4) := 114
playery (2, 4) := 466
circleCounter (2, 4) := 0
locate (25, maxcol div 2 - 19)
colourback (brightred)
put "You sent ", playerName (2), "'s 4 back to the beginning" ..
Time.Delay (2000)
Draw.FillOval (playerx (player, playerMove), playery (player, playerMove), 14, 14, white)
Time.Delay (2000)
locate (25, maxcol div 2 - 25)
put repeat (" ", 52) ..
end if
end if
%% if you land on green
if whatdotcolour (playerx (player, playerMove) - 12, playery (player, playerMove)) = brightgreen then
if playerx (player, playerMove) = playerx (3, playerMove) and playery (player,
playerMove) = playery (3, playerMove) then
jump (player, playerMove)
elsif playerx (player, playerMove) = playerx (3, 1) and playery (player, playerMove) = playery (3, 1) then
playerx (3, 1) := 746
playery (3, 1) := 417
circleCounter (3, 1) := 0
locate (25, maxcol div 2 - 19)
colourback (brightred)
put "You sent ", playerName (3), "'s 1 back to the beginning" ..
Time.Delay (2000)
Draw.FillOval (playerx (player, playerMove), playery (player, playerMove), 14, 14, white)
Time.Delay (2000)
locate (25, maxcol div 2 - 25)
put repeat (" ", 52) ..
elsif playerx (player, playerMove) = playerx (3, 2) and playery (player, playerMove) = playery (3, 2) then
playerx (3, 2) := 746
playery (3, 2) := 417
circleCounter (3, 2) := 0
locate (25, maxcol div 2 - 19)
colourback (brightred)
put "You sent ", playerName (3), "'s 2 back to the beginning" ..
Time.Delay (2000)
Draw.FillOval (playerx (player, playerMove), playery (player, playerMove), 14, 14, white)
Time.Delay (2000)
locate (25, maxcol div 2 - 25)
put repeat (" ", 52) ..
elsif playerx (player, playerMove) = playerx (3, 3) and playery (player, playerMove) = playery (3, 3) then
playerx (3, 3) := 746
playery (3, 3) := 417
circleCounter (3, 3) := 0
locate (25, maxcol div 2 - 19)
colourback (brightred)
put "You sent ", playerName (3), "'s 3 back to the beginning" ..
Time.Delay (2000)
Draw.FillOval (playerx (player, playerMove), playery (player, playerMove), 14, 14, white)
Time.Delay (2000)
locate (25, maxcol div 2 - 25)
put repeat (" ", 52) ..
elsif playerx (player, playerMove) = playerx (3, 4) and playery (player, playerMove) = playery (3, 4) then
playerx (3, 4) := 746
playery (3, 4) := 417
circleCounter (3, 4) := 0
locate (25, maxcol div 2 - 19)
colourback (brightred)
put "You sent ", playerName (3), "'s 4 back to the beginning" ..
Time.Delay (2000)
Draw.FillOval (playerx (player, playerMove), playery (player, playerMove), 14, 14, white)
Time.Delay (2000)
locate (25, maxcol div 2 - 25)
put repeat (" ", 52) ..
end if
end if
%% if you land on blue
if whatdotcolour (playerx (player, playerMove) - 12, playery (player, playerMove)) = blue then
if playerx (player, playerMove) = playerx (4, playerMove) and playery (player, playerMove) = playery (4, playerMove) then
jump (player, playerMove)
elsif playerx (player, playerMove) = playerx (4, 1) and playery (player, playerMove) = playery (4, 1) then
playerx (4, 1) := 667
playery (4, 1) := 25
circleCounter (4, 1) := 0
locate (25, maxcol div 2 - 19)
colourback (brightred)
put "You sent ", playerName (4), "'s 1 back to the beginning" ..
Time.Delay (2000)
Draw.FillOval (playerx (player, playerMove), playery (player, playerMove), 14, 14, white)
Time.Delay (2000)
locate (25, maxcol div 2 - 25)
put repeat (" ", 52) ..
elsif playerx (player, playerMove) = playerx (4, 2) and playery (player, playerMove) = playery (4, 2) then
playerx (4, 2) := 667
playery (4, 2) := 25
circleCounter (4, 2) := 0
locate (25, maxcol div 2 - 19)
colourback (brightred)
put "You sent ", playerName (4), "'s 2 back to the beginning" ..
Time.Delay (2000)
Draw.FillOval (playerx (player, playerMove), playery (player, playerMove), 14, 14, white)
Time.Delay (2000)
locate (25, maxcol div 2 - 25)
put repeat (" ", 52) ..
elsif playerx (player, playerMove) = playerx (4, 3) and playery (player, playerMove) = playery (4, 3) then
playerx (4, 3) := 667
playery (4, 3) := 25
circleCounter (4, 3) := 0
locate (25, maxcol div 2 - 19)
colourback (brightred)
put "You sent ", playerName (4), "'s 3 back to the beginning" ..
Time.Delay (2000)
Draw.FillOval (playerx (player, playerMove), playery (player, playerMove), 14, 14, white)
Time.Delay (2000)
locate (25, maxcol div 2 - 25)
put repeat (" ", 52) ..
elsif playerx (player, playerMove) = playerx (4, 4) and playery (player, playerMove) = playery (4, 4) then
playerx (4, 4) := 667
playery (4, 4) := 25
circleCounter (4, 4) := 0
locate (25, maxcol div 2 - 19)
colourback (brightred)
put "You sent ", playerName (4), "'s 4 back to the beginning" ..
Time.Delay (2000)
Draw.FillOval (playerx (player, playerMove), playery (player, playerMove), 14, 14, white)
Time.Delay (2000)
locate (25, maxcol div 2 - 25)
put repeat (" ", 52) ..
end if
end if
exit when whatdotcolour (playerx (player, playerMove), playery (player, playerMove)) = white
end loop
end if
lastMove (player, playerMove)
%% draws the guy
if player = 1 then
Draw.Fill (playerx (1, playerMove), playery (1, playerMove), brightred, black)
elsif player = 2 then
Draw.Fill (playerx (2, playerMove), playery (2, playerMove), yellow, black)
elsif player = 3 then
Draw.Fill (playerx (3, playerMove), playery (3, playerMove), brightgreen, black)
elsif player = 4 then
Draw.Fill (playerx (4, playerMove), playery (4, playerMove), blue, black)
end if
end if
lastMove (player, playerMove)
end for
if whatdotcolour (playerx (player, playerMove), playery (player, playerMove)) = brightred or whatdotcolour (playerx (player, playerMove), playery (player, playerMove)) = blue then
Font.Draw (intstr (playerMove), playerx (player, playerMove) - 3, playery (player, playerMove) - 3, font3, white)
else
Font.Draw (intstr (playerMove), playerx (player, playerMove) - 3, playery (player, playerMove) - 3, font3, black)
end if
end moveAround
var playerMove : int
proc choosePlayer
%% to choose which guy to move
locate (4, 15)
put repeat (" ", 70) ..
locate (4, 15)
%% if it's comp.'s turn
if playerName (turn) = "Comp 2" or playerName (turn) = "Comp 3" or playerName (turn) = "Comp 4" then
put "Comp will choose a guy to move " ..
playerMove := Rand.Int (1, 4)
else
put "Which player do you want to move? 1-4 " ..
get playerMove
end if
loop
if playerMove > 4 or playerMove < 1 then
locate (4, 15)
put repeat (" ", 70) ..
locate (4, 15)
put "You only have 4 pieces, choose 1-4 " ..
get playerMove
else
exit
end if
end loop
locate (4, 15)
put repeat (" ", 70) ..
locate (4, 15)
put "You chose player ", playerMove ..
Time.Delay (1000)
end choosePlayer
%%%%% Trouble PUT TOGETHER%%%%%
proc trouble
loop
menu
%% if you hit back button
if button = 1 and mousex >= 5 and mousex <= 43 and mousey >= 8 and mousey <= 29 then
exit
end if
startGame
colour (black)
colourback (brightgreen)
firstRoll
Time.Delay (1500)
loop
locate (4, 15)
put repeat (" ", 70) ..
locate (4, 15)
put "It's ", playerName (turn), "'s turn" ..
Time.Delay (1500)
choosePlayer
dieRoll (turn)
lastMove (turn, playerMove)
moveAround (turn, playerMove, Roll)
circleCounter (turn, playerMove) += Roll
lastMove (turn, playerMove)
turn += 1
if turn = 5 then
turn := 1
end if
colourback (brightgreen)
Time.Delay (2000)
exit when playerCounter (1) = 4 or playerCounter (2) = 4 or playerCounter (3) = 4 or playerCounter (4) = 4
end loop
end loop
end trouble
proc targetGame
var score : int := 0
var x, y : int
var button : int := 0
var levelSpeed : array 1 .. 4 of int := init (150000, 100000, 80000, 60000)
Draw.Fill (100, 100, black, black)
Font.Draw ("Instructions", 170, maxy - 50, font1, Rand.Int (9, 14)) %%title
locate (maxrow div 2 - 2, 1)
put "This is a target game where you have to click the target to get points."
put "There are 30 targets per level but you only have to hit 10."
put "Once you beat a level (there's 4), then the targets will get faster."
put "Click to start."
loop
Mouse.Where (x, y, button)
if button = 1 then
Time.Delay (1000)
Draw.Cls
exit
end if
end loop
for level : 1 .. 4
Draw.Fill (100, 100, black, black)
colourback (black)
colour (white)
score := 0
locate (maxrow div 2, maxcol div 2 - 4)
put "level ", level ..
Time.Delay (2000)
Draw.Cls
for target : 1 .. 30
var placex : int := Rand.Int (25, maxx - 25)
var placey : int := Rand.Int (25, maxy - 25)
Draw.Fill (100, 100, black, black)
locate (maxrow, 1)
colourback (black)
colour (white)
put "Score: ", score ..
Draw.FillOval (placex, placey, 20, 20, brightred)
Draw.FillOval (placex, placey, 15, 15, brightgreen)
Draw.FillOval (placex, placey, 10, 10, blue)
Draw.FillOval (placex, placey, 5, 5, yellow)
for q : 1 .. levelSpeed (level)
Mouse.Where (x, y, button)
locate (1, 1)
if button = 1 and x < placex + 20 and x > placex - 20 and y < placey + 20 and y > placey - 20 then
put "Hit!"
score += 1
exit
end if
end for
Draw.FillOval (placex, placey, 26, 26, black)
Time.Delay (500)
locate (maxrow, 1)
put "Score: ", score ..
locate (1, 1)
Time.Delay (100)
put repeat (" ", 5) ..
exit when score = 10
end for
locate (maxrow div 2, maxcol div 2 - 12)
if score = 10 then
put "Good job you beat level ", level ..
else
locate (maxrow div 2, maxcol div 2 - 4)
put "You lose" ..
Time.Delay (2000)
Draw.Cls
exit
end if
if level = 4 and score = 10 then
locate (maxrow div 2, maxcol div 2 - 12)
put "You beat the game!!!!!!!"
Time.Delay (2000)
Draw.Cls
end if
Time.Delay (2000)
Draw.Cls
end for
end targetGame
proc pong
%Pong
var ballx, bally : int
ballx := maxx div 2
bally := maxy div 2
var xChange, yChange : int := 8
var x, y, button : int
var compHit : array 1 .. 4, 1 .. 10 of boolean
var hit : int := 5
var goals : array 1 .. 2 of int := init (0, 0)
var speed : array 1 .. 4 of int := init (8, 6, 4, 2)
Draw.Fill (1, 1, black, black)
Font.Draw ("Instructions", 170, maxy - 50, font1, Rand.Int (9, 14)) %%title
locate (maxrow div 2 - 3, 1)
put "This is the classic game of pong."
put "To move you paddle you have to move your mouse."
put "There are 4 levels that you have to beat, if you lose one than you will lose the game."
put "Each level gets harder"
put "It gets faster and the Computer player will hit the ball more."
put "Click to continue."
loop
Mouse.Where (x, y, button)
if button = 1 then
Time.Delay (1000)
Draw.Cls
exit
end if
end loop
for row : 1 .. 4
for col : 1 .. 10
if col > hit then
compHit (row, col) := false
else
compHit (row, col) := true
end if
end for
hit += 1
end for
colour (white)
colourback (black)
for level : 1 .. 4
goals (1) := 0
goals (2) := 0
var cp : boolean %% cp=computer paddle
cp := false
locate (maxrow div 2, maxcol div 2 - 3)
Draw.Fill (1, 1, black, black)
put "Level ", level ..
Time.Delay (1000)
Draw.Cls
loop
Draw.Fill (1, 1, black, black)
locate (1, maxcol div 2 - 23)
put "Your score: ", goals (1), " Comp. score: ", goals (2) ..
Mouse.Where (x, y, button)
Draw.FillBox (10, y + 25, 15, y - 25, brightred)
Time.Delay (speed (level))
View.Update
%% if the ball is on comp.'s side of screen
if ballx > maxx div 2 then
if compHit (level, hit) = true then
if cp = false then
hit := Rand.Int (1, 10) %% chooses if comp hits the ball or not
cp := true %% chooses it once
end if
Draw.FillBox (maxx - 10, bally - 25, maxx - 5, bally + 25, brightgreen)
Time.Delay (speed (level))
View.Update
elsif compHit (level, hit) = false then
if cp = false then
hit := Rand.Int (1, 10)
cp := true
end if
Draw.FillBox (maxx - 10, bally - 60, maxx - 5, bally - 10, brightgreen)
Time.Delay (speed (level))
View.Update
end if
else
Draw.FillBox (maxx - 10, bally - 25, maxx - 5, bally + 25, brightgreen)
end if
Draw.FillOval (ballx, bally, 10, 10, yellow)
Time.Delay (10)
Draw.FillOval (ballx, bally, 10, 10, black)
ballx += xChange
bally += yChange
Draw.FillOval (ballx, bally, 10, 10, yellow)
if bally - 11 < 10 or bally + 11 > maxy - 10 then
yChange := -yChange
elsif whatdotcolour (ballx + 11, bally) = brightgreen then
xChange := -xChange
cp := false
elsif whatdotcolour (ballx - 11, bally) = brightred then
xChange := -xChange
end if
if ballx < 1 then
Draw.Cls
Draw.Fill (1, 1, black, black)
put "Comp. scores!!"
goals (2) += 1
ballx := maxx div 2
bally := maxy div 2
Time.Delay (1500)
Draw.Cls
elsif ballx > maxx then
Draw.Cls
Draw.Fill (1, 1, black, black)
put "You scored!!"
goals (1) += 1
ballx := maxx div 2
bally := maxy div 2
cp := false
Time.Delay (1500)
Draw.Cls
end if
if goals (1) = 5 then
Draw.Cls
Draw.Fill (1, 1, black, black)
put "You beat level ", level, "!!"
Time.Delay (2000)
Draw.Cls
exit
elsif goals (2) = 5 then
put "You lose :("
Draw.Cls
Draw.Fill (1, 1, black, black)
exit
end if
Draw.FillBox (maxx - 10, maxy, maxx - 5, 1, black)
Draw.FillBox (10, maxy, 15, 1, black)
View.Update
end loop
ballx := maxx div 2
bally := maxy div 2
if goals (2) = 5 then
put "You lose :("
Time.Delay (1000)
Draw.Cls
Draw.FillBox (10, maxy, 15, 1, black)
exit
end if
end for
end pong
proc arcade
loop
Draw.Fill (1, 1, black, black)
Font.Draw ("Arcade!!", 275, maxy - 50, font1, Rand.Int (9, 14)) %% title
locate (maxrow div 2 - 1, maxcol div 2 - 7)
colour (Rand.Int (9, 14))
colourback (black)
Draw.Box (294, 266, 473, 285, Rand.Int (9, 14))
put "Target Practice" .. %% button
locate (maxrow div 2 + 1, maxcol div 2 - 2)
colour (Rand.Int (9, 14))
colourback (black)
Draw.Box (294, 234, 480, 253, Rand.Int (9, 14))
put "Pong" .. %% button
locate (maxrow, 2)
Draw.Box (5, 8, 43, 29, Rand.Int (9, 14))
put "Back" .. %% button
loop
Mouse.Where (mousex, mousey, button)
if button = 1 and mousex >= 294 and mousex <= 473 and mousey > 266 and mousey < 285 then
Draw.Cls
Time.Delay (200)
targetGame
exit
elsif button = 1 and mousex >= 294 and mousex <= 480 and mousey > 234 and mousey < 253 then
Draw.Cls
Time.Delay (200)
pong
exit
elsif button = 1 and mousex >= 5 and mousex <= 43 and mousey >= 8 and mousey <= 29 then
exit
elsif button = 1 then
exit
end if
end loop
if button = 1 and mousex >= 5 and mousex <= 43 and mousey >= 8 and mousey <= 29 then
exit
end if
end loop
end arcade
loop
Draw.Fill (1, 1, black, black)
Font.Draw ("Choose Your Game", 130, maxy - 50, font1, Rand.Int (9, 14)) %% title
locate (maxrow div 2 - 1, maxcol div 2 - 4)
colour (Rand.Int (9, 14))
colourback (black)
Draw.Box (294, 266, 473, 285, Rand.Int (9, 14))
put "Trouble!" .. %% button
locate (maxrow div 2 + 1, maxcol div 2 - 3)
colour (Rand.Int (9, 14))
colourback (black)
Draw.Box (294, 234, 480, 253, Rand.Int (9, 14))
put "Arcade" .. %% button
loop
Mouse.Where (mousex, mousey, button)
if button = 1 and mousex >= 294 and mousex <= 473 and mousey > 266 and mousey < 285 then
Draw.Cls
Time.Delay (200)
trouble
exit
elsif button = 1 and mousex >= 294 and mousex <= 480 and mousey > 234 and mousey < 253 then
Draw.Cls
Time.Delay (200)
arcade
exit
elsif button = 1 then
Draw.Cls
exit
end if
end loop
end loop
|