% Ryan Murray TIK2O
% December 8, 2004
% pinball.t
cls
View.Set ("offscreenonly")
var xchange : int
var ychange : int
var score : int
var kolor : int
var lives : int
var x : int
var y : int
var size : int
var col : int %stands for color
var speed : int
var kol : int
var kol2 : int
var gameOver : boolean
gameOver := false
col := 42
score := 0
lives := 5
speed := 0
kol := white
kol2 := black
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
process paddle
var chars : array char of boolean
View.Set ("offscreenonly")
var x, x2 : int
x := 320
x2 := 260
loop
Input.KeyDown (chars) %tells the computer that the user will be entering a character
drawfillbox (x, 10, x2, 20, kol2) %draws a black paddle to erase the white one at the end of the code
if chars (KEY_RIGHT_ARROW) then %tells the computer that if the user enters the right arrow key to move the paddle to the right
x := x + 10
x2 := x2 + 10
end if
if chars (KEY_LEFT_ARROW) then %tells the computer that if the user enters the left arrow key to move the paddle to the left
x := x - 10
x2 := x2 - 10
end if
drawfillbox (x, 10, x2, 20, kol) %draws the paddle
View.Update
delay (20)
if score = 30 then
kol2 := 11
end if
if score = 70 then
kol2 := 50
end if
exit when gameOver %tells teh paddle to exit when count=0
end loop
end paddle
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
process ball
loop
xchange := speed % sets a speed for the ball
exit when xchange not= 0
end loop
loop
ychange := speed
exit when ychange not= 0
end loop
Draw.FillBox (5, 5, maxx - 5, maxy - 5, black)
colorback (black)
cls
kolor := red
size := 6
x := maxx div 2
y := maxy div 2
Draw.FillOval (x, y, size, size, kolor)
loop
drawfillbox (100, 100, 200, 200, col) %draws the shapes
drawfillbox (90, 90, 190, 190, black)
drawfillbox (400, 100, 500, 200, col)
drawfillbox (410, 90, 510, 190, black)
drawfillbox (100, 300, 200, 210, col)
drawfillbox (90, 300, 190, 220, black)
drawfillbox (400, 300, 500, 210, col)
drawfillbox (410, 300, 500, 220, black)
delay (11)
if (x >= maxx - 5 - size - xchange) or (x <= 5 + size - xchange) then %tells the program that if the ball hits the side it will bounce off
xchange := -xchange
end if
if (y >= maxy - 5 - size - ychange) then %tells the program that if th ball hits the top then the ball should bounce off
ychange := -ychange
end if
if (y <= 5 + size - ychange) then %tells the program that if the ball hits the bottom then the ball should bounce off
lives := lives - 1
ychange := -ychange
end if
if xchange > 0 then
if whatdotcolor (x + xchange + size, y) not= black then %tells the program that if the ball hits a color thats not black then it should add a point and bounce off
xchange := -xchange
score := score + 1
end if
else
if
whatdotcolor (x + xchange - size, y) not= black then %tells the program that if the ball hits a color thats not black then it should add a point and bounce off
xchange := -xchange
score := score + 1
end if
end if
if ychange > 0 then
if whatdotcolor (x, y + ychange + size) not= black then %tells the program that if the ball hits a color thats not black then it should add a point and bounce off
ychange := -ychange
score := score + 1
end if
else
if
whatdotcolor (x, y + ychange - size) not= black then %tells the program that if the ball hits a color thats not black then it should add a point and bounce off
ychange := -ychange
score := score + 1
end if
end if
if lives = 2 then %tells the computer that if the lives are at 2 then the ball is yellow
kolor := yellow
end if
if lives = 5 then %tells the computer that if the lives are at 5 then the ball is blue
kolor := blue
end if
if lives = 1 then %tells the computer that if the lives are at 1 then the ball is red
kolor := 12
end if
if lives = 0 then %tells the computer that if the lives are at 0 then the ball is black
kolor := black
end if
locate (1, 1) %%tells the computer to show the score at the top of the screen
color (green)
put "Score:", score
put "Lives:", lives
Draw.FillOval (x, y, size, size, black) %earases the ball
x := x + xchange %tells the ball how much to move
y := y + ychange
Draw.FillOval (x, y, size, size, kolor) %draws the ball
View.Update
if lives = 0 then %tells the computer that if lives = 0 then the game is over
cls
put ""
put ""
put ""
put ""
put ""
put ""
put ""
put " -------------------"
put " GameOver "
put " Your Score is:", score
put " -------------------"
exit
end if
if score = 30 then %tells the computer that if the score is 30 to go to the next level
kol := white
cls
put ""
put ""
put ""
put ""
put ""
put ""
put ""
put " -------------------"
put " Level 2 "
put " -------------------"
delay (1000)
cls
exit
end if
end loop
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
loop
xchange := speed
exit when xchange not= 0
end loop
loop
ychange := speed
exit when ychange not= 0
end loop
size := 6
x := maxx div 2
y := maxy div 2
Draw.FillBox (5, 5, maxx - 5, maxy - 5, 11)
colorback (11)
cls
Draw.FillOval (x, y, size, size, kolor)
loop
drawfilloval (100, 250, 100, 100, 55)
drawfilloval (150, 250, 100, 100, 11)
drawfilloval (540, 250, 100, 100, 55)
drawfilloval (490, 250, 100, 100, 11)
drawfillbox (250, 200, 375, 300, 53)
drawfillbox (275, 225, 350, 275, 11)
drawfillbox (290, 200, 340, 275, 11)
delay (11)
if (x >= maxx - 5 - size - xchange) or (x <= 5 + size - xchange) then
xchange := -xchange
end if
if (y >= maxy - 5 - size - ychange) then
ychange := -ychange
end if
if (y <= 5 + size - ychange) then
lives := lives - 1
ychange := -ychange
end if
if xchange > 0 then
if whatdotcolor (x + xchange + size, y) not= 11 then
xchange := -xchange
score := score + 1
end if
else
if
whatdotcolor (x + xchange - size, y) not= 11 then
xchange := -xchange
score := score + 1
end if
end if
if ychange > 0 then
if whatdotcolor (x, y + ychange + size) not= 11 then
ychange := -ychange
score := score + 1
end if
else
if
whatdotcolor (x, y + ychange - size) not= 11 then
ychange := -ychange
score := score + 1
end if
end if
if lives = 2 then
kolor := yellow
end if
if lives = 5 then
kolor := blue
end if
if lives = 1 then
kolor := 12
end if
if lives = 0 then
kolor := black
end if
locate (1, 1)
color (green)
put "Score:", score
put "Lives:", lives
Draw.FillOval (x, y, size, size, 11)
x := x + xchange
y := y + ychange
Draw.FillOval (x, y, size, size, kolor)
View.Update
if lives = 0 then
cls
put ""
put ""
put ""
put ""
put ""
put ""
put ""
put " -------------------"
put " GameOver "
put " Your Score is:", score
put " -------------------"
exit
end if
if score = 70 then
cls
put ""
put ""
put ""
put ""
put ""
put ""
put ""
put " -------------------"
put " Level 3 "
put " -------------------"
delay (1000)
cls
exit
end if
end loop
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
loop
xchange := speed
exit when xchange not= 0
end loop
loop
ychange := speed
exit when ychange not= 0
end loop
size := 6
x := maxx div 2
y := maxy div 2
Draw.FillBox (5, 5, maxx - 5, maxy - 5, 50)
colorback (50)
cls
Draw.FillOval (x, y, size, size, kolor)
drawfilloval (320, 240, 50, 50, green)
drawfilloval (320, 220, 50, 50, 50)
drawfilloval (200, 240, 50, 50, green)
drawfilloval (200, 220, 50, 50, 50)
drawfilloval (440, 240, 50, 50, green)
drawfilloval (440, 220, 50, 50, 50)
drawfilloval (380, 150, 50, 50, green)
drawfilloval (380, 130, 50, 50, 50)
drawfilloval (260, 150, 50, 50, green)
drawfilloval (260, 130, 50, 50, 50)
loop
delay (11)
if (x >= maxx - 5 - size - xchange) or (x <= 5 + size - xchange) then
xchange := -xchange
end if
if (y >= maxy - 5 - size - ychange) then
ychange := -ychange
end if
if (y <= 5 + size - ychange) then
lives := lives - 1
ychange := -ychange
end if
if xchange > 0 then
if whatdotcolor (x + xchange + size, y) not= 50 then
xchange := -xchange
score := score + 1
end if
else
if
whatdotcolor (x + xchange - size, y) not= 50 then
xchange := -xchange
score := score + 1
end if
end if
if ychange > 0 then
if whatdotcolor (x, y + ychange + size) not= 50 then
ychange := -ychange
score := score + 1
end if
else
if
whatdotcolor (x, y + ychange - size) not= 50 then
ychange := -ychange
score := score + 1
end if
end if
if lives = 2 then
kolor := yellow
end if
if lives = 5 then
kolor := blue
end if
if lives = 1 then
kolor := 12
end if
if lives = 0 then
kolor := black
end if
locate (1, 1)
color (green)
put "Score:", score
put "Lives:", lives
Draw.FillOval (x, y, size, size, 50)
x := x + xchange
y := y + ychange
Draw.FillOval (x, y, size, size, kolor)
View.Update
if lives = 0 then
gameOver := true
exit
end if
end loop
end ball
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
process kolo %makes the paddle and shapes flash
loop
delay (75)
col := Rand.Int (33, 103)
exit when gameOver
end loop
end kolo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
process music1
loop
%pirates/carribean
play ("4d,8f,4g,4g,8g,8a,4b-,4b-,4b-,>4c,<8a,8a,8a,8g,8f,8d,2g") %makes the music %music is taken from compsci.ca and written in turing by ELCOMANDANTE
play ("4d,8f,4g,4g,8g,8a,4b-,4b-,4b-,>4c,4d,8e-,8e-,8d,8c,8d,<1g")
play ("4d,8f,4g,4g,8g,8a,4b-,4b-,4b-,>4c,<8a,8a,8a,8g,8f,8d,2g")
exit when lives = 0
end loop
end music1
process music2
loop
%Sonic the hedgehog casino theme(Sonic 2)
play ("2c,>4e-,2c,4g-,2f,2e-,4c,<2g,4b-,4a-,2g,4e,4e,2e,4e") %makes the music %music is taken from compsci.ca and written in turing by ELCOMANDANTE
play ("4f,4e,4a-,2e,4e,2a,2e,2c,4d,4c,4e-,4d,4c,4d,4c,4e,4e")
play ("2e,4e,4f,4e,4a-,2e,4e,2a,2b,>2c,<2a,2g,4e,2c,2d,2a,2g")
play ("4e,2c,2d,2a,2g,4e,2c,2d,1e-")
exit when lives = 0
end loop
end music2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
color (blue)
put "Instructions:"
put
"Use the keyboard to move the paddle,everytime you hit an object you get a point,once you get so many points you go to the next level. There are three levels. Once you get to the 3rd level try to get the highest score possible."
var song : int
var dif : int
put ""
put "Choose a music:"
put ""
put "Press 1: for Pirates of the Carribean music"
put "Press 2: for Sonic casino music"
put "Press 0: for no music."
View.Update
get song
if song = 1 then
fork music1
elsif song = 2 then
fork music2
else
end if
put "Choose a dificulty level:"
put "1=Beginner"
put "2=Normal"
put "3=Hard"
put "4=Suicide(Good Luck)"
View.Update
get dif
if dif=1 then speed:=1
elsif dif=2 then speed:=3
elsif dif=3 then speed:=5
elsif dif=4 then speed:=15
end if
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%55
fork ball %tells the computer to make the ball and background
fork kolo %tells the computer to make the paddle flash
fork paddle %tells the computer to make the paddle
loop
exit when gameOver = true
end loop
cls
put ""
put ""
put ""
put ""
put ""
put ""
put ""
put " -------------------"
put " GameOver "
put " Your Score is:", score
put " -------------------"
|