% ******************************************************
%
% The Turing Programming Language
% Activity #15: The 'Blocksies' Game!
% Date: Friday, January 21st, 2005
% Prepared by: Amreen Azam
% Prepared for: Mr. Henrich
% Class: TEE201-01
%
% ******************************************************
var Level: int
var Response: string
put "Welcome to the Blocksies Game!"
put "Please choose your level (1, 2 or 3): "
put "1. BABY (The blocker is large and the asterisks fall slower!)"
put "2. INTERMEDIATE (The blocker is medium and the asterisks at a steady pace!)"
put "3. ADVANCED (The blocker is small and the asterisks fall fast!)"
get Level
cls
case Level of
label 1: put "Welcome to Blocksies Game. This level is Baby which means that"
put "the blocker located on the bottom of the screen is larger than"
put "the rest of the levels and also, the asterisks fall slower."
put "The object of this game is to block the asterisks by moving the"
put "blocker at the bottom of the screen, by using left and right <ARROW>"
put "key along with the <HOME>, which makes the blocker move to the far"
put "left of the screen, and <END>, which makes the blocker move to the"
put "far right of the screen. You have 10 asterisks to hit. GOOD LUCK!!!"
put "BEAT THE CLOCK!"
label 2: put "Welcome to Blocksies Game. This level is Intermediate which means that"
put "the blocker located on the bottom of the screen is small"
put "and also, the asterisks fall slower."
put "The object of this game is to block the asterisks by moving the"
put "blocker at the bottom of the screen, by using left and right <ARROW>"
put "key along with the <HOME>, which makes the blocker move to the far"
put "left of the screen, and <END>, which makes the blocker move to the"
put "far right of the screen. You have 10 asterisks to hit. GOOD LUCK!!!"
put "BEAT THE CLOCK!"
label 3: put "Welcome to Blocksies Game. This level is Advance which means that"
put "the blocker located on the bottom of the screen is the smallest compared"
put "to the rest of the levels. Also, the asterisks fall the fastest in this level."
put "The object of this game is to block the asterisks by moving the"
put "blocker at the bottom of the screen, by using left and right <ARROW>"
put "key along with the <HOME>, which makes the blocker move to the far"
put "left of the screen, and <END>, which makes the blocker move to the"
put "far right of the screen. You have 10 asterisks to hit. GOOD LUCK!!!"
put "BEAT THE CLOCK!"
label : put "You entered an invalid number! Please pick a level!"
end case
if Level=1 then
%This program is what the BLOCKSIES game is going to look like
%as this is the structure of the game.
const BLOCKER:=
chr(220)+chr(220)+chr(220)+chr(220)+chr(220)
const WAIT:=125
const NUMBER_OF_ASTERISKS:=10
const LEFT_ARROW:= chr(203)
const RIGHT_ARROW:= chr(205)
const HOME:= chr(199)
const END:= chr(207)
const BLOCKER_ROW:=24
const BLANK_BLOCKER:= " " % 10 blank spaces
var Key:string (1)
var Asterisks_Column, Start, Finish:int
var Blocker_Column:= 38
var Asterisks_Row:=2
setscreen ("noecho, nocursor")
% We set the screen because we want to make sure that the user's
% keystrokes and not displayed and also to hide the cursor
% while the game is being played. Also, we set up the global vaiables
% and constants that will be needed in this program.
procedure Move_Blocker
%We wait for the user to press a key.
getch (Key)
%We erase a previously positioned blocker.
locate (BLOCKER_ROW, Blocker_Column)
put BLANK_BLOCKER
%We adjust the position of the blocker according
%to the direction specified by the user.
if Key = RIGHT_ARROW then
Blocker_Column:= Blocker_Column + 2
elsif Key = LEFT_ARROW then
Blocker_Column :=Blocker_Column - 2
elsif Key = HOME then
Blocker_Column:= 2
elsif Key = END then
Blocker_Column:= 75
end if
%We do not allow the blocker to be moved
%beyond the borders of the screen.
if Blocker_Column > 75 then
Blocker_Column:=75
elsif Blocker_Column < 2 then
Blocker_Column:=2
end if
%The blocker is displayed on the screen.
locate (BLOCKER_ROW, Blocker_Column)
put BLOCKER
end Move_Blocker
%This will randomly determine the column that each
%asterisk is going to fall from.
randomize
%Clock keeps track of the time (in milliseconds) that
%Turing has been in use.
clock(Start)
for Asterisk:1..NUMBER_OF_ASTERISKS
locate (1,1)
put "Asterisk #",Asterisk
randint (Asterisks_Column, 2, 79)
loop
locate (Asterisks_Row, Asterisks_Column)
put "*"..
delay (WAIT)
if hasch then
Move_Blocker
end if
locate (Asterisks_Row, Asterisks_Column)
put " "
Asterisks_Row:=Asterisks_Row + 1
if Asterisks_Row > 24 then
Asterisks_Row:= 2
end if
if Asterisks_Column >= Blocker_Column and
Asterisks_Column <= Blocker_Column + 4 and
Asterisks_Row = 24 then
sound (100, 100)
exit
elsif Asterisks_Row = 24 and
(Asterisks_Column < Blocker_Column or
Asterisks_Column > Blocker_Column + 4) then
sound (100,100)
end if
end loop
end for
clock (Finish)
cls
put "TIME: ", (Finish - Start) / 1000, " Seconds."
elsif Level=2 then
const BLOCKER:=
chr(220)+chr(220)+chr(220)+chr(220)+chr(220)
const WAIT:=125
const NUMBER_OF_ASTERISKS:=10
const LEFT_ARROW:= chr(203)
const RIGHT_ARROW:= chr(205)
const HOME:= chr(199)
const END:= chr(207)
const BLOCKER_ROW:=24
const BLANK_BLOCKER:= " " % 6 blank spaces
var Key:string (1)
var Asterisks_Column, Start, Finish:int
var Blocker_Column:= 38
var Asterisks_Row:=2
setscreen ("noecho, nocursor")
% We set the screen because we want to make sure that the user's
% keystrokes and not displayed and also to hide the cursor
% while the game is being played. Also, we set up the global vaiables
% and constants that will be needed in this program.
procedure Move_Blocker
%We wait for the user to press a key.
getch (Key)
%We erase a previously positioned blocker.
locate (BLOCKER_ROW, Blocker_Column)
put BLANK_BLOCKER
%We adjust the position of the blocker according
%to the direction specified by the user.
if Key = RIGHT_ARROW then
Blocker_Column:= Blocker_Column + 2
elsif Key = LEFT_ARROW then
Blocker_Column :=Blocker_Column - 2
elsif Key = HOME then
Blocker_Column:= 2
elsif Key = END then
Blocker_Column:= 75
end if
%We do not allow the blocker to be moved
%beyond the borders of the screen.
if Blocker_Column > 75 then
Blocker_Column:=75
elsif Blocker_Column < 2 then
Blocker_Column:=2
end if
%The blocker is displayed on the screen.
locate (BLOCKER_ROW, Blocker_Column)
put BLOCKER
end Move_Blocker
%This will randomly determine the column that each
%asterisk is going to fall from.
randomize
%Clock keeps track of the time (in milliseconds) that
%Turing has been in use.
clock(Start)
for Asterisk:1..NUMBER_OF_ASTERISKS
locate (1,1)
put "Asterisk #",Asterisk
randint (Asterisks_Column, 2, 79)
loop
locate (Asterisks_Row, Asterisks_Column)
put "*"..
delay (2000)
if hasch then
Move_Blocker
end if
locate (Asterisks_Row, Asterisks_Column)
put " "
Asterisks_Row:=Asterisks_Row + 1
if Asterisks_Row > 24 then
Asterisks_Row:= 2
end if
if Asterisks_Column >= Blocker_Column and
Asterisks_Column <= Blocker_Column + 4 and
Asterisks_Row = 24 then
sound (100, 100)
exit
elsif Asterisks_Row = 24 and
(Asterisks_Column < Blocker_Column or
Asterisks_Column > Blocker_Column + 4) then
sound (100,100)
end if
end loop
end for
clock (Finish)
cls
put "TIME: ", (Finish - Start) / 1000, " Seconds."
elsif Level=3 then
%This program is what the BLOCKSIES game is going to look like
%as this is the structure of the game.
const BLOCKER:=
chr(220)+chr(220)+chr(220)+chr(220)+chr(220)
const WAIT:=125
const NUMBER_OF_ASTERISKS:=10
const LEFT_ARROW:= chr(203)
const RIGHT_ARROW:= chr(205)
const HOME:= chr(199)
const END:= chr(207)
const BLOCKER_ROW:=24
const BLANK_BLOCKER:= " " % 3 blank spaces
var Key:string (1)
var Asterisks_Column, Start, Finish:int
var Blocker_Column:= 38
var Asterisks_Row:=2
setscreen ("noecho, nocursor")
% We set the screen because we want to make sure that the user's
% keystrokes and not displayed and also to hide the cursor
% while the game is being played. Also, we set up the global vaiables
% and constants that will be needed in this program.
procedure Move_Blocker
%We wait for the user to press a key.
getch (Key)
%We erase a previously positioned blocker.
locate (BLOCKER_ROW, Blocker_Column)
put BLANK_BLOCKER
%We adjust the position of the blocker according
%to the direction specified by the user.
if Key = RIGHT_ARROW then
Blocker_Column:= Blocker_Column + 2
elsif Key = LEFT_ARROW then
Blocker_Column :=Blocker_Column - 2
elsif Key = HOME then
Blocker_Column:= 2
elsif Key = END then
Blocker_Column:= 75
end if
%We do not allow the blocker to be moved
%beyond the borders of the screen.
if Blocker_Column > 75 then
Blocker_Column:=75
elsif Blocker_Column < 2 then
Blocker_Column:=2
end if
%The blocker is displayed on the screen.
locate (BLOCKER_ROW, Blocker_Column)
put BLOCKER
end Move_Blocker
%This will randomly determine the column that each
%asterisk is going to fall from.
randomize
%Clock keeps track of the time (in milliseconds) that
%Turing has been in use.
clock(Start)
for Asterisk:1..NUMBER_OF_ASTERISKS
locate (1,1)
put "Asterisk #",Asterisk
randint (Asterisks_Column, 2, 79)
loop
locate (Asterisks_Row, Asterisks_Column)
put "*"..
delay (500)
if hasch then
Move_Blocker
end if
locate (Asterisks_Row, Asterisks_Column)
put " "
Asterisks_Row:=Asterisks_Row + 1
if Asterisks_Row > 24 then
Asterisks_Row:= 2
end if
if Asterisks_Column >= Blocker_Column and
Asterisks_Column <= Blocker_Column + 4 and
Asterisks_Row = 24 then
sound (100, 100)
exit
elsif Asterisks_Row = 24 and
(Asterisks_Column < Blocker_Column or
Asterisks_Column > Blocker_Column + 4) then
sound (100,100)
end if
end loop
end for
clock (Finish)
cls
put "TIME: ", (Finish - Start) / 1000, " Seconds."
else
Response:= "You entered an invalid number."
end if
put ""
|