mouse-bubbles_2


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 ticks
]

to startup setup end

to setup
   ca
   ask random-n-of (.75 * count patches) patches
   [ sprout 1
     [ setxy random 100 random 100
       set shape "circle"
     ]
   ]
end

to go
every ( 1 / 30 ) [ 
   no-display
   ;; set ticks ticks + 1
   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 ]
     ]

   ]
   if hidden?-of turtle 0 != hide-all?
   [ ask turtles [ set hidden? hide-all? ]
   ]
   ;; if ticks = 1 [
   ;;  set ticks 0
     ask patches
     [ set pcolor scale-color gray (count turtles in-radius 3) 0 35
     ]
   ;; ]
   display
]   
end
   

                    


Download Link

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