%variable declaration
View.Set ("graphics:400;300,title:Uncle Worm Score: 0")
var food1 : int
var food2 : int
var foodSize : int
var box1 : int := 0
var box2 : int := maxy
var box3 : int := maxx
var box4 : int := 0
var col : int := 31
var countdown : int := 6
var ballx1 : int := 200
var bally1 : int := 150
var ballsize : int := 5
var move, move2, move3, move4 := false
var key : array char of boolean
var ring : int := 0
var answer : string
move3 := true %starting direction of snake
var score : int := 0
var newMaxX : int := 400 %innitial screen dimensions (x co-ords)
var newMaxY : int := 300 %innitial screen dimensions (y co-ords)
var levelUp : int := 10 %decrease in screen dimensions upon completion of level
var scoreLevel : int := 10
%gives time for user to get ready
loop
locate (9, 18)
put "Starting in...", countdown - 1
delay (300)
countdown := countdown - 1
cls
exit when countdown = 0
end loop
%creates food in random locations
procedure food
randint (food1, 1, 395) %random food location (but not in the walls)
randint (food2, 1, 295) %random food location (but not in the walls)
randint (foodSize, 2, 10) %random food size
drawfilloval (food1, food2, foodSize, foodSize, 2)
end food
%point of contact upon death
procedure ringEnd
loop
drawoval (ballx1, bally1, ballsize + ring, ballsize + ring, ring)
ring += 2
delay (10)
exit when ring = 100
end loop
end ringEnd
%draws food
food
%snake movement
loop
drawbox (box1, box2, box3, box4, 7)
drawfilloval (ballx1, bally1, ballsize, ballsize, col)
if move then
bally1 += 1
elsif move2 then
bally1 -= 1
elsif move3 then
ballx1 += 1
elsif move4 then
ballx1 -= 1
end if
Input.KeyDown (key)
if key (KEY_UP_ARROW) and move2 = false then %Two Conditions: 1. up arrow is pressed 2. move2 = false
move2 := false
move3 := false
move4 := false
move := true
elsif key (KEY_DOWN_ARROW) and move = false then %Two Conditions: 1. down arrow is pressed 2. move = false
move := false
move3 := false
move4 := false
move2 := true
elsif key (KEY_RIGHT_ARROW) and move4 = false then %Two Conditions: 1. right arrow is pressed 2. move4 = false
move := false
move2 := false
move4 := false
move3 := true
elsif key (KEY_LEFT_ARROW) and move3 = false then %Two Conditions: 1. left arrow is pressed 2. move3 = false
move := false
move2 := false
move3 := false
move4 := true
end if
drawfilloval (ballx1, bally1, ballsize, ballsize, 12) %deletes the tail
delay (10)
%wall collision detection
if ballx1 = 4 or ballx1 = maxx - 4 or bally1 = 4 or bally1 = maxy - 4 then
View.Set ("graphics:" + intstr (newMaxX) + ";" + intstr (newMaxY) + ",title:Uncle Worm Score: " + intstr (score) + " You Lose!")
ringEnd
exit
end if
%food collision detection
if whatdotcolour (food1 + foodSize, food2 + foodSize) = 12 or whatdotcolour (food1 - foodSize, food2 - foodSize) = 12
then
score += 10 %when food collision detected points are added to score
View.Set ("graphics:" + intstr (newMaxX) + ";" + intstr (newMaxY) + ",title:Uncle Worm Score: " + intstr (score))
drawfilloval (food1, food2, foodSize, foodSize, white) %so that no chunk of food is left behind
food %when collision detected food is redrawn
end if
%NEXT LEVEL
if score = scoreLevel
then
drawfillbox ((maxx div 2) - 10, maxy, (maxx div 2) + 10, maxy - 5, 4)
scoreLevel += 10
exit when whatdotcolour (ballx1+ballsize,bally1+ballsize)=4
end if
end loop
/*
View.Set ("graphics:" + intstr (newMaxX-levelUp) + ";" + intstr (newMaxY-levelUp) + ",title:Uncle Worm Score: " + intstr (score))
*/
View.Update
|