% First attempt to compile light cycles into one giant program
% Eric Ellis
View.Set ("graphics:600;640")
%forward gamespeed menu to make it work
forward procedure gamespeedmenu (var gamespeed, car1colour, car2colour : int)
%forward colour menu to make it work
forward procedure changecolourmenu (carnum : int, var gamespeed, car1colour, car2colour : int)
%forward highscores to make it work
forward procedure highscores (var gamespeed, car1colour, car2colour : int)
%forwards the main menu to make this work
forward procedure mainmenu (var gamespeed, car1colour, car2colour : int)
%forwards the into so that this works
forward procedure intro
procedure drawmainmenu
%Draws the main menu
var font : int
font := Font.New ("Fixedsys:20:bold")
Draw.FillBox (220, 178, 240, 198, 10)
delay (200)
Font.Draw ("One Player", 250, 180, font, 10)
delay (200)
Draw.FillBox (220, 148, 240, 168, 13)
delay (200)
Font.Draw ("Multiplayer", 250, 150, font, 13)
delay (200)
Draw.FillBox (220, 118, 240, 138, 11)
delay (200)
Font.Draw ("Options", 250, 120, font, 11)
delay (200)
Draw.FillBox (220, 88, 240, 108, 14)
delay (200)
Font.Draw ("Quit", 250, 90, font, 14)
delay (200)
Draw.Box (199, 64, 437, 219, 0)
Draw.Box (200, 65, 438, 220, 0)
Draw.Box (201, 66, 439, 221, 0)
end drawmainmenu
procedure explode (x, y, Colour, spread : int)
%creates the explosions that occur when cars die and when menus are clicked
for i : 1 .. 1000
Draw.Oval (x, y, i, i, Colour)
delay (2)
if i > spread then
Draw.FillOval (x, y, i - spread, i - spread, 7)
end if
end for
end explode
procedure drawcar1 (car1xloc, car1yloc, car1colour : int)
% Draw Player 1
Draw.Dot (car1xloc, car1yloc, car1colour)
Draw.Dot (car1xloc + 1, car1yloc + 1, car1colour)
Draw.Dot (car1xloc + 1, car1yloc - 1, car1colour)
Draw.Dot (car1xloc - 1, car1yloc + 1, car1colour)
Draw.Dot (car1xloc - 1, car1yloc - 1, car1colour)
Draw.Dot (car1xloc, car1yloc + 1, car1colour)
Draw.Dot (car1xloc + 1, car1yloc, car1colour)
Draw.Dot (car1xloc - 1, car1yloc, car1colour)
Draw.Dot (car1xloc, car1yloc - 1, car1colour)
end drawcar1
procedure drawcar2 (car2xloc, car2yloc, car2colour : int)
% Draw Player 2
Draw.Dot (car2xloc, car2yloc, car2colour)
Draw.Dot (car2xloc + 1, car2yloc + 1, car2colour)
Draw.Dot (car2xloc + 1, car2yloc - 1, car2colour)
Draw.Dot (car2xloc - 1, car2yloc + 1, car2colour)
Draw.Dot (car2xloc - 1, car2yloc - 1, car2colour)
Draw.Dot (car2xloc, car2yloc + 1, car2colour)
Draw.Dot (car2xloc + 1, car2yloc, car2colour)
Draw.Dot (car2xloc, car2yloc - 1, car2colour)
Draw.Dot (car2xloc - 1, car2yloc, car2colour)
end drawcar2
procedure drawbackground (backcolour, gridcolour, bordercolour : int)
% Back Ground
Draw.FillBox (0, 0, maxx, maxy, backcolour)
% Grid
for i : 1 .. 10
Draw.Line (60 * i, 0 + 10, 60 * i, maxy - 50, gridcolour)
end for
for i : 1 .. 9
Draw.Line (0 + 10, 60 * i, maxx - 10, 60 * i, gridcolour)
end for
% Left board
Draw.FillBox (10, 10, 15, maxy - 50, bordercolour)
% Right Board
Draw.FillBox (maxx - 10, 10, maxx - 15, maxy - 50, bordercolour)
% Bottom Board
Draw.FillBox (10, 10, maxx - 10, 15, bordercolour)
% Top Board
Draw.FillBox (10, maxy - 50, maxx - 10, maxy - 55, bordercolour)
end drawbackground
procedure movedirectioncar1 (var car1direction : string)
% Player 1 movement is controled with w,a,s,d
var chars : array char of boolean
Input.KeyDown (chars)
if chars ('w') then
if car1direction not= "down" then
car1direction := "up"
end if
elsif chars ('s') then
if car1direction not= "up" then
car1direction := "down"
end if
elsif chars ('a') then
if car1direction not= "right" then
car1direction := "left"
end if
elsif chars ('d') then
if car1direction not= "left" then
car1direction := "right"
end if
else
end if
end movedirectioncar1
procedure movedirectioncar2 (var car2direction : string)
% Player 2 movement is controled with the directional keys
var chars : array char of boolean
Input.KeyDown (chars)
if chars (KEY_UP_ARROW) then
if car2direction not= "down" then
car2direction := "up"
end if
elsif chars (KEY_DOWN_ARROW) then
if car2direction not= "up" then
car2direction := "down"
end if
elsif chars (KEY_LEFT_ARROW) then
if car2direction not= "right" then
car2direction := "left"
end if
elsif chars (KEY_RIGHT_ARROW) then
if car2direction not= "left" then
car2direction := "right"
end if
else
end if
end movedirectioncar2
procedure movecar (var car1xloc, car1yloc, car2xloc, car2yloc : int, car1direction, car2direction : string, movespeed : int)
% Player 2's movement
if car2direction = "up" then
car2yloc += movespeed
elsif car2direction = "down" then
car2yloc -= movespeed
elsif car2direction = "left" then
car2xloc -= movespeed
elsif car2direction = "right" then
car2xloc += movespeed
end if
% Player 1's movement
if car1direction = "up" then
car1yloc += movespeed
elsif car1direction = "down" then
car1yloc -= movespeed
elsif car1direction = "left" then
car1xloc -= movespeed
elsif car1direction = "right" then
car1xloc += movespeed
end if
end movecar
procedure hitcheck (var crash : boolean, car1xloc, car1yloc, car2xloc, car2yloc, car1colour, car2colour : int, comp : boolean)
%checks for collisions too end a game
var font := Font.New ("Fixedsys:30:bold")
var winner, f1, solowins, car1wins, car2wins : int
winner := 0
% Check to see if a player has collided with a line
if View.WhatDotColour (car1xloc, car1yloc) = car1colour or View.WhatDotColour (car1xloc, car1yloc) = car2colour or View.WhatDotColour (car1xloc, car1yloc) = 0 then
explode (car1xloc, car1yloc, car1colour, 150)
crash := true
Font.Draw ("Car Two Wins!", 155, maxy div 2, font, car2colour)
delay (3000)
winner := 1
end if
if View.WhatDotColour (car2xloc, car2yloc) = car1colour or View.WhatDotColour (car2xloc, car2yloc) = car2colour or View.WhatDotColour (car2xloc, car2yloc) = 0 then
explode (car2xloc, car2yloc, car2colour, 150)
crash := true
Font.Draw ("Car One Wins!", 155, maxy div 2, font, car1colour)
delay (3000)
winner := 2
end if
if crash then
open : f1, "LightCyclesWins.t", get
get : f1, skip
get : f1, solowins
get : f1, car1wins
get : f1, car2wins
close : f1
if comp then
if winner = 2 then
solowins += 1
end if
else
if winner = 2 then
car1wins += 1
else
car2wins += 1
end if
end if
open : f1, "LightCyclesWins.t", put
put : f1, solowins
put : f1, car1wins
put : f1, car2wins
close : f1
end if
end hitcheck
procedure turndecision (var car2direction : string, car2xloc, car2yloc, car1colour, car2colour : int)
%Decides which direction the computer should turn
var increase, decrease : boolean := true
var directionright, directionleft, directionup, directiondown, random : int := 0
if car2direction = "up" or car2direction = "down" then
for i : 1 .. 50 % Might lower if this affects gameplay speed
if whatdotcolour (car2xloc + i, car2yloc) = car1colour or whatdotcolour (car2xloc + i, car2yloc) = car2colour or whatdotcolour (car2xloc + i, car2yloc) = 0 then
directionleft += 1
end if
if whatdotcolour (car2xloc - i, car2yloc) = car1colour or whatdotcolour (car2xloc - i, car2yloc) = car2colour or whatdotcolour (car2xloc - i, car2yloc) = 0 then
directionright += 1
end if
end for
end if
if car2direction = "right" or car2direction = "left" then
for i : 1 .. 50 % Might lower if this affects gameplay speed
if whatdotcolour (car2xloc, car2yloc + i) = car1colour or whatdotcolour (car2xloc, car2yloc + i) = car2colour or whatdotcolour (car2xloc, car2yloc + i) = 0 then
directiondown += 1
end if
if whatdotcolour (car2xloc, car2yloc - i) = car1colour or whatdotcolour (car2xloc, car2yloc - i) = car2colour or whatdotcolour (car2xloc, car2yloc - i) = 0 then
directionup += 1
end if
end for
end if
% Changes the direction of the car
if directionright > directionleft then
car2direction := "right"
elsif directionright < directionleft then
car2direction := "left"
elsif directionup > directiondown then
car2direction := "up"
elsif directionup < directiondown then
car2direction := "down"
elsif directionup > 0 then %Randomizes the choice if up and down are equal
random := Rand.Int (1, 2)
if random = 1 then
car2direction := "up"
else
car2direction := "down"
end if
else
random := Rand.Int (1, 2)
if random = 1 then
car2direction := "left"
else
car2direction := "right"
end if
end if
end turndecision
procedure compturn (var car2direction, car1direction : string, difficulty, car2xloc, car2yloc, car1xloc, car1yloc, car1colour, car2colour : int)
%allows the computer to move
var view, randmove : int
if difficulty = 2 then
view := 15
elsif difficulty = 3 then
view := 10
elsif difficulty = 4 then
view := 7
elsif difficulty = 5 then
view := 4
else
view := 25
end if
if car1direction = car2direction then
end if
if car2direction = "up" then
% Computer looks ahead of it to make sure it won't crash into a wall.
if View.WhatDotColour (car2xloc, car2yloc + view) = 0 or View.WhatDotColour (car2xloc, car2yloc + view) = car1colour or View.WhatDotColour (car2xloc, car2yloc + view) = car2colour then
turndecision (car2direction, car2xloc, car2yloc, car1colour, car2colour)
% The computer has a chance to turn randomly with seemingly no purpose. The chances of a random turn are more likely at low difficulty.
else
randmove := Rand.Int (1, 1000)
if randmove < view then
turndecision (car2direction, car2xloc, car2yloc, car1colour, car2colour)
end if
end if
elsif car2direction = "right" then
% Computer looks ahead of it to make sure it won't crash into a wall.
if View.WhatDotColour (car2xloc + view, car2yloc) = 0 or View.WhatDotColour (car2xloc + view, car2yloc) = car1colour or View.WhatDotColour (car2xloc + view, car2yloc) = car2colour
then
turndecision (car2direction, car2xloc, car2yloc, car1colour, car2colour)
% The computer has a chance to turn randomly with seemingly no purpose. The chances of a random turn are more likely at low difficulty.
else
randmove := Rand.Int (1, 1000)
if randmove < view then
turndecision (car2direction, car2xloc, car2yloc, car1colour, car2colour)
end if
end if
elsif car2direction = "down" then
% Computer looks ahead of it to make sure it won't crash into a wall.
if View.WhatDotColour (car2xloc, car2yloc - view) = 0 or View.WhatDotColour (car2xloc, car2yloc - view) = car1colour or View.WhatDotColour (car2xloc, car2yloc - view) = car2colour
then
turndecision (car2direction, car2xloc, car2yloc, car1colour, car2colour)
% The computer has a chance to turn randomly with seemingly no purpose. The chances of a random turn are more likely at low difficulty.
else
randmove := Rand.Int (1, 1000)
if randmove < view then
turndecision (car2direction, car2xloc, car2yloc, car1colour, car2colour)
end if
end if
else
% Computer looks ahead of it to make sure it won't crash into a wall.
if View.WhatDotColour (car2xloc - view, car2yloc) = 0 or View.WhatDotColour (car2xloc - view, car2yloc) = car1colour or View.WhatDotColour (car2xloc - view, car2yloc) = car2colour
then
turndecision (car2direction, car2xloc, car2yloc, car1colour, car2colour)
% The computer has a chance to turn randomly with seemingly no purpose. The chances of a random turn are more likely at low difficulty.
else
randmove := Rand.Int (4, 2000) %As this is the hardest difficulty random turns are almost entirely eliminated.
if randmove < 2 then
turndecision (car2direction, car2xloc, car2yloc, car1colour, car2colour)
end if
end if
end if
end compturn
procedure gameplaymultiplayer (var gamespeed, car1colour, car2colour : int)
%Allows multiplayer gameplay
drawbackground (7, Rand.Int (1, 6), 0)
var car1xloc, car1yloc, car2xloc, car2yloc, movespeed : int
var car1direction, car2direction : string
var crash : boolean := false
var comp : boolean := false
car2direction := "right"
car1direction := "left"
movespeed := 3
car1xloc := maxx div 2 - 20
car1yloc := maxy div 2
car2xloc := maxx div 2 + 20
car2yloc := maxy div 2
loop
movedirectioncar1 (car1direction)
movedirectioncar2 (car2direction)
movecar (car1xloc, car1yloc, car2xloc, car2yloc, car1direction, car2direction, movespeed)
hitcheck (crash, car1xloc, car1yloc, car2xloc, car2yloc, car1colour, car2colour, comp)
if crash then
intro
drawmainmenu
mainmenu (gamespeed, car1colour, car2colour)
exit
end if
drawcar1 (car1xloc, car1yloc, car1colour)
drawcar2 (car2xloc, car2yloc, car2colour)
delay (gamespeed)
end loop
end gameplaymultiplayer
procedure gameplaycomputer (var car1xloc, car1yloc, car2xloc, car2yloc, difficulty, gamespeed, car1colour, car2colour : int,
%Allows Against the Computer gameplay
movespeed : int)
var car1direction, car2direction : string
var crash : boolean := false
var comp : boolean := true
car2direction := "right"
car1direction := "left"
drawbackground (7, Rand.Int (1, 6), 0)
loop
movedirectioncar1 (car1direction)
compturn (car2direction, car1direction, difficulty, car2xloc, car2yloc, car1xloc, car1yloc, car1colour, car2colour)
% computermove
movecar (car1xloc, car1yloc, car2xloc, car2yloc, car1direction, car2direction, movespeed)
hitcheck (crash, car1xloc, car1yloc, car2xloc, car2yloc, car1colour, car2colour, comp)
if crash then
intro
drawmainmenu
mainmenu (gamespeed, car1colour, car2colour)
exit
end if
drawcar1 (car1xloc, car1yloc, car1colour)
drawcar2 (car2xloc, car2yloc, car2colour)
delay (gamespeed)
end loop
end gameplaycomputer
procedure showtitle (font : int)
%Shows Light Cycles Title
Font.Draw ("Light Cycles", 60, 450, font, white)
end showtitle
body procedure intro
%Shows Intro
var font : int
font := Font.New ("Fixedsys:120:bold")
Draw.FillBox (0, 0, maxx, maxy, 7)
showtitle (font)
for i : 0 .. maxx + 200
Draw.FillBox (i, 550, i + 4, 560, 12)
if i > 200 then
Draw.FillBox (i - 200, 400, i + 4 - 200, 410, 32)
end if
delay (1)
if i mod 100 = 0 then
showtitle (font)
elsif i mod 100 = 50 then
Draw.FillBox (50, 415, maxx, 540, 7)
end if
end for
showtitle (font)
end intro
procedure samecolour (var gamespeed, car1colour, car2colour : int)
%keeps colours from being the same
var font : int
font := Font.New ("Fixedsys:30:bold")
if car1colour = car2colour then
car1colour := 9
car2colour := 12
Font.Draw ("Colours set to Default", 50, maxy div 2, font, 10)
end if
end samecolour
procedure changecarcolour (carnum : int, var gamespeed, car1colour, car2colour : int)
%allows you to change the colour of both cars
var font, font2 : int
font := Font.New ("Fixedsys:40:bold")
font2 := Font.New ("Fixedsys:30:bold")
Draw.FillBox (0, 0, maxx, maxy, 7)
for i : 0 .. maxy
Draw.FillBox ((maxx * 9 div 10) - 5, maxy - i, (maxx * 9 div 10) + 5, maxy - i - 4, 47)
Draw.FillBox (maxx - i, (maxy * 9 div 10) - 5, maxx - i - 4, (maxy * 9 div 10) + 5, 43)
delay (1)
end for
delay (500)
Font.Draw ("Pick Colour", 30, 500, font, white)
delay (500)
Draw.FillBox (150, 400, 170, 420, 14)
delay (200)
Font.Draw ("Yellow", 180, 400, font2, 14)
delay (200)
Draw.FillBox (150, 350, 170, 370, 13)
delay (200)
Font.Draw ("Magenta", 180, 350, font2, 13)
delay (200)
Draw.FillBox (150, 300, 170, 320, 10)
delay (200)
Font.Draw ("Green", 180, 300, font2, 10)
delay (200)
Draw.FillBox (150, 250, 170, 270, 12)
delay (200)
Font.Draw ("Red", 180, 250, font2, 12)
delay (200)
Draw.FillBox (150, 200, 170, 220, 9)
delay (200)
Font.Draw ("Blue", 180, 200, font2, 9)
delay (500)
Font.Draw ("Return", 180, 100, font2, 42)
changecolourmenu (carnum, gamespeed, car1colour, car2colour)
end changecarcolour
procedure changegamespeed (var gamespeed, car1colour, car2colour : int)
%Changes game speed
var font, font2 : int
font := Font.New ("Fixedsys:40:bold")
font2 := Font.New ("Fixedsys:30:bold")
Draw.FillBox (0, 0, maxx, maxy, 7)
for i : 0 .. maxy
Draw.FillBox ((maxx * 9 div 10) - 5, maxy - i, (maxx * 9 div 10) + 5, maxy - i - 4, 47)
Draw.FillBox (maxx - i, (maxy * 9 div 10) - 5, maxx - i - 4, (maxy * 9 div 10) + 5, 43)
delay (1)
end for
delay (500)
Font.Draw ("Pick Game Speed", 30, 500, font, white)
delay (500)
Draw.FillBox (150, 400, 170, 420, 14)
delay (200)
Font.Draw ("Turtle", 180, 400, font2, 14)
delay (200)
Draw.FillBox (150, 350, 170, 370, 13)
delay (200)
Font.Draw ("Slow", 180, 350, font2, 13)
delay (200)
Draw.FillBox (150, 300, 170, 320, 10)
delay (200)
Font.Draw ("Normal", 180, 300, font2, 10)
delay (200)
Draw.FillBox (150, 250, 170, 270, 12)
delay (200)
Font.Draw ("Fast", 180, 250, font2, 12)
delay (200)
Draw.FillBox (150, 200, 170, 220, 9)
delay (200)
Font.Draw ("Lightning", 180, 200, font2, 9)
delay (500)
Font.Draw ("Return", 180, 100, font2, 42)
gamespeedmenu (gamespeed, car1colour, car2colour)
end changegamespeed
procedure optionsmenu (var gamespeed, car1colour, car2colour : int)
%allows you to navigate the option menu
var x, y, button, dotcolour : int
loop
Mouse.Where (x, y, button)
if button = 1 then
dotcolour := whatdotcolor (x, y)
if dotcolour = 14 then
%gamspeedmenu
explode (x, y, dotcolour, 100)
changegamespeed (gamespeed, car1colour, car2colour)
exit
elsif dotcolour = 13 then
% car1colourmenu
explode (x, y, dotcolour, 100)
changecarcolour (1, gamespeed, car1colour, car2colour)
exit
elsif dotcolour = 10 then
% car2colourmenu
explode (x, y, dotcolour, 100)
changecarcolour (2, gamespeed, car1colour, car2colour)
elsif dotcolour = 12 then
% Highscoregame
explode (x, y, dotcolour, 100)
highscores (gamespeed, car1colour, car2colour)
exit
elsif dotcolour = 42 then
%Return to title screen
explode (x, y, dotcolour, 100)
intro
drawmainmenu
mainmenu (gamespeed, car1colour, car2colour)
else
end if
else
end if
end loop
end optionsmenu
procedure options (var gamespeed, car1colour, car2colour : int)
%Prints out the options menu
var font, font2 : int
font := Font.New ("Fixedsys:70:bold")
font2 := Font.New ("Fixedsys:30:bold")
Draw.FillBox (0, 0, maxx, maxy, 7)
for i : 0 .. maxy
Draw.FillBox ((maxx * 1 div 10) - 5, i, (maxx * 1 div 10) + 5, i + 4, 11)
Draw.FillBox (i, (maxy * 1 div 10) - 5, i + 4, (maxy * 1 div 10) + 5, 10)
delay (1)
end for
delay (500)
Font.Draw ("Options", 275, 550, font, white)
delay (500)
Draw.FillBox (150, 400, 170, 420, 14)
delay (200)
Font.Draw ("Game Speed", 180, 400, font2, 14)
delay (200)
Draw.FillBox (150, 350, 170, 370, 13)
delay (200)
Font.Draw ("Car 1 Colour", 180, 350, font2, 13)
delay (200)
Draw.FillBox (150, 300, 170, 320, 10)
delay (200)
Font.Draw ("Car 2 Colour", 180, 300, font2, 10)
delay (200)
Draw.FillBox (150, 250, 170, 270, 12)
delay (200)
Font.Draw ("High Scores", 180, 250, font2, 12)
delay (500)
Font.Draw ("Return", 180, 150, font2, 42)
optionsmenu (gamespeed, car1colour, car2colour)
end options
body procedure highscores (var gamespeed, car1colour, car2colour : int)
%Prints out the highscores
var font, font2, f1, solowins, car1wins, car2wins : int
font := Font.New ("Fixedsys:70:bold")
font2 := Font.New ("Fixedsys:30:bold")
Draw.FillBox (0, 0, maxx, maxy, 7)
open : f1, "LightCyclesWins.t", get
loop
get : f1, skip
exit when eof (f1)
get : f1, solowins
get : f1, car1wins
get : f1, car2wins
end loop
close : f1
for i : 0 .. maxy
Draw.FillBox ((maxx * 1 div 10) - 5, i, (maxx * 1 div 10) + 5, i + 4, 11)
Draw.FillBox ((maxx * 9 div 10) - 5, maxy - i, (maxx * 9 div 10) + 5, maxy - i - 4, 14)
delay (1)
end for
for i : 0 .. maxx
Draw.FillBox (i, (maxy * 1 div 10) - 5, i + 4, (maxy * 1 div 10) + 5, 10)
Draw.FillBox (maxx - i, (maxy * 9 div 10) - 5, maxx - i - 4, (maxy * 9 div 10) + 5, 12)
delay (1)
end for
Font.Draw ("High Scores", 75, 450, font, white)
delay (500)
Font.Draw ("Solo Wins: ", 75, 325, font2, white)
delay (500)
Font.Draw (intstr (solowins), maxx - 200, 325, font2, white)
delay (500)
Font.Draw ("Car 1 Wins: ", 75, 275, font2, white)
delay (500)
Font.Draw (intstr (car1wins), maxx - 200, 275, font2, white)
delay (500)
Font.Draw ("Car 2 Wins: ", 75, 225, font2, white)
delay (500)
Font.Draw (intstr (car2wins), maxx - 200, 225, font2, white)
delay (3000)
explode (maxx div 2, maxy div 2, 0, 100)
options (gamespeed, car1colour, car2colour)
end highscores
body procedure gamespeedmenu (var gamespeed, car1colour, car2colour : int)
%the actual gamespeed menu navigator
var x, y, button, dotcolour : int
loop
Mouse.Where (x, y, button)
if button = 1 then
dotcolour := whatdotcolor (x, y)
if dotcolour = 14 then
%turtle
explode (x, y, dotcolour, 100)
gamespeed := 100
exit
elsif dotcolour = 13 then
%slow
explode (x, y, dotcolour, 100)
gamespeed := 50
exit
elsif dotcolour = 10 then
% normal
explode (x, y, dotcolour, 100)
gamespeed := 20
exit
elsif dotcolour = 12 then
% fast
explode (x, y, dotcolour, 100)
gamespeed := 10
exit
elsif dotcolour = 9 then
% lightning
explode (x, y, dotcolour, 100)
gamespeed := 5
exit
elsif dotcolour = 42 then
%Return to title screen
explode (x, y, dotcolour, 100)
exit
else
end if
else
end if
end loop
options (gamespeed, car1colour, car2colour)
end gamespeedmenu
body procedure changecolourmenu (carnum : int, var gamespeed, car1colour, car2colour : int)
%the actual colour menu navigator
var x, y, button, dotcolour, font : int
font := Font.New ("Fixedsys:70:bold")
loop
Mouse.Where (x, y, button)
if button = 1 then
dotcolour := whatdotcolor (x, y)
if dotcolour = 14 then
%yellow
explode (x, y, dotcolour, 100)
if carnum = 1 then
car1colour := 14
else
car2colour := 14
end if
exit
elsif dotcolour = 13 then
%magenta
explode (x, y, dotcolour, 100)
if carnum = 1 then
car1colour := 13
else
car2colour := 13
end if
exit
elsif dotcolour = 10 then
% green
explode (x, y, dotcolour, 100)
if carnum = 1 then
car1colour := 10
else
car2colour := 10
end if
exit
elsif dotcolour = 12 then
% red
explode (x, y, dotcolour, 100)
if carnum = 1 then
car1colour := 12
else
car2colour := 12
end if
exit
elsif dotcolour = 9 then
% blue
explode (x, y, dotcolour, 100)
if carnum = 1 then
car1colour := 9
else
car2colour := 9
end if
exit
elsif dotcolour = 42 then
%Return to title screen
explode (x, y, dotcolour, 100)
exit
else
end if
end if
end loop
samecolour (gamespeed, car1colour, car2colour)
options (gamespeed, car1colour, car2colour)
end changecolourmenu
procedure singleplayer (var gamespeed, car1colour, car2colour : int)
const movespeed := 3
var x, y, button, dotcolour, font, font2, difficulty, car1xloc, car1yloc, car2xloc, car2yloc : int
var car1direction, car2direction : string
font := Font.New ("Fixedsys:40:bold")
font2 := Font.New ("Fixedsys:30:bold")
Draw.FillBox (0, 0, maxx, maxy, 7)
for i : 0 .. maxy % Draws the border
Draw.FillBox ((maxx * 9 div 10) - 5, maxy - i, (maxx * 9 div 10) + 5, maxy - i - 4, 49)
Draw.FillBox (maxx - i, (maxy * 9 div 10) - 5, maxx - i - 4, (maxy * 9 div 10) + 5, 35)
delay (1)
end for
% Draws out the choices
delay (500)
Font.Draw ("Pick Difficulty", 30, 500, font, white)
delay (500)
Draw.FillBox (150, 400, 170, 420, 14)
delay (200)
Font.Draw ("Simple", 180, 400, font2, 14)
delay (200)
Draw.FillBox (150, 350, 170, 370, 13)
delay (200)
Font.Draw ("Easy", 180, 350, font2, 13)
delay (200)
Draw.FillBox (150, 300, 170, 320, 10)
delay (200)
Font.Draw ("Medium", 180, 300, font2, 10)
delay (200)
Draw.FillBox (150, 250, 170, 270, 12)
delay (200)
Font.Draw ("Hard", 180, 250, font2, 12)
delay (200)
Draw.FillBox (150, 200, 170, 220, 9)
delay (200)
Font.Draw ("Insane", 180, 200, font2, 9)
%Select the gamespeed with a click
loop
Mouse.Where (x, y, button)
if button = 1 then
dotcolour := whatdotcolor (x, y)
if dotcolour = 14 then
%simple
explode (x, y, dotcolour, 100)
difficulty := 1
exit
elsif dotcolour = 13 then
%easy
explode (x, y, dotcolour, 100)
difficulty := 2
exit
elsif dotcolour = 10 then
% normal
explode (x, y, dotcolour, 100)
difficulty := 3
exit
elsif dotcolour = 12 then
% hard
explode (x, y, dotcolour, 100)
difficulty := 4
exit
elsif dotcolour = 9 then
% insane
explode (x, y, dotcolour, 100)
difficulty := 5
exit
else
end if
else
end if
end loop
car1xloc := maxx div 2 - 20
car1yloc := maxy div 2
car2xloc := maxx div 2 + 20
car2yloc := maxy div 2
gameplaycomputer (car1xloc, car1yloc, car2xloc, car2yloc, difficulty, gamespeed, car1colour, car2colour, movespeed)
end singleplayer
body procedure mainmenu (var gamespeed, car1colour, car2colour : int)
var x, y, button, dotcolour : int
loop
Mouse.Where (x, y, button)
if button = 1 then
dotcolour := whatdotcolor (x, y)
if dotcolour = 10 then
explode (x, y, dotcolour, 100)
singleplayer (gamespeed, car1colour, car2colour)
exit
%singleplayermenu
elsif dotcolour = 13 then
explode (x, y, dotcolour, 100)
gameplaymultiplayer (gamespeed, car1colour, car2colour)
exit
%twoplayermenu
elsif dotcolour = 11 then
explode (x, y, dotcolour, 100)
options (gamespeed, car1colour, car2colour)
exit
%optionsmenu
elsif dotcolour = 14 then
explode (x, y, dotcolour, 100)
exit
%quitgame
else
end if
else
end if
end loop
end mainmenu
var gamespeed, car1colour, car2colour, movespeed : int
car1colour := 9 % The default colour for player one is blue
car2colour := 12 % The default colour for player two is red
movespeed := 3 % This is the number of pixels the cars move per turn
gamespeed := 20 % This is how long of a delay there is between each turn
intro
drawmainmenu
mainmenu (gamespeed, car1colour, car2colour)
|