mouse-bubbles_1.1


Information

Created with NetLogo version NetLogo 3.0.2
Running with NetLogoLite.jar version 302.


WHAT IS IT?


A simple model where the size of turtles increases when they are near the mouse pointer

HOW IT WORKS


The size of the turtle is calculated as the cos of the distance from the mouse. If the distance is greater than some limit (1/4th of the screen, here), the size defaults to 1.

NETLOGO FEATURES


This model makes use of the mouse primitives, %mouse-xcor%, %mouse-ycor% and %mouse-inside?%

Procedures

NetLogo Version: NetLogo 3.0.2

;;;; SUMMARY
;; The mouse makes the bubbles swell
;; COPYRIGHT
;;;; Copyright (C) 2006 James P. Steiner
;;;; Some Rights Reserved.
;;;; Licensed under Creative Commons Attribution-Non-Commercial-Share-Alike licens 2.0.
;;;; 
globals
[ mx my
]

to startup setup end

to setup
   ca
   cct 1000
   [ setxy random 100 random 100
     set shape "circle"
   ]
end

to go
every ( 1 / 30 ) [
   ifelse mouse-inside?
   [ set mx (mx + mouse-xcor) * .5
     set my (my + mouse-ycor) * .5
   ]
   [ set mx mx * .9
     set my my * .9
   ]
   ask turtles
   [ rt -10 + random-float 20
     jump .1 * size
     let dist distancexy mx my  
     let alter (dist ) / (screen-edge-x * .75)
     ifelse alter < .5
     [ set size 1 + 5 * (cos (180 * alter)) 
     ]
     [ if size != 1
       [ set size 1 ]
     ]
   ]
]   
end
   

                    


Download Link

View or download the complete model file (to download: right-click, save-link-as):
-- Download mouse-bubbles_1.1 --