
-----------------------------------
GregLP
Tue Oct 25, 2005 6:14 pm

Sheep Herding
-----------------------------------

var x : int := maxx
var y : int := maxy
var x2 : int
var y2 : int
var mousex : int := round (maxx / 2)
var mousey : int := round (maxy / 2)
var button : int

randint (x2, 1, maxx)
randint (y2, 1, maxy)

var sheep := Window.Open ("graphics:1;70")
var picID := Pic.FileNew ("sheep.jpeg")
Pic.Draw (picID, 1, 35, picCopy)
var target := Window.Open ("graphics:161;160")

var picIDtarget := Pic.FileNew ("Target.jpg")
Pic.Draw (picIDtarget, 0, 0, picCopy)



Window.SetPosition (target, x2, y2)

loop
    delay (7)
    Window.SetPosition (sheep, x, y)
    Mouse.Where (mousex, mousey, button)
    if mousex > x and mousey > y then
        x -= 2
        y -= 2
    elsif mousex > x and mousey < y then
        x -= 2
        y += 2
    elsif mousex < x and mousey > y then
        x += 2
        y -= 2
    elsif mousex < x and mousey < y then
        x += 2
        y += 2
    end if
    exit when x >= x2 - 20 and x = y2 - 20 and y - 20 