%ID SECTION
%Janet Mak and Jacky Yoh
%Eight Racing Game
%DUE : MAY 7, 2004
%An eight way race track, with 2 cars,
%one control by cursor keys (ascii), another by the mouse
%slows down when they hit the wall or each other
%Original site: http://www.compsci.ca/v2/viewtopic.php?t=2173
%DECALARATION
var racer1, racer2, speed1, speed2, wager, credits, win, startcredits : int
% racer1/racer2: Represents the posistion of the racers
% speed1/speed2: Represents the speed of the two racers
% wager: Repesents the user's wager
% credits: Represents the amount of credits the user has
% win: Represents wether you have won, lost, or had a tie
% startcredits: Represents the amount of starting credits
var continue, restart, guess : string
% continue: Represents the users choice to race again
% restart: Represents the user choice to start over, if he/she has ran out of money
% guess: Represents the guess of the user
var next : char % Represents the user input of any key, to move to the next screen
const midx := maxx div 2
const midy := maxy div 2
var x, y, button : int
var font1, font2, font3, font4, font5, font6 : int
%INITIALIZATION
wager := 0
font1 := Font.New ("Comic Sans MS:20:bold")
font2 := Font.New ("Palatino:30:bold,italic")
font3 := Font.New ("Comic Sans MS:30:bold")
font4 := Font.New ("Georgia:16")
font5 := Font.New ("Lucida Bright:55:bold,italic")
font6 := Font.New ("Lucida Bright:80:bold,italic")
assert font1 > 0
assert font2 > 0
assert font3 > 0
assert font4 > 0
assert font5 > 0
assert font6 > 0
%PROGRAM SECTION
%Introduction
setscreen ("graphics")
colorback (7)
color (0)
drawfillbox (0, 0, maxx, maxy, 7)
Font.Draw ("Welcome " , 1, 300, font1, 46)
delay (500)
Font.Draw (" to " , 1, 300, font1, 47)
delay (500)
Font.Draw (" Janet " , 1, 300, font2, 83)
delay (500)
Font.Draw (" and " , 1, 300, font1, 46)
delay (500)
Font.Draw (" Jacky's " , 1, 300, font2, 32)
delay (500)
Font.Draw (" Raceway!!! ... " , 1, 200, font2, 41)
delay (500)
cls
Font.Draw ("Janet and Jacky's Raceway" , 60, 320, font3, 79)
Font.Draw ("Choose the amount of starting credits you want." , 1, 280, font4, 29)
Font.Draw ("You will be biding on one of the two cars, red or blue." , 1, 260, font4, 29)
Font.Draw ("Choose the car you think will win." , 1, 240, font4, 29)
Font.Draw ("Then place a bet on your car." , 1, 220, font4, 29)
Font.Draw ("If you win, you will get your wager back," , 1, 200, font4, 29)
Font.Draw ("plus double your wager on top of it!" , 1, 180, font4, 39)
Font.Draw ("Press any key to begin." , 1, 160, font4, 29)
next := getchar
cls
%Start Credits
loop
Font.Draw ("How many credit(s) would you like to start with? (1-1000)" , 1, 200, font4, 96)
get startcredits
if (startcredits >= 1) and (startcredits <= 1000) then
cls
exit
end if
cls
end loop
credits := startcredits
% User Input (Guess)
loop
Font.Draw ("Which car would you like to bid on?" , 1, 240, font4, 48)
Font.Draw ("Red car - mouse control. (Red) or (1)", 150, 200, font4, 39)
Font.Draw ("Blue car - arrow keys. (Blue) or (2)", 150, 170, font4, 9)
get guess
cls
if (guess = "Red") or (guess = "red") or (guess = "1") or (guess = "Blue") or (guess = "blue") or (guess = "2") then
exit
end if
end loop
% User Input (Wager)
loop
Font.Draw ("How many credits would you like to wager on your car?" , 1, 300, font4, 48)
put "You have ", credits, " credit(s)."
get wager
cls
if wager > 0 and wager <= credits then
exit
end if
cls
end loop
%Draws the race track
setscreen ("graphics")
drawfilloval (200, midy, 195, 190, 45)
drawfilloval (442, midy, 195, 190, 45)
drawfillarc (180, midy, 75, 85, 0, -360, 7)
drawfillarc (450, midy, 75, 85, 0, -360, 7)
delay (500)
%Starts race countdown
Font.Draw ("On your mark, ", 35, 300, font5, 38)
delay (2000)
cls
drawfilloval (200, midy, 195, 190, 45)
drawfilloval (442, midy, 195, 190, 45)
drawfillarc (180, midy, 75, 85, 0, -360, 7)
drawfillarc (450, midy, 75, 85, 0, -360, 7)
Font.Draw ("Get Set!", 180, 280, font5, 41)
delay (1000)
cls
drawfilloval (200, midy, 195, 190, 45)
drawfilloval (442, midy, 195, 190, 45)
drawfillarc (180, midy, 75, 85, 0, -360, 7)
drawfillarc (450, midy, 75, 85, 0, -360, 7)
Font.Draw ("GO", 170, 250, font6, 40)
delay (500)
Font.Draw (" !", 240, 250, font6, 40)
delay (500)
Font.Draw (" !", 250, 250, font6, 40)
delay (500)
Font.Draw (" !", 270, 250, font6, 40)
delay (1000)
cls
%Redraw race track
loop
drawfilloval (200, midy, 195, 190, 45)
drawfilloval (442, midy, 195, 190, 45)
drawfillarc (180, midy, 75, 85, 0, -360, 7)
drawfillarc (450, midy, 75, 85, 0, -360, 7)
%Red car mouse
mousewhere (x, y, button)
drawfilloval(x, y, 25,25,39)
delay (90)
cls
end loop
|