setscreen ("offscreenonly")
var oldx, oldy : int := 0
var x, y : int := 50
var a, b : int
var leng : int := 10
var key : array char of boolean
var c : int := 0
var score : int := 0
var lives : int := 3
var up1, down1, left1, right1 : boolean := false
var checkButton : int := 0
randint (a, 200, 600)
randint (b, 150, 300)
procedure up
y += 1
end up
procedure down
y -= 1
end down
procedure left
x -= 1
end left
procedure right
x += 1
end right
Draw.FillBox (x - 10, y - leng, x + 10, y + leng, blue)
loop
View.Update
Input.KeyDown (key)
c := c + 1
locate (1, 1)
put "Score: ", score ..
locate (2, 1)
put "Lives: ", lives ..
if x > oldx or y > oldy or x < oldx or y < oldy then
Draw.FillBox (oldx - 10, oldy - leng, oldx + 10, oldy + leng, white)
end if
Draw.FillBox (a - 10, b - 10, a + 10, b + 10, red)
oldx := x
oldy := y
if x > a - 11 and x < a + 11 and y > b - 11 and y < b + 11 then
score += 100
setscreen ("nooffscreenonly")
cls
setscreen ("offscreenonly")
randint (a, 200, 600)
randint (b, 150, 300)
leng += 10
end if
if checkButton = 1 then
up
Draw.FillBox (x - 10, y - leng, x + 10, y + leng, blue)
delay (50)
elsif checkButton = 2 then
down
Draw.FillBox (x - 10, y - leng, x + 10, y + leng, blue)
delay (50)
elsif checkButton = 3 then
left
Draw.FillBox (x - leng, y - 10, x + leng, y + 10, blue)
delay (50)
elsif checkButton = 4 then
right
Draw.FillBox (x - leng, y - 10, x + leng, y + 10, blue)
delay (50)
end if
if up1 = true then
checkButton := 1
up
up1 := false
elsif down1 = true then
checkButton := 2
down
down1 := false
elsif left1 = true then
checkButton := 3
left
left1 := false
elsif right1 = true then
checkButton := 4
right
right1 := false
end if
if c = 255 then
c := 0
end if
if key ('w') then
up1 := true
elsif key ('s') then
down1 := true
elsif key ('a') then
left1 := true
elsif key ('d') then
right1 := true
end if
end loop
|