Turing: |
setscreen ("title:Dragon Rage")
setscreen ("graphics:1000,600")
buttonchoose ("multibutton")
var edgeovalx1, edgeovalx2, edgeovaly1, engeovaly2, font1, font2, font3, font4, titlepic1, titlepic2, mousex, mousey, click, score : int
var textx, pic1, pic2, pic3, pic4, linex1, linex2, liney1, liney2, ovalonex, ovaloney, ovaltwox, ovaltwoy, mainovalx, mainovaly : int
var ball1speedx, ball1speedy, ball2speedx, ball2speedy, ball3speedx, ball3speedy, ball4speedx, ball4speedy, ballspeed, speedtime : int
var dragonspeed, knightspeed, difficulty, filenumb : int
var high : int := 0
var ovalsize1 : int := 50
var ovalsize2 : int := 25
var filename : string := "Highscore.txt"
pic1 := Pic.FileNew ("Pictures/Dragon.jpg")
pic2 := Pic.FileNew ("Pictures/Dragon2.jpg")
pic3 := Pic.FileNew ("Pictures/Dragon3.jpg")
pic4 := Pic.FileNew ("Pictures/Dragon4.jpg")
titlepic1 := Pic.FileNew ("Pictures/Titledragon1.jpg")
titlepic2 := Pic.FileNew ("Pictures/Titledragon2.jpg")
font1 := Font.New ("Comic Sans MS:36:bold")
font2 := Font.New ("Arial:20:bold")
font3 := Font.New ("Arial:10")
font4 := Font.New ("Comic Sans MS:32")
procedure title
Font.Draw ("Dragon Rage", textx + 2, 475, font1, 12)
Font.Draw ("Dragon Rage", textx - 2, 475, font1, 12)
Font.Draw ("Dragon Rage", textx, 475, font1, yellow)
end title
procedure edgecircles
drawfilloval (edgeovalx1, edgeovaly1, 10, 10, 12)
drawfilloval (edgeovalx2, engeovaly2, 10, 10, 12)
drawoval (edgeovalx1, edgeovaly1, 10, 10, yellow)
drawoval (edgeovalx2, engeovaly2, 10, 10, yellow)
delay (50)
drawfilloval (edgeovalx1, edgeovaly1, 11, 11, 7)
drawfilloval (edgeovalx2, engeovaly2, 11, 11, 7)
end edgecircles
procedure mouse
mousewhere (mousex, mousey, click )
drawfillbox (150, 250, 300, 325, 12)
drawbox (150, 250, 300, 325, yellow)
drawfillbox (700, 250, 850, 325, 12)
drawbox (700, 250, 850, 325, yellow)
if mousex >= 150 and mousex <= 300 and mousey >= 250 and mousey <= 325 then
drawfillbox (150, 250, 300, 325, 10)
drawbox (150, 250, 300, 325, yellow)
elsif mousex >= 700 and mousex <= 850 and mousey >= 250 and mousey <= 325 then
drawfillbox (700, 250, 850, 325, 10)
drawbox (700, 250, 850, 325, yellow)
end if
end mouse
loop
textx := 400
edgeovalx1 := 20
edgeovaly1 := 20
edgeovalx2 := 980
engeovaly2 := 580
ovalsize1 := 50
ovalsize2 := 25
colourback (7)
cls
Pic.Draw (pic1, 310, 25, picCopy)
Pic.Draw (titlepic1, 180, 65, picCopy)
Pic.Draw (titlepic2, 720, 65, picCopy)
drawfillbox (50, 450, 950, 550, 12)
drawbox (50, 450, 950, 550, yellow)
drawfillbox (65, 497, 150, 503, brown)
drawfillbox (96, 495, 150, 505, grey)
drawbox (65, 497, 95, 503, 7)
drawfillbox (90, 480, 95, 520, brown)
drawbox (90, 480, 95, 520, 7)
drawfilloval (70, 500, 7, 7, yellow)
drawfilloval (92, 520, 5, 5, yellow)
drawfilloval (92, 480, 5, 5, yellow)
drawoval (70, 500, 7, 7, 7)
drawoval (92, 520, 5, 5, 7)
drawoval (92, 480, 5, 5, 7)
drawline (150, 495, 150, 505, grey)
drawline (150, 495, 160, 500, grey)
drawline (150, 505, 160, 500, grey)
drawfill (152, 500, grey, grey)
drawfillbox (96, 498, 150, 502, darkgrey)
drawline (150, 498, 150, 502, darkgrey)
drawline (150, 498, 155, 500, darkgrey)
drawline (150, 502, 155, 500, darkgrey)
drawfill (152, 500, darkgrey, darkgrey)
drawfillbox (935, 497, 910, 503, brown)
drawfillbox (904, 495, 850, 505, grey)
drawbox (935, 497, 910, 503, 7)
drawfillbox (910, 480, 905, 520, brown)
drawbox (910, 480, 905, 520, 7)
drawfilloval (930, 500, 7, 7, yellow)
drawfilloval (908, 520, 5, 5, yellow)
drawfilloval (908, 480, 5, 5, yellow)
drawoval (930, 500, 7, 7, 7)
drawoval (908, 520, 5, 5, 7)
drawoval (908, 480, 5, 5, 7)
drawline (850, 495, 850, 505, grey)
drawline (850, 495, 840, 500, grey)
drawline (850, 505, 840, 500, grey)
drawfill (848, 500, grey, grey)
drawfillbox (904, 498, 850, 502, darkgrey)
drawline (850, 498, 850, 502, darkgrey)
drawline (850, 498, 845, 500, darkgrey)
drawline (850, 502, 845, 500, darkgrey)
drawfill (848, 500, darkgrey, darkgrey)
Font.Draw ("New Game", 159, 350, font2, yellow)
Font.Draw ("Exit", 750, 350, font2, yellow)
loop
loop
title
mouse
if (mousex >= 150 and mousex <= 300 and mousey >= 250 and mousey <= 325 and click = 1)
or (mousex >= 700 and mousex <= 850 and mousey >= 250 and mousey <= 325 and click = 1) then
exit
end if
textx := textx - 2
edgeovalx1 := edgeovalx1 + 20
edgeovalx2 := edgeovalx2 - 20
edgecircles
exit when edgeovalx1 = 980
end loop
if (mousex >= 150 and mousex <= 300 and mousey >= 250 and mousey <= 325 and click = 1)
or (mousex >= 700 and mousex <= 850 and mousey >= 250 and mousey <= 325 and click = 1) then
exit
end if
loop
title
mouse
if (mousex >= 150 and mousex <= 300 and mousey >= 250 and mousey <= 325 and click = 1)
or (mousex >= 700 and mousex <= 850 and mousey >= 250 and mousey <= 325 and click = 1) then
exit
end if
textx := textx - 2
edgeovaly1 := edgeovaly1 + 20
engeovaly2 := engeovaly2 - 20
edgecircles
exit when edgeovaly1 = 580
end loop
if (mousex >= 150 and mousex <= 300 and mousey >= 250 and mousey <= 325 and click = 1)
or (mousex >= 700 and mousex <= 850 and mousey >= 250 and mousey <= 325 and click = 1) then
exit
end if
loop
title
mouse
if (mousex >= 150 and mousex <= 300 and mousey >= 250 and mousey <= 325 and click = 1)
or (mousex >= 700 and mousex <= 850 and mousey >= 250 and mousey <= 325 and click = 1) then
exit
end if
textx := textx + 2
edgeovalx1 := edgeovalx1 - 20
edgeovalx2 := edgeovalx2 + 20
edgecircles
exit when edgeovalx1 = 20
end loop
if (mousex >= 150 and mousex <= 300 and mousey >= 250 and mousey <= 325 and click = 1)
or (mousex >= 700 and mousex <= 850 and mousey >= 250 and mousey <= 325 and click = 1) then
exit
end if
loop
title
mouse
if (mousex >= 150 and mousex <= 300 and mousey >= 250 and mousey <= 325 and click = 1)
or (mousex >= 700 and mousex <= 850 and mousey >= 250 and mousey <= 325 and click = 1) then
exit
end if
textx := textx + 2
edgeovaly1 := edgeovaly1 - 20
engeovaly2 := engeovaly2 + 20
edgecircles
exit when edgeovaly1 = 20
end loop
if (mousex >= 150 and mousex <= 300 and mousey >= 250 and mousey <= 325 and click = 1)
or (mousex >= 700 and mousex <= 850 and mousey >= 250 and mousey <= 325 and click = 1) then
exit
end if
end loop
if mousex >= 700 and mousex <= 850 and mousey >= 250 and mousey <= 325 then
cls
exit
end if
%dragon's fire
for : 1 .. 10
drawfilloval (maxx div 2, 150, ovalsize1, ovalsize1, yellow)
drawfilloval (maxx div 2, 150, ovalsize2, ovalsize2, 12)
delay (150)
ovalsize1 := ovalsize1 + 100
ovalsize2 := ovalsize2 + 50
end for
cls
Font.Draw ("What difficulty do you wish to play on?", 100, 500, font4, yellow)
Font.Draw ("Easy", 270, 225, font2, yellow)
Font.Draw ("Medium", 450, 225, font2, yellow)
Font.Draw ("Hard", 670, 225, font2, yellow)
Pic.Draw (pic4, 600, 75, picMerge)
Pic.Draw (pic3, 175, 200, picMerge)
Pic.Draw (pic2, 400, 100, picMerge)
loop
mousewhere (mousex, mousey, click )
if mousex >= 270 and mousex <= 330 and mousey >= 225 and mousey <= 250 then
Font.Draw ("Easy", 270, 225, font2, 10)
elsif mousex >= 450 and mousex <= 550 and mousey >= 225 and mousey <= 250 then
Font.Draw ("Medium", 450, 225, font2, 10)
elsif mousex >= 670 and mousex <= 730 and mousey >= 225 and mousey <= 250 then
Font.Draw ("Hard", 670, 225, font2, 10)
else
Font.Draw ("Easy", 270, 225, font2, yellow)
Font.Draw ("Medium", 450, 225, font2, yellow)
Font.Draw ("Hard", 670, 225, font2, yellow)
end if
if mousex >= 270 and mousex <= 330 and mousey >= 225 and mousey <= 250 and click = 1 then
difficulty := 30
exit
elsif mousex >= 450 and mousex <= 550 and mousey >= 225 and mousey <= 250 and click = 1 then
difficulty := 25
exit
elsif mousex >= 670 and mousex <= 730 and mousey >= 225 and mousey <= 250 and click = 1 then
difficulty := 20
exit
end if
end loop
score := 0
cls
setscreen ("nocursor")
var ball1x, ball1y, ball2x, ball2y, ball3x, ball3y, ball4x, ball4y : int := 10
if difficulty = 30 then
ballspeed := 3
speedtime := 50
elsif difficulty = 25 then
ballspeed := 5
speedtime := 125
elsif difficulty = 20 then
ballspeed := 7
speedtime := 250
end if
mainovalx := 500
mainovaly := 300
ovalonex := 100
ovaloney := 100
ovaltwox := 900
ovaltwoy := 500
knightspeed := 1
ball1speedx := ballspeed
ball1speedy := ballspeed
ball2speedx := ballspeed
ball2speedy := ballspeed
ball3speedx := ballspeed
ball3speedy := ballspeed
ball4speedx := ballspeed
ball4speedy := ballspeed
%Instructions
for decreasing i : 3 .. 1
colour (0)
put i, " " ..
drawbox (- 1, 580, 65, maxy + 1, 12)
drawfilloval (ovalonex, ovaloney, 50, 50, 3)
drawfilloval (ovaltwox, ovaltwoy, 25, 25, green)
drawfilloval (mainovalx, mainovaly, 30, 30, 12)
for g : 1 .. 5
drawline (450 + g, 150, 490 + g, 225, 12)
end for
Font.Draw ("Guide your dragon with the mouse", 300, 75, font2, yellow)
Font.Draw ("This is your dragon - do not let him get hit by the knights", 200, 125, font3, yellow)
delay (1000)
end for
loop
for i : 0 .. speedtime
if difficulty = 30 then
dragonspeed := 10
elsif difficulty = 25 then
dragonspeed := 8
elsif difficulty = 20 then
dragonspeed := 7
end if
cls
View.Set ("offscreenonly")
open : filenumb, filename, get
get : filenumb, high
close : filenumb
if high = 1 then
put "Score: ", score, " High Score: N/A"
else
put "Score: ", score, " High Score: ", high
end if
%draws knights and dragon
drawfilloval (ovalonex, ovaloney, 50, 50, 3)
drawfilloval (ovaltwox, ovaltwoy, 25, 25, green)
drawfilloval (mainovalx, mainovaly, 30, 30, 12)
%movement of the knights
if mainovalx > ovalonex then
ovalonex := ovalonex + knightspeed
elsif mainovalx < ovalonex then
ovalonex := ovalonex - knightspeed
end if
if mainovaly > ovaloney then
ovaloney := ovaloney + knightspeed
elsif mainovaly < ovaloney then
ovaloney := ovaloney - knightspeed
end if
if mainovalx > ovaltwox then
ovaltwox := ovaltwox + (knightspeed * 2 - 1)
elsif mainovalx < ovaltwox then
ovaltwox := ovaltwox - (knightspeed * 2 - 1)
end if
if mainovaly > ovaltwoy then
ovaltwoy := ovaltwoy + (knightspeed * 2 - 1)
elsif mainovaly < ovaltwoy then
ovaltwoy := ovaltwoy - (knightspeed * 2 - 1)
end if
%borders (knight 1)
if ovalonex > 950 then
ovalonex := 950
end if
if ovalonex < 50 then
ovalonex := 50
end if
if ovaloney > 550 then
ovaloney := 550
end if
if ovaloney < 50 then
ovaloney := 50
end if
%borders (knight 2)
if ovaltwox > 975 then
ovaltwox := 975
end if
if ovaltwox < 25 then
ovaltwox := 25
end if
if ovaltwoy > 575 then
ovaltwoy := 575
end if
if ovaltwoy < 25 then
ovaltwoy := 25
end if
%borders (dragon)
if mainovalx > 970 then
mainovalx := 970
end if
if mainovalx < 30 then
mainovalx := 30
end if
if mainovaly > 570 then
mainovaly := 570
end if
if mainovaly < 30 then
mainovaly := 30
end if
%--------------------------------------------------%
if score >= 1000 then
drawfilloval (ball1x, ball1y, 10, 10, yellow)
if mainovalx + 21 >= ball1x - 6 and mainovaly + 21 >= ball1y - 6 and mainovalx - 21 <= ball1x + 6 and mainovaly - 21 <= ball1y + 6 then
exit
end if
ball1x := ball1x + ball1speedx
ball1y := ball1y + ball1speedy
if ball1x <= 10 then
ball1x := 10
ball1speedx := ball1speedx * (- 1)
elsif ball1x >= 990 then
ball1x := 990
ball1speedx := ball1speedx * (- 1)
end if
if ball1y <= 10 then
ball1y := 10
ball1speedy := ball1speedy * (- 1)
elsif ball1y >= 590 then
ball1y := 590
ball1speedy := ball1speedy * (- 1)
end if
end if
if score >= 2000 then
drawfilloval (ball2x, ball2y, 10, 10, yellow)
if mainovalx + 21 >= ball2x - 6 and mainovaly + 21 >= ball2y - 6 and mainovalx - 21 <= ball2x + 6 and mainovaly - 21 <= ball2y + 6 then
exit
end if
ball2x := ball2x + ball2speedx
ball2y := ball2y + ball2speedy
if ball2x <= 10 then
ball2x := 10
ball2speedx := ball2speedx * (- 1)
elsif ball2x >= 990 then
ball2x := 990
ball2speedx := ball2speedx * (- 1)
end if
if ball2y <= 10 then
ball2y := 10
ball2speedy := ball2speedy * (- 1)
elsif ball2y >= 590 then
ball2y := 590
ball2speedy := ball2speedy * (- 1)
end if
end if
if score >= 3000 then
drawfilloval (ball3x, ball3y, 10, 10, yellow)
if mainovalx + 21 >= ball3x - 6 and mainovaly + 21 >= ball3y - 6 and mainovalx - 21 <= ball3x + 6 and mainovaly - 21 <= ball3y + 6 then
exit
end if
ball3x := ball3x + ball3speedx
ball3y := ball3y + ball3speedy
if ball3x <= 10 then
ball3x := 10
ball3speedx := ball3speedx * (- 1)
elsif ball3x >= 990 then
ball3x := 990
ball3speedx := ball3speedx * (- 1)
end if
if ball3y <= 10 then
ball3y := 10
ball3speedy := ball3speedy * (- 1)
elsif ball3y >= 590 then
ball3y := 590
ball3speedy := ball3speedy * (- 1)
end if
end if
if score >= 4000 then
drawfilloval (ball4x, ball4y, 10, 10, yellow)
if mainovalx + 21 >= ball4x - 6 and mainovaly + 21 >= ball4y - 6 and mainovalx - 21 <= ball4x + 6 and mainovaly - 21 <= ball4y + 6 then
exit
end if
ball4x := ball4x + ball4speedx
ball4y := ball4y + ball4speedy
if ball4x <= 10 then
ball4x := 10
ball4speedx := ball4speedx * (- 1)
elsif ball4x >= 990 then
ball4x := 990
ball4speedx := ball4speedx * (- 1)
end if
if ball4y <= 10 then
ball4y := 10
ball4speedy := ball4speedy * (- 1)
elsif ball4y >= 590 then
ball4y := 590
ball4speedy := ball4speedy * (- 1)
end if
end if
View.Update
if score >= 5000 then
score := 5000
exit
end if
%--------------------------------------------------%
delay (difficulty )
%movement of the dragom
mousewhere (mousex, mousey, click )
if mainovalx > mousex then
mainovalx := mainovalx - dragonspeed
end if
if mainovaly > mousey then
mainovaly := mainovaly - dragonspeed
end if
if mainovalx < mousex then
mainovalx := mainovalx + dragonspeed
end if
if mainovaly < mousey then
mainovaly := mainovaly + dragonspeed
end if
%if either knight hits the dragon it exits loop
if mainovalx + 21 >= ovalonex - 35 and mainovaly + 21 >= ovaloney - 35 and mainovalx - 21 <= ovalonex + 35 and mainovaly - 21 <= ovaloney + 35
or mainovalx + 21 >= ovaltwox - 17 and mainovaly + 21 >= ovaltwoy - 17 and mainovalx - 21 <= ovaltwox + 17 and mainovaly - 21 <= ovaltwoy + 17 then
exit
end if
if difficulty = 30 then
score := score + 5
elsif difficulty = 25 then
score := score + 2
elsif difficulty = 20 then
score := score + 1
end if
end for
if score >= 1000 and mainovalx + 21 >= ball1x - 6 and mainovaly + 21 >= ball1y - 6 and mainovalx - 21 <= ball1x + 6 and mainovaly - 21 <= ball1y + 6 then
exit
end if
if score >= 2000 and mainovalx + 21 >= ball2x - 6 and mainovaly + 21 >= ball2y - 6 and mainovalx - 21 <= ball2x + 6 and mainovaly - 21 <= ball2y + 6 then
exit
end if
if score >= 3000 and mainovalx + 21 >= ball3x - 6 and mainovaly + 21 >= ball3y - 6 and mainovalx - 21 <= ball3x + 6 and mainovaly - 21 <= ball3y + 6 then
exit
end if
if score >= 4000 and mainovalx + 21 >= ball4x - 6 and mainovaly + 21 >= ball4y - 6 and mainovalx - 21 <= ball4x + 6 and mainovaly - 21 <= ball4y + 6 then
exit
end if
if score >= 5000 then
score := 5000
exit
end if
%if either knight hits the dragon it exits loop
if mainovalx + 21 >= ovalonex - 35 and mainovaly + 21 >= ovaloney - 35 and mainovalx - 21 <= ovalonex + 35 and mainovaly - 21 <= ovaloney + 35
or mainovalx + 21 >= ovaltwox - 17 and mainovaly + 21 >= ovaltwoy - 17 and mainovalx - 21 <= ovaltwox + 17 and mainovaly - 21 <= ovaltwoy + 17 then
exit
end if
knightspeed := knightspeed + 1
if knightspeed >= 3 then
knightspeed := 3
end if
end loop
View.Set ("nooffscreenonly")
if score = 5000 then
cls
put "Score: ", score, " High Score: ", high
drawfilloval (ovalonex, ovaloney, 50, 50, 3)
drawfilloval (ovaltwox, ovaltwoy, 25, 25, green)
drawfilloval (mainovalx, mainovaly, 30, 30, 12)
drawfilloval (ball1x, ball1y, 10, 10, yellow)
drawfilloval (ball2x, ball2y, 10, 10, yellow)
drawfilloval (ball3x, ball3y, 10, 10, yellow)
drawfilloval (ball4x, ball4y, 10, 10, yellow)
Font.Draw ("You Win!", maxx div 2 - 50, maxy div 2, font2, yellow)
delay (1250)
high := 0
open : filenumb, filename, put
put : filenumb, 1
close : filenumb
cls
else
Font.Draw ("You Lose.", maxx div 2 - 50, maxy div 2, font2, yellow)
delay (1250)
cls
end if
if score < 5000 and score > high then
open : filenumb, filename, put
put : filenumb, score
close : filenumb
high := score
end if
end loop
|
|