Computer Science Canada

Haunted Maze

Author:  lilmizeminem [ Mon May 14, 2007 10:36 am ]
Post subject:  Haunted Maze

my group has to make a video game for our final project in computer tech course. Try it out, let me know if you have any ideas ?Thannnnkkkkksss =)! .





%Video Game Assignment
%Steph, Jordan and Rachel
%Our video game is a haunted maze, where the user is a character who has to find his/her way to the middle of the maze,
%where they will recieve a trophy. They have to battle monsters along the way and may use teleporting squares to progress
%through the maze.

View.Set ("graphics:1010;655") %Sets the size of the playing screen
View.Set ("nocursor") %Turn off cursor (the blinking rectangle)
View.Set ("noecho") %Do not echo keystrokes (do not show what has been typed)
View.Set ("offscreenonly") %Creates smoother animation (used with View.Update)
%Writes everything to memory, then when View.Update is used, it is written to the screen
%It saves time and is more effecient

var locx : int := 900 %These numbers (for locx and locy) control where the picture is when the program starts
var locy : int := 30
var direction : string (1) %This only allows one key to be pressed for each action
var picID, picID2, picID3, button, pic : int := 0 %These are the pictures that are used in the game
var x, y : int := 0 %These numbers control where the picture of the maze is drawn on the screen
var Font1, Font2 : int := 0

var xj : int := 90 %Coordinates of the first teleportation box
var yj : int := 330
var x2 : int := 90 %Coordinates of the receiving teleportation box
var y2 : int := 390
var x3 : int := 745 %Coordinates of the second teleportation box
var y3 : int := 400

var monster1, monster2 : int := 0 %Pictures of the monsters
var monsterx : int := 30 %Coordinates of first monster
var monstery : int := 30
var monstermove : int := 0 %Variable for control of random first monster movements
var monster2x : int := 810 %Coordinates of second monster
var monster2y : int := 390
var monstermove2 : int := 0 %Variable for control of random second monster movements

var health : int := 10 %The health of the character
var again : string %Variable for the end screen when the user is asked if they would like to play again

picID := Pic.FileNew ("smallnofoot.bmp") %Picture of the man
picID2 := Pic.FileNew ("stucture.jpg") %Picture of the maze
picID3 := Pic.FileNew ("ghost2.jpg") %Picture of the ghost
monster1 := Pic.FileNew ("monster.gif") %Picture of the monsters
monster2 := Pic.FileNew ("monster.gif")
Font1 := Font.New ("tahoma:15") %Draws the different types of fonts
Font2 := Font.New ("italic:30") %The number after : is the size of the font


loop

colorback (7) %Makes the background of the screen, in this case it will be black
cls
Pic.Draw (picID3, 700, 200, picCopy) %Draws the picture of the ghost

Font.Draw ("Welcome to the Haunted Maze!", 120, 570, Font2, yellow) % all of the font draws, draw the special writing that appears
Font.Draw ("-The object of this game is to get through the maze alive", 20, 500, Font1, brightred)
Font.Draw ("-Watch out for the monsters, if they hit you your health bar will decrease.", 20, 450, Font1, 2)
Font.Draw ("-However, the more you hit the monsters the more points you will recieve", 20, 400, Font1, 2)
Font.Draw ("(press any key to continue)", 400, 5, Font1, 2)
Font.Draw ("-Use the arrow keys to move", 20, 300, Font1, brightred)
Font.Draw ("and the space bar to shoot your gun", 20, 250, Font1, brightred)
Font.Draw ("-Run into the green boxes to teleport to the red boxes ", 20, 180, Font1, brightred)
Font.Draw ("Created by: Jordan, Rachel and Steph ", 650, 100, Font1, yellow)
Font.Draw ("Have Fun!! ", 20, 80, Font1, yellow)
View.Update

exit when hasch %The user is asked to press any key to continue
end loop

Font.Free (Font1) %Frees up the memory that is taken up by the font (Font2 will be used later on)
Pic.Free (picID3) %Frees up the memory that is taken up by the picture of the ghost

loop
loop
Pic.Draw (picID2, x, y, picCopy) %Picture of the maze
Pic.Draw (picID, locx, locy, picCopy) %Picture of the man
Pic.Draw (monster1, monsterx, monstery, picCopy) %Draws the first monster
Pic.Draw (monster2, monster2x, monster2y, picCopy) %Draws the second monster
Draw.FillBox (xj, yj, xj + 30, yj + 30, 13) %Teleporting box
Draw.FillBox (x2, y2, x2 + 30, y2 + 30, 4) %Recieving teleporting box
delay (100)
if health = 10 then
Draw.FillBox (0, 0, 100, 10, blue) %Changes the colour and size of the health bar, depending on what
elsif health = 9 then %the character's health level is
Draw.FillBox (0, 0, 90, 10, blue)
elsif health = 8 then
Draw.FillBox (0, 0, 80, 10, blue)
elsif health = 7 then
Draw.FillBox (0, 0, 70, 10, blue)
elsif health = 6 then
Draw.FillBox (0, 0, 60, 10, 42) %42 is orange
elsif health = 5 then
Draw.FillBox (0, 0, 50, 10, 42)
elsif health = 4 then
Draw.FillBox (0, 0, 40, 10, 42)
elsif health = 3 then
Draw.FillBox (0, 0, 30, 10, red)
elsif health = 2 then
Draw.FillBox (0, 0, 20, 10, red)
elsif health = 1 then
Draw.FillBox (0, 0, 10, 10, red)
end if
View.Update %Writes everything that is in memory to the screen

if whatdotcolor (locx - 1, locy + 15) = 13 or whatdotcolor (locx + 15, locy + 30) = 13 or whatdotcolor (locx + 30, locy + 15) = 13 or whatdotcolor (locx + 13, locy - 1) = 13
then %Coordinates that detect what colour pixel the user's character is on
locx := x2 %Changes the location of the user's character to the location of the recieving teleporting box
locy := y2
for i : 1 .. 10
Music.Sound (100 * i, 100) % Teleporting sound
Music.SoundOff
end for
end if
if locx - 1 = monsterx + 30 or locy + 15 = monstery + 15 and locx + 30 = monsterx - 1 or locy + 15 = monstery + 15 and locx + 15 = monsterx + 15 or locy + 30 = monstery - 1 and locx + 15 =
monsterx + 15 or locy
- 1 = monstery + 30 then %If the location of the character is the same as the location of the monster,
health := health - 1 %the character's health decreases
elsif
locx - 1 = monster2x + 30 or locy + 15 = monster2y + 15 and locx + 30 = monster2x - 1 or locy + 15 = monster2y + 15 and locx + 15 = monster2x + 15 or locy + 30 = monster2y - 1 and locx + 15 =
monster2x + 15 or locy
- 1 = monster2y + 30 then %If the location of the character is the same as the location of the monster,
health := health - 1 %the character's health decreases
end if

if hasch then

Input.getch (direction) %Allows input of a single character without pressing enter after
case ord (direction (1)) of
label 205 : %Right arrow key
if whatdotcolour (locx + 29, locy + 13) = 0 or whatdotcolour (locx + 27, locy + 13) = 4 then %If the pixel colour that the character is on is white, the character will move
locx := locx + 30
picID := Pic.FileNew ("rightfootfaceright.bmp") %Picture of the man facing right
else
Music.Play ("f")
end if

label 203 : %Left arrow key
if whatdotcolour (locx - 5, locy + 25) = 0 or whatdotcolour (locx - 5, locy + 25) = 4 then
locx := locx - 30
picID := Pic.FileNew ("leftfootfaceleft.bmp") %Picture of the man facing left
else
Music.Play ("f")
end if

label 200 : %Up arrow key
if whatdotcolour (locx + 13, locy + 31) = 0 or whatdotcolour (locx + 13, locy + 31) = 4 then
locy := locy + 30
picID := Pic.FileNew ("rightfootfaceup.bmp") %Picture of the man facing up
else
Music.Play ("f")
end if

label 208 : %Down arrow key
if whatdotcolour (locx + 15, locy - 5) = 0 or whatdotcolour (locx + 15, locy - 5) = 4 then
locy := locy - 30
picID := Pic.FileNew ("leftfootfacedown.bmp") %Picture of the man facing down
else
Music.Play ("f")
end if

label 27 : %Esc key
exit
label : %If any other key is pressed, a note is played
Music.Play ("f")
end case
end if
Input.Flush %Stops the keyboard from reading multiple keystrokes because the user pressed the key too long

monstermove := Rand.Int (1, 4) %The computer randomly selects a number between 1 and 4
case monstermove of
delay (10)
label 1 : %If the number is 1, the first monster moves right
if whatdotcolour (monsterx + 30, monstery + 14) = 0 then
monsterx := monsterx + 30
end if

label 2 : %If the number is 2, the first monster moves left
locate (1, 1)
if whatdotcolour (monsterx - 1, monstery + 14) = 0 then
monsterx := monsterx - 30
end if

label 3 : %If the number is 3, the first monster moves up
if whatdotcolour (monsterx + 14, monstery + 30) = 0 then
monstery := monstery + 30
end if

label 4 : %If the number is 4, the first monster moves down
if whatdotcolour (monsterx + 14, monstery - 1) = 0 then
monstery := monstery - 30
end if
label :

end case
monstermove2 := Rand.Int (1, 4) %The computer randomly selects a number between 1 and 4
case monstermove2 of
delay (10)
label 1 : %If the number is 1, the second monster moves right
locate (1, 1)
put whatdotcolour (monster2x + 30, monster2y + 14) ..
if whatdotcolour (monster2x + 30, monster2y + 14) = 0 then
monster2x := monster2x + 30
end if

label 2 : %If the number is 2, the second monster moves left
if whatdotcolour (monster2x - 1, monster2y + 14) = 0 then
monster2x := monster2x - 30
end if

label 3 : %If the number is 3, the second monster moves up
if whatdotcolour (monster2x + 14, monster2y + 30) = 0 then
monster2y := monster2y + 30
end if

label 4 : %If the number is 4, the second monster moves down
if whatdotcolour (monster2x + 14, monster2y - 1) = 0 then
monster2y := monster2y - 30
end if
label :
Input.Flush %Stops the keyboard from reading multiple keystrokes because the user pressed the key too long
end case
exit when health = 0 %When the character's health is 0, the monsters will stop moving
end loop


colourback (7) %Makes the background of the screen, in this case it will be black
cls
Font.Draw ("You're dead!", 400, 400, Font2, brightred)
Font.Draw ("Would you like to play again?", 150, 300, Font2, green)
Font.Draw ("yes or no?", 350, 220, Font2, green)
View.Update %Writes everything that is in memory to the screen
get again
exit when again = "no" or again = "NO" %Exits the game when the user says no or NO to the question, Would you like to
cls %play again?
end loop

colourback (7) %Makes the background of the screen, in this case it will be black
cls
Font.Draw ("Thank you for playing", 250, 600, Font2, brightred)
Font.Draw ("The Haunted Maze", 250, 550, Font2, brightred)
Font.Draw ("By : Jordan, Rachel and Stephanie", 70, 500, Font2, brightred)
View.Update %Writes everything that is in memory to the screen

Font.Free (Font2) %Frees up the memory that is taken up by the font

Author:  tenniscrazy [ Mon May 14, 2007 11:15 am ]
Post subject:  RE:Haunted Maze

i cant run it without the pictures, and don't you already have a thread with the same program??

Author:  lilmizeminem [ Mon May 14, 2007 11:17 am ]
Post subject:  RE:Haunted Maze

yeaa i dont know how to do the thingy withthe folder and the attaching thingy keennan ahaha


: