% File "mouse.tu". % % Written by Phil Edmonds, Feb 97. % % This is an example of a very simple animal. A mouse is just an animal % that moves very quickly to a random destination % %+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ unit class Mousey inherit Animal in "animal.tu" export InitMousey %========== INITIALIZE ====================================== %============================================================ proc InitMousey (x, y : real, n : string) InitAnimal (x, y, n, gray, 20, 4, 0, 0, 0) end InitMousey %========== PUBLIC FUNCTIONS ================================ %============================================================ % draw an ellipse, with a 'tail' %------------------------------------------------------------ body proc DrawImage var x := round (loc -> GetX) var y := round (loc -> GetY) Draw.Oval (x + 1, y, girth - 2, (girth - 2) div 2, col) Draw.Line (x, y, x - girth, y + girth, col) end DrawImage % move to a random destination, then choose a new destination %------------------------------------------------------------ body proc TakeTurn if ReachedDestination then SetRandomDestination end if Animal.TakeTurn end TakeTurn end Mousey