|
|
|
run "turtle make "Animal [ [:weight :x :name :color_] local "minDistance "turtl "move_a_bit "run_away "look_for make "minDistance 40 make "turtl turtle ; make [domain] "turtl ;won`t work. No local domains? ;How to make inheritance then? to turtl.init ;this is a workaround for the moment ; hide ;for speeding it up right 90 pu setxy x -150 pd end turtl.init to move_a_bit make "x x+(random 20)-10 turtl.color color_ turtl.setxy x turtl.pos.y+1 end to run_away_from :dog make "x x+100/weight print name "' ' dog.x-x turtl.color red turtl.fd 100/weight turtl.color color_ end to look_for :dog if abs (dog.x-x) < minDistance [ run_away_from :dog ] [ move_a_bit ] end ] make "cat Animal 10 50 "tom green make "dog Animal 12 0 "spike blue to cat.turtl.image if :showit [ make "shape circle :pos 10 ] end while "true [ dog.look_for cat cat.look_for dog ] |
|
|
|