%Lucille Domingo
%Ms Dyke
%December 27 2006
%
%set screen up
import GUI
setscreen ("nocursor")
setscreen ("noecho")
%setscreen ("position:130;30,graphics:800;600")
setscreen ("offscreenonly")
%Declaration Section
%var startpointx, startpointy, endpointx, endpointy : int
var startpointx, endpointx, endpointy : int := 0
var startpointy : int := 150
var startpointy2 : int := 400
var endpointy2 : int := 450
var pictureID : int
var key : array char of boolean
%var mainMenuBtn : int := 0
var mainMenuBtn : int := 0
var mainWin := Window.Open ("position:130;30,graphics:800;600")
%Procedures:
%Procedure Title Purpose: Proc title already contains a title so programmer only has to type the name of the proc to input a title on a screen.
process DoMusic
loop
Music.PlayFile ("mario_circuit.mid")
end loop
end DoMusic
procedure title
cls
locate (1, 44)
put "Racing Game"
put " "
end title
%Proc pauseProgram
proc pauseProgram
put " "
put "Press any key to continue..."
% getch (key)
end pauseProgram
%Proc introduction
procedure introduction
title
locate (3, 1)
put "Do you think you're the best at racing games? Test your skills with the Racing Game!"
GUI.Show (mainMenuBtn)
loop
exit when GUI.ProcessEvent
end loop
end introduction
%Proc display
proc display
title
locate (17, 37)
put "Congratulations! You WIN!"
GUI.Show (mainMenuBtn)
GUI.Enable (mainMenuBtn)
loop
exit when GUI.ProcessEvent
end loop
end display
%Proc displayandUserInput
proc displayEasy
title
% drawfillbox (0,0,800,580,77)
pictureID := Pic.FileNew ("BG1.JPG")
Pic.Draw (pictureID, 0, 60, 0)
pictureID := Pic.FileNew ("Comp.jpg")
Pic.Draw (pictureID, 1, 400, 0)
pictureID := Pic.FileNew ("P1.jpg")
Pic.Draw (pictureID, 1, 151, 0)
locate (4, 44)
%colourback (77)
put "3.." ..
delay (500)
put "2.." ..
delay (500)
put "1.." ..
delay (500)
put "GO!" ..
Pic.Free (pictureID)
% exit when GUI.ProcessEvent
pictureID := Pic.FileNew ("BG1.JPG")
Pic.Draw (pictureID, 0, 60, picCopy)
% drawfillbox (300, 350, 350, 400, 7)
pictureID := Pic.FileNew ("P1.jpg")
drawfillbox (startpointx + 1, 70 + 1, 0 + 1, 300 + 1, gray)
% drawfillbox (startpointx+1, startpointy+70, endpointx + 1, endpointy + 300, yellow)
% drawfillbox (startpointx+1, startpointy+100, endpointx + 150, endpointy + 150, yellow)
Pic.Draw (pictureID, startpointx + 1, startpointy + 1, picMerge)
loop
Input.KeyDown (key)
if key (KEY_UP_ARROW) and endpointy <= 300 then
startpointy := startpointy + 10
endpointy := endpointy + 10
elsif key (KEY_DOWN_ARROW) and startpointy >= 80 then
startpointy := startpointy - 10
endpointy := endpointy - 10
elsif key (KEY_RIGHT_ARROW) and endpointx <= 630 then
startpointx := startpointx + 10
endpointx := endpointx + 10
else
if key (KEY_UP_ARROW) and startpointx >= 1 then
startpointx := startpointx - 10
endpointx := endpointx - 10
elsif startpointx > 600 then
delay (500)
display
end if
end if
drawfillbox (startpointx + 1, 400 + 1, 0 + 1, 450 + 1, grey)
pictureID := Pic.FileNew ("Comp.jpg")
Pic.Draw (pictureID, startpointx, startpointy2, picMerge)
startpointx := startpointx + 1
delay (50)
if startpointx > 630 then
display
end if
%GUI.Show (mainMenuBtn)
%GUI.Enable (mainMenuBtn)
end loop
View.Update
loop
exit when GUI.ProcessEvent
end loop
end displayEasy
%proc displayIntermediate
%Proc Controls
proc controls
title
locate (8, 1)
put "Use the arrow keys on your keyboard to move the car in different directions." ..
put " "
put " "
put "Forward = Right Arrow Key" ..
put " "
put "Backward = Left Arrow Key" ..
put " "
put "Left = Up Arrow Key" ..
put " "
put "Right = Down Arrow Key" ..
GUI.Show (mainMenuBtn)
GUI.Enable (mainMenuBtn)
loop
exit when GUI.ProcessEvent
end loop
end controls
%Proc goodBye
proc goodBye
title
locate (17, 29)
put "Hope you had fun playing the Racing Game!"
locate (18, 28)
put "For more information visit:
www.racing.com"
locate (37, 1)
put "This program was written by: Lucille Domingo" ..
delay (3000)
Window.Close (mainWin)
end goodBye
%Proc mainMenu
proc mainMenu
title
startpointx := 0
pictureID := Pic.FileNew ("racing_flags.jpg")
Pic.Draw (pictureID, 230, 250, 0)
GUI.Disable (mainMenuBtn)
GUI.Hide (mainMenuBtn)
locate (9, 25)
put "Levels:" ..
var easyBtn : int := GUI.CreateButtonFull (300, 450, 190, "Easy", displayEasy, 10, '^F', false)
var intermediateBtn : int := GUI.CreateButtonFull (300, 420, 190, "Intermediate", displayEasy, 10, '^G', false)
var hardBtn : int := GUI.CreateButtonFull (300, 390, 190, "Hard", displayEasy, 10, '^S', false)
var controlsBtn : int := GUI.CreateButtonFull (300, 320, 190, "Controls", controls, 10, '^H', false)
var quitBtn : int := GUI.CreateButtonFull (300, 250, 190, "Quit", GUI.Quit, 10, '^T', false)
loop
exit when GUI.ProcessEvent
end loop
end mainMenu
mainMenuBtn := GUI.CreateButtonFull (700, 1, 100, "Main Menu", mainMenu, 25, '^M', false)
%Main Program
fork DoMusic
introduction
loop
exit when GUI.ProcessEvent
end loop
goodBye