Turing: |
setscreen ("graphics: 1000; 600") %Englarge execution window
setscreen ("onscreenonly") %Generates a smoother appearance
%GRPAHICS -- Variables
var fontmenu : int := Font.New ("impact:20") %Declaring font
var MainMenu : int := Pic.FileNew ("MainMenu.jpg") %Declare image for main menu
var introscreen : int := Pic.FileNew ("logo.jpg") %Declare image for introduction screen
var creditscreen : int := Pic.FileNew ("credits.jpg") %Declare image for credit screen
var gamescreen : int := Pic.FileNew ("gameScreen.jpg") %Declare image for game screen
var endscreen : int := Pic.FileNew ("endscreen.jpg") %Declare image for end screen
var I1 : int := Pic.FileNew ("I1.jpg") %Declare instruction screen (1)
var I2 : int := Pic.FileNew ("I2.jpg") %Declare instruction screen (2)
var I3 : int := Pic.FileNew ("I3.jpg") %Declare instruction screen (3)
var I4 : int := Pic.FileNew ("I4.jpg") %Declare instruction screen (4)
var I5 : int := Pic.FileNew ("I5.jpg") %Declare instruction screen (5)
var IBack : int := Pic.FileNew ("IBack.jpg") %Declare instruction screen background
%Set the following procedures as forward in order to avoid mutual recursion
forward procedure Instructions
forward procedure SongSelect
forward procedure Credits
forward procedure mainmenu
forward procedure lanes
forward procedure endscreen_song
forward procedure Instruction1
forward procedure Instruction2
forward procedure Instruction3
forward procedure Instruction4
forward procedure Instruction5
body procedure Instruction5 % open instruction screen, fifth slide
cls % clear screen
Pic.Draw (I5, 1, 1, 0) % display background of instruction screen
loop
drawfillbox ((maxx - 100), 0, maxx, 100, white)
Font.Draw ("Menu", maxx - 80, 30, fontmenu, red)
drawfillbox (0, maxy - 100, 100, maxy, white)
Font.Draw ("Back", 20, maxy - 80, fontmenu, red)
var m, n, o, p : int
buttonwait ("up", m, n, o, p )
if m >= (maxx - 100) and n >= 0 and m <= maxx and n <= 100 then
Music.PlayFile ("Drum Fill.wav")
cls
mainmenu
elsif m >= 0 and n >= (maxy - 100) and m <= 100 and n <= maxy then
Music.PlayFile ("Drumstick Sound.wav")
cls
Instruction4
end if
end loop
end Instruction5
body procedure Instruction4
cls
Pic.Draw (I4, 1, 1, 0)
loop
drawfillbox ((maxx - 100), 0, maxx, 100, white)
Font.Draw ("Menu", maxx - 80, 30, fontmenu, red)
drawfillbox (maxx - 100, maxy - 100, maxx, maxy, white)
Font.Draw ("Next", maxx - 80, maxy - 80, fontmenu, red)
drawfillbox (0, maxy - 100, 100, maxy, white)
Font.Draw ("Back", 20, maxy - 80, fontmenu, red)
var m, n, o, p : int
buttonwait ("up", m, n, o, p )
if m >= (maxx - 100) and n >= 0 and m <= maxx and n <= 100 then
Music.PlayFile ("Drum Fill.wav")
cls
mainmenu
elsif m >= (maxx - 100) and n >= (maxy - 100) and m <= maxx and n <= maxy then
Music.PlayFile ("Drumstick Sound.wav")
cls
Instruction5
elsif m >= 0 and n >= (maxy - 100) and m <= 100 and n <= maxy then
Music.PlayFile ("Drumstick Sound.wav")
cls
Instruction3
end if
end loop
end Instruction4
body procedure Instruction3
cls
Pic.Draw (I3, 1, 1, 0)
loop
drawfillbox ((maxx - 100), 0, maxx, 100, white)
Font.Draw ("Menu", maxx - 80, 30, fontmenu, red)
drawfillbox (maxx - 100, maxy - 100, maxx, maxy, white)
Font.Draw ("Next", maxx - 80, maxy - 80, fontmenu, red)
drawfillbox (0, maxy - 100, 100, maxy, white)
Font.Draw ("Back", 20, maxy - 80, fontmenu, red)
var m, n, o, p : int
buttonwait ("up", m, n, o, p )
if m >= (maxx - 100) and n >= 0 and m <= maxx and n <= 100 then
Music.PlayFile ("Drum Fill.wav")
cls
mainmenu
elsif m >= (maxx - 100) and n >= (maxy - 100) and m <= maxx and n <= maxy then
Music.PlayFile ("Drumstick Sound.wav")
cls
Instruction4
elsif m >= 0 and n >= (maxy - 100) and m <= 100 and n <= maxy then
Music.PlayFile ("Drumstick Sound.wav")
cls
Instruction2
end if
end loop
end Instruction3
body procedure Instruction2
cls
Pic.Draw (I2, 1, 1, 0)
loop
drawfillbox ((maxx - 100), 0, maxx, 100, white)
Font.Draw ("Menu", maxx - 80, 30, fontmenu, red)
drawfillbox (maxx - 100, maxy - 100, maxx, maxy, white)
Font.Draw ("Next", maxx - 80, maxy - 80, fontmenu, red)
drawfillbox (0, maxy - 100, 100, maxy, white)
Font.Draw ("Back", 20, maxy - 80, fontmenu, red)
var m, n, o, p : int
buttonwait ("up", m, n, o, p )
if m >= (maxx - 100) and n >= 0 and m <= maxx and n <= 100 then
Music.PlayFile ("Drum Fill.wav")
cls
mainmenu
elsif m >= (maxx - 100) and n >= (maxy - 100) and m <= maxx and n <= maxy then
Music.PlayFile ("Drumstick Sound.wav")
cls
Instruction3
elsif m >= 0 and n >= (maxy - 100) and m <= 100 and n <= maxy then
Music.PlayFile ("Drumstick Sound.wav")
cls
Instruction1
end if
end loop
end Instruction2
body procedure Instruction1
cls
Pic.Draw (I1, 1, 1, 0)
loop
drawfillbox ((maxx - 100), 0, maxx, 100, white)
Font.Draw ("Menu", maxx - 80, 30, fontmenu, red)
drawfillbox (maxx - 100, maxy - 100, maxx, maxy, white)
Font.Draw ("Next", maxx - 80, maxy - 80, fontmenu, red)
var m, n, o, p : int
buttonwait ("up", m, n, o, p )
if m >= (maxx - 100) and n >= 0 and m <= maxx and n <= 100 then
Music.PlayFile ("Drum Fill.wav")
cls
mainmenu
elsif m >= (maxx - 100) and n >= (maxy - 100) and m <= maxx and n <= maxy then
Music.PlayFile ("Drumstick Sound.wav")
cls
Instruction2
end if
end loop
end Instruction1
%Instructions Screen
body procedure Instructions
Music.PlayFileLoop ("Mississippi Queen Instrumental.mp3") %Play a song on loop
cls
Instruction1
end Instructions
%Song Select Screen (OPTIONAL)
body procedure SongSelect
cls
loop
drawfill (1, 1, 72, 72)
drawfillbox ((maxx div 2) - 300, (maxy div 2) + 100, (maxx div 2) + 300, (maxy div 2) + 200, white)
drawfillbox ((maxx div 2) - 300, (maxy div 2), (maxx div 2) + 300, (maxy div 2) + 50, white)
drawfillbox ((maxx div 2) - 300, (maxy div 2) - 75, (maxx div 2) + 300, (maxy div 2) - 25, white)
drawfillbox ((maxx div 2) - 300, (maxy div 2) - 150, (maxx div 2) + 300, (maxy div 2) - 100, white)
Font.Draw ("Song Select", (maxx div 2) - 75, (maxy div 2) + 140, fontmenu, red)
drawfillbox ((maxx - 100), 0, maxx, 100, white)
Font.Draw ("Back", maxx - 80, 30, fontmenu, red)
var m, n, o, p : int
buttonwait ("up", m, n, o, p )
if m >= (maxx - 100) and n >= 0 and m <= maxx and n <= 100 then
Music.PlayFile ("Drum Fill.wav")
cls
mainmenu
end if
View.Update
end loop
end SongSelect
%Credits Screen
body procedure Credits
Music.PlayFileLoop ("Foreplay Long Time Boston Instrumental.mp3")
cls
Pic.Draw (creditscreen, 1, 1, 0)
loop
var m, n, o, p : int
buttonwait ("up", m, n, o, p )
if m >= (maxx - 100) and n >= 0 and m <= maxx and n <= 100 then
Music.PlayFile ("Drum Fill.wav")
cls
mainmenu
end if
View.Update
end loop
end Credits
%Main Menu Screen
body procedure mainmenu
Music.PlayFileLoop ("Bullseye Instrumental.mp3")
cls
loop
%Background
Pic.Draw (MainMenu, 1, 1, 0)
var m, n, o, p : int
buttonwait ("up", m, n, o, p )
if m >= 405 and n >= 385 and m <= 957 and n <= 430 then
Music.PlayFile ("Guitar Chord 1.wav")
cls
lanes
elsif m >= 405 and n >= 320 and m <= 957 and n <= 365 then
Music.PlayFile ("Guitar Chord 2.wav")
cls
Instructions
elsif m >= 405 and n >= 260 and m <= 957 and n <= 300 then
Music.PlayFile ("Guitar Chord 4.wav")
cls
Credits
elsif m >= 405 and n >= 200 and m <= 957 and n <= 240 then
quit
end if
View.Update
end loop
end mainmenu
% MAIN PROGRAM: GAME
% MUSIC_SONG 01
process song01_subprogram
Music.PlayFileStop
Music.PlayFile ("demo.mp3")
end song01_subprogram
% GRAPHICS (BUTTONS)
%Declare all images of buttons and notes as sprites
var redkey : int := Pic.FileNew ("scale_rednote.bmp")
var redsprite : int := Sprite.New (redkey )
var bluekey : int := Pic.FileNew ("scale_bluenote.bmp")
var bluesprite : int := Sprite.New (bluekey )
var greenkey : int := Pic.FileNew ("scale_greennote.bmp")
var greensprite : int := Sprite.New (greenkey )
var yellowkey : int := Pic.FileNew ("scale_yellownote.bmp")
var yellowsprite : int := Sprite.New (yellowkey )
var orangekey : int := Pic.FileNew ("scale_orangenote.bmp")
var orangesprite : int := Sprite.New (orangekey )
var redslot : int := Pic.FileNew ("scale_red.bmp")
var slotredsprite : int := Sprite.New (redslot )
Sprite.SetPosition (slotredsprite, 75, 50, false) %set initial position of the sprite
var blueslot : int := Pic.FileNew ("scale_blue.bmp")
var slotbluesprite : int := Sprite.New (blueslot )
Sprite.SetPosition (slotbluesprite, 175, 50, false) %set initial position of the sprite
var greenslot : int := Pic.FileNew ("scale_green.bmp")
var slotgreensprite : int := Sprite.New (greenslot )
Sprite.SetPosition (slotgreensprite, 275, 50, false) %set initial position of the sprite
var yellowslot : int := Pic.FileNew ("scale_yellow.bmp")
var slotyellowsprite : int := Sprite.New (yellowslot )
Sprite.SetPosition (slotyellowsprite, 375, 50, false) %set initial position of the sprite
var orangeslot : int := Pic.FileNew ("scale_orange.bmp")
var slotorangesprite : int := Sprite.New (orangeslot )
Sprite.SetPosition (slotorangesprite, 475, 50, false) %set initial position of the sprite
% ENABLE CONTROLS
var chars : array char of boolean
var hit : boolean := false
Input.KeyDown (chars )
% MAIN PROGRAM VARIABLES & CONSTANTS
var lanenumber : int
const totalnotes : int := 16
% DESCENDING NOTES
var y1 : int := 450
var y2 : int := 450
var y3 : int := 450
var y4 : int := 450
var y5 : int := 450
% DETECT PRESSED KEYS
var one_pressed, two_pressed, three_pressed, four_pressed, five_pressed : boolean := false % declare variables for keys and initialize as "unpressed"
% HIT NOTE COUNT
var count_pt10, count_pt5, count_pt3, count_pt1 : int := 0
var count := 0
var totalpoints : int
var winpercentage : int := 0
% TIME DELAY IN BETWEEN CONSECUTIVE NOTES
var interval : array 1 .. totalnotes of int
interval (1) := (4550)
interval (2) := (120)
interval (3) := (0)
interval (4) := (140)
interval (5) := (165)
interval (6) := (5)
interval (7) := (90)
interval (8) := (170)
interval (9) := (0)
interval (10) := (80) %9.820 SECONDS IN
interval (11) := (170)
interval (12) := (140)
interval (13) := (0)
interval (14) := (160)
interval (15) := (130)
interval (16) := (360) %13.48
% PROCEDURES
% sucessful hit
procedure hitnote
count := count + 1
Sprite.Hide (redsprite )
Sprite.Hide (bluesprite )
Sprite.Hide (greensprite )
Sprite.Hide (yellowsprite )
Sprite.Hide (orangesprite )
Pic.Draw (gamescreen, 1, 1, 0)
if 75 - y1 = 0 or 75 - y2 = 0 or 75 - y3 = 0 or 75 - y4 = 0 or 75 - y5 = 0 then
count_pt10 := count_pt10 + 1
delay (75)
end if
if 75 - y1 = 1 or 75 - y2 = 1 or 75 - y3 = 1 or 75 - y4 = 1 or 75 - y5 = 1 then
count_pt5 := count_pt5 + 1
delay (74)
end if
if 75 - y1 = 2 or 75 - y2 = 2 or 75 - y3 = 2 or 75 - y4 = 2 or 75 - y5 = 2 then
count_pt5 := count_pt5 + 1
delay (73)
end if
if 75 - y1 = 3 or 75 - y2 = 3 or 75 - y3 = 3 or 75 - y4 = 3 or 75 - y5 = 3 then
count_pt5 := count_pt5 + 1
delay (72)
end if
if 75 - y1 = 4 or 75 - y2 = 4 or 75 - y3 = 4 or 75 - y4 = 4 or 75 - y5 = 4 then
count_pt3 := count_pt3 + 1
delay (71)
end if
if 75 - y1 = 5 or 75 - y2 = 5 or 75 - y3 = 5 or 75 - y4 = 5 or 75 - y5 = 5 then
count_pt3 := count_pt3 + 1
delay (70)
end if
if 75 - y1 = 6 or 75 - y2 = 6 or 75 - y3 = 6 or 75 - y4 = 6 or 75 - y5 = 6 then
count_pt1 := count_pt1 + 1
delay (69)
end if
if 75 - y1 = 7 or 75 - y2 = 7 or 75 - y3 = 7 or 75 - y4 = 7 or 75 - y5 = 7 then
count_pt1 := count_pt1 + 1
delay (68)
end if
if 75 - y1 = - 1 or 75 - y2 = - 1 or 75 - y3 = - 1 or 75 - y4 = - 1 or 75 - y5 = - 1 then
count_pt5 := count_pt5 + 1
delay (76)
end if
if 75 - y1 = - 2 or 75 - y2 = - 2 or 75 - y3 = - 2 or 75 - y4 = - 2 or 75 - y5 = - 2 then
count_pt5 := count_pt5 + 1
delay (77)
end if
if 75 - y1 = - 3 or 75 - y2 = - 3 or 75 - y3 = - 3 or 75 - y4 = - 3 or 75 - y5 = - 3 then
count_pt5 := count_pt5 + 1
delay (78)
end if
if 75 - y1 = - 4 or 75 - y2 = - 4 or 75 - y3 = - 4 or 75 - y4 = - 4 or 75 - y5 = - 4 then
count_pt3 := count_pt3 + 1
delay (79)
end if
if 75 - y1 = - 5 or 75 - y2 = - 5 or 75 - y3 = - 5 or 75 - y4 = - 5 or 75 - y5 = - 5 then
count_pt3 := count_pt3 + 1
delay (80)
end if
if 75 - y1 = - 6 or 75 - y2 = - 6 or 75 - y3 = - 6 or 75 - y4 = - 6 or 75 - y5 = - 6 then
count_pt1 := count_pt1 + 1
delay (81)
end if
if 75 - y1 = - 7 or 75 - y2 = - 7 or 75 - y3 = - 7 or 75 - y4 = - 7 or 75 - y5 = - 7 then
count_pt1 := count_pt1 + 1
delay (82)
end if
end hitnote
% animation of descending note in lane 01
procedure line01_individualnote
loop
View.Set ("offscreenonly")
Pic.Draw (gamescreen, 1, 1, 0)
Sprite.Show (slotredsprite )
Sprite.Show (slotbluesprite )
Sprite.Show (slotgreensprite )
Sprite.Show (slotyellowsprite )
Sprite.Show (slotorangesprite )
% lane 01 controls
Input.KeyDown (chars )
if chars ('1') then
one_pressed := true
else
one_pressed := false
end if
% THE y-VALUE
y1 := y1 - 5
exit when y1 = - 25
%collision
if 82 > y1 and y1 > 68 and one_pressed = true then
hitnote
exit
else
end if
Sprite.SetPosition (redsprite, 75, y1 - 25, false)
Sprite.Show (redsprite )
View.Update
delay (5)
end loop
end line01_individualnote
% animation of descending note in lane 01
procedure line02_individualnote
loop
View.Set ("offscreenonly")
Pic.Draw (gamescreen, 1, 1, 0)
Sprite.Show (slotredsprite )
Sprite.Show (slotbluesprite )
Sprite.Show (slotgreensprite )
Sprite.Show (slotyellowsprite )
Sprite.Show (slotorangesprite )
Input.KeyDown (chars )
if chars ('2') then
two_pressed := true
else
two_pressed := false
end if
%THE y-VALUE
y2 := y2 - 5
exit when y2 = - 25
%collision
if 82 > y2 and y2 > 68 and two_pressed = true then
hitnote
exit
else
end if
Sprite.SetPosition (bluesprite, 175, y2 - 25, false)
Sprite.Show (bluesprite )
View.Update
delay (5)
end loop
end line02_individualnote
% animation of descending note in lane 03
procedure line03_individualnote
loop
View.Set ("offscreenonly")
Pic.Draw (gamescreen, 1, 1, 0)
Sprite.Show (slotredsprite )
Sprite.Show (slotbluesprite )
Sprite.Show (slotgreensprite )
Sprite.Show (slotyellowsprite )
Sprite.Show (slotorangesprite )
% lane 03 controls
Input.KeyDown (chars )
if chars ('3') then
three_pressed := true
else
three_pressed := false
end if
% THE y-VALUE
y3 := y3 - 5
exit when y3 = - 25
%collision
if 82 > y3 and y3 > 68 and three_pressed = true then
hitnote
exit
else
end if
Sprite.SetPosition (greensprite, 275, y3 - 25, false)
Sprite.Show (greensprite )
View.Update
delay (5)
end loop
end line03_individualnote
procedure line04_individualnote
loop
View.Set ("offscreenonly")
Pic.Draw (gamescreen, 1, 1, 0)
Sprite.Show (slotredsprite )
Sprite.Show (slotbluesprite )
Sprite.Show (slotgreensprite )
Sprite.Show (slotyellowsprite )
Sprite.Show (slotorangesprite )
% lane 01 controls
Input.KeyDown (chars )
if chars ('4') then
four_pressed := true
else
four_pressed := false
end if
% THE y-VALUE
y4 := y4 - 5
exit when y4 = - 25
%collision
if 82 > y4 and y4 > 68 and four_pressed = true then
hitnote
exit
else
end if
Sprite.SetPosition (yellowsprite, 375, y4 - 25, false)
Sprite.Show (yellowsprite )
View.Update
delay (5)
end loop
end line04_individualnote
procedure line05_individualnote
loop
View.Set ("offscreenonly")
Pic.Draw (gamescreen, 1, 1, 0)
Sprite.Show (slotredsprite )
Sprite.Show (slotbluesprite )
Sprite.Show (slotgreensprite )
Sprite.Show (slotyellowsprite )
Sprite.Show (slotorangesprite )
Input.KeyDown (chars )
if chars ('5') then
five_pressed := true
else
five_pressed := false
end if
% THE y-VALUE
y5 := y5 - 5
exit when y5 = - 25
%collision
if 82 > y5 and y5 > 68 and five_pressed = true then
hitnote
exit
else
end if
Sprite.SetPosition (orangesprite, 475, y5 - 25, false)
Sprite.Show (orangesprite )
View.Update
delay (5)
end loop
end line05_individualnote
% PROCEDURE for consecutive notes within song
body procedure lanes
Music.PlayFileStop
fork song01_subprogram
Sprite.Show (slotredsprite )
Sprite.Show (slotbluesprite )
Sprite.Show (slotgreensprite )
Sprite.Show (slotyellowsprite )
Sprite.Show (slotorangesprite )
for i : 1 .. totalnotes
Pic.Draw (gamescreen, 1, 1, 0)
delay (interval (i ))
randint (lanenumber, 1, 5)
if lanenumber = 1 then
line01_individualnote
elsif lanenumber = 2 then
line02_individualnote
elsif lanenumber = 3 then
line03_individualnote
elsif lanenumber = 4 then
line04_individualnote
elsif lanenumber = 5 then
line05_individualnote
end if
y1 := 450
Pic.Draw (redslot, 75, 50, 0)
y2 := 450
Pic.Draw (blueslot, 175, 50, 0)
y3 := 450
Pic.Draw (greenslot, 275, 50, 0)
y4 := 450
Pic.Draw (yellowslot, 375, 50, 0)
y5 := 450
Pic.Draw (orangeslot, 475, 50, 0)
end for
Sprite.Hide (redsprite )
Sprite.Hide (bluesprite )
Sprite.Hide (greensprite )
Sprite.Hide (yellowsprite )
Sprite.Hide (orangesprite )
endscreen_song
end lanes
body procedure endscreen_song
Sprite.Hide (redsprite )
Sprite.Hide (bluesprite )
Sprite.Hide (greensprite )
Sprite.Hide (yellowsprite )
Sprite.Hide (orangesprite )
Sprite.Hide (slotredsprite )
Sprite.Hide (slotbluesprite )
Sprite.Hide (slotgreensprite )
Sprite.Hide (slotyellowsprite )
Sprite.Hide (slotorangesprite )
cls % clears the screen
Pic.Draw (endscreen, 1, 1, 0) % displays the end screen
totalpoints := (count_pt10 * 10) + (count_pt5 * 5) + (count_pt3 * 3) + (count_pt1 ) % calculates the number of points earned depending on how many notes were hit and to whast degree of accuracy
winpercentage := (totalpoints div (totalnotes * 10)) * 100 % calculates the win percentage
colour (white) % sets font colour to white
colourback (black) % sets background colour of text to black
locatexy (maxx - 50, 540)
put count
locatexy (maxx - 50, 505)
put totalnotes - count
locatexy (maxx - 50, 465)
put winpercentage, "%"
if winpercentage >= 80 then
Font.Draw ("A", 170, 405, fontmenu, white)
elsif winpercentage >= 70 then
Font.Draw ("B", 170, 405, fontmenu, white)
elsif winpercentage >= 60 then
Font.Draw ("C", 170, 405, fontmenu, white)
elsif winpercentage >= 50 then
Font.Draw ("D", 170, 405, fontmenu, white)
else
Font.Draw ("F", 170, 405, fontmenu, white)
end if
var reply : string (1) % declare variable for user's response
getch (reply ) % waits for user to press any key before continuing program
mainmenu % returns to main menu
end endscreen_song
%---------------------------------------------
% PROGRAM BEGINS
Pic.Draw (introscreen, 1, 1, 0) % display introduction screen
delay (3000) % waits 3 seconds before clearing the screen
% GAME BEGINS // MUSIC STARTS PLAYING
mainmenu
|
|