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 newMaxX : int := 500 %innitial screen dimensions (x co-ords)
 
var newMaxY : int := 400 %innitial screen dimensions (y co-ords)
 
var levelUpX : int := 50 %decrease in screen dimensions (x co-ords) upon completion of level
 
var levelUpY :int :=40 %decrease in screen dimensions (y co-ords) upon completion of level
 
var scoreLevel : int := 50
 
var foodBoolean :boolean
 
var score : int :=0 %score
 
var bonus:int:=60000 %1 min to be able to get bonus 
 
var timeBonus:int :=bonus-Time.Elapsed 
 
var scoreOverall:int :=score+timeBonus
 
 
 
%gives time for user to get ready
 
loop
 
    locate (12, 25)
 
    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, newMaxX-10) %random food location (but not in the walls)
 
    randint (food2, 1, newMaxY-10) %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, newMaxY-1, newMaxX-1, 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
 
        
 
    end if
 
 
 
    %NEXT LEVEL
 
    if score >= scoreLevel
 
            then
 
            drawfillbox ((maxx div 2) - 10, maxy, (maxx div 2) + 10, maxy - 5, 4)
 
        end if
 
        
 
        if whatdotcolour (ballx1+ballsize,bally1+ballsize)=4
 
        then cls
 
        put "Your score is: ", score
 
        put "Your time bonus is: ", timeBonus
 
        put "Your overall score is: ", scoreOverall
 
        put "[press any key to continue to next round]"
 
        Input.Pause         
 
        newMaxX:=newMaxX-levelUpX  
 
        newMaxY:=newMaxY-levelUpY
 
        View.Set ("graphics:" + intstr (newMaxX) + ";" + intstr (newMaxY) + ",title:Uncle Worm           Score: " + intstr (score))
 
        ballx1:=newMaxX div 2 %new x co-ords for the start of a new level
 
        bally1:=newMaxY div 2 %new y co-ords for the start of a new level
 
        food
 
        scoreLevel:=score+50
 
    end if
 
 
 
end loop
 
 
View.Update 
 
  |