Computer Science Canada

Sheep Herding

Author:  GregLP [ Tue Oct 25, 2005 6:14 pm ]
Post subject:  Sheep Herding

code:

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 <= x2 + 20 and y - 20 >= y2 - 20 and y - 20 <= y2 + 20
end loop

put "You win!!!"


Nowhere near done, procedures, intro, conclusion, music, sound fx to come!

A little bit of fun here. The one thing I need help on is making the "sheep" window smaller so all you really see is the sheep and not all the white space. Turing doesn't seem to let me make the window any smaller.

I'd also like some ideas for how to make a more "sheep like" movement that is not so linear (ooh big word!)

Comments are definitely welcome!

Author:  Tony [ Tue Oct 25, 2005 7:54 pm ]
Post subject: 

to make the window smaller, you might have to remove the bar with control buttons turing places. Check out View.Set(), there got to be an option for removing that part.


: