%unknown :P
%29/5/2006
%Summative 2
%to play a game
var snakex, snakey : int := 100
var fruit1, fruit2 : int
var count := 0
var direction : string := "null"
var snakey1, snakex1, snakey2, snakex2 : int
var chars : array char of boolean
var a, b, c, d : int
var iWindow : int
unchecked
setscreen ("offscreenonly")
%make the snake grow, make the dot go back, make it run :P
proc fruit
randint (fruit1, 30, 620)
randint (fruit2, 30, 370)
end fruit
proc process1
fruit
end process1
proc snake5
snakey1 := snakey + 18
snakex1 := snakex - 18
snakex2 := snakex + 18
snakey2 := snakey - 18
end snake5
proc snake
drawfilloval (fruit1, fruit2, 5, 5, red)
drawfilloval (snakex, snakey, 10, 10, black)
end snake
proc snakee
drawfilloval (fruit1, fruit2, 5, 5, red)
drawfilloval (snakex, snakey, 10, 10, black)
end snakee
proc lvl2
process1
loop
cls
snake5
snakee
locate (1, 2)
put fruit1, " ", fruit2, "" ..
Input.KeyDown (chars)
if chars (KEY_UP_ARROW) then
View.Update
delay (10)
cls
direction := "up"
locate (2, 1)
elsif chars (KEY_RIGHT_ARROW) then
View.Update
delay (10)
cls
direction := "right"
locate (2, 1)
elsif chars (KEY_LEFT_ARROW) then
View.Update
delay (10)
cls
direction := "left"
locate (2, 1)
elsif chars (KEY_DOWN_ARROW) then
View.Update
delay (10)
cls
direction := "down"
elsif snakex >= fruit1 + 7 and snakex <= fruit1 + 7 and snakey >= fruit2 + 7 and snakey <= fruit2 + 7 then
cls
lvl2
elsif snakex >= 11 and snakey <= 10 or snakex <= 627 and snakey >= 389 or snakex = 627 and snakey >= 1 or snakex = 14 and snakey >= 1 then
snakex := 20
snakey := 20
count += 1
end if
if direction = "up" then
View.Update
snakey += 1
snakey2 -= 1
drawfilloval (snakex, snakey, 10, 10, black)
drawfilloval (snakex, snakey2, 5, 5, black)
elsif direction = "right" then
View.Update
snakex += 1
snakex1 -= 1
drawfilloval (snakex, snakey, 10, 10, black)
drawfilloval (snakex1, snakey, 5, 5, black)
elsif direction = "left" then
View.Update
snakex -= 1
snakex2 -= 1
drawfilloval (snakex, snakey, 10, 10, black)
drawfilloval (snakex2, snakey, 5, 5, black)
elsif direction = "down" then
View.Update
snakey -= 1
snakey1 -= 1
drawfilloval (snakex, snakey, 10, 10, black)
drawfilloval (snakex, snakey1, 5, 5, black)
end if
View.Update
delay (6)
end loop
end lvl2
proc lvl1
process1
loop
View.Update
snake
%:P
put fruit1, " ", fruit2, "" ..
Input.KeyDown (chars)
locate (3, 1)
View.Update
if chars (KEY_UP_ARROW) then
View.Update
delay (10)
cls
direction := "up"
elsif chars (KEY_RIGHT_ARROW) then
View.Update
delay (10)
cls
direction := "right"
elsif chars (KEY_LEFT_ARROW) then
View.Update
delay (10)
cls
direction := "left"
elsif chars (KEY_DOWN_ARROW) then
View.Update
delay (10)
cls
direction := "down"
elsif snakex >= fruit1 + 7 and snakex <= fruit1 + 7 and snakey >= fruit2 + 7 and snakey <= fruit2 + 7 then
View.Update
cls
lvl2
elsif snakex >= 11 and snakey <= 10 or snakex <= 627 and snakey >= 389 or snakex = 627 and snakey >= 1 or snakex = 14 and snakey >= 1 then
snakex := 290
snakey := 200
count += 1
elsif direction = "up" then
View.Update
snakey += 1
drawfilloval (snakex, snakey, 10, 10, black)
elsif direction = "right" then
View.Update
snakex += 1
drawfilloval (snakex, snakey, 10, 10, black)
elsif direction = "left" then
View.Update
snakex -= 1
drawfilloval (snakex, snakey, 10, 10, black)
elsif direction = "down" then
View.Update
snakey -= 1
drawfilloval (snakex, snakey, 10, 10, black)
end if
if count >= 3 then
View.Update
cls
count := 0
put "You died please try again"
end if
exit when count = 3
View.Update
delay (6)
cls
end loop
end lvl1
proc intro
loop
Mouse.ButtonChoose ("multibutton")
var x, y, button, left, middle, right : int
Mouse.Where (x, y, button)
Pic.ScreenLoad ("play.BMP", 250, 200, picCopy)
left := button mod 10 % left = 0 or 1
middle := (button - left) mod 100 % middle = 0 or 10
right := button - middle - left % right = 0 or 100
if left = 1 and x >= 260 and x <= 335 and y >= 210 and y <= 335 then
lvl1
elsif right = 100 then
cls
put "hey it's my program and grapics :P"
end if
%210 = x = 235
%210 = y = 330
View.Update
end loop
end intro
if count = 0 then
intro
end if
Window.Close (iWindow)
|