Mouse Drag One Example
Model was written in NetLogo 5.0.4
•
Viewed 482 times
•
Downloaded 81 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
This is a code sample illustrating how to let the user drag turtles around with the mouse.
NETLOGO FEATURES
The code also demonstrates the use of the watch
, subject
, and reset-perspective
primitives.
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
to setup clear-all ask n-of 30 patches [ sprout 1 ] end to go if mouse-down? [ let candidate min-one-of turtles [distancexy mouse-xcor mouse-ycor] if [distancexy mouse-xcor mouse-ycor] of candidate < 1 [ ;; The WATCH primitive puts a "halo" around the watched turtle. watch candidate while [mouse-down?] [ ;; If we don't force the view to update, the user won't ;; be able to see the turtle moving around. display ;; The SUBJECT primitive reports the turtle being watched. ask subject [ setxy mouse-xcor mouse-ycor ] ] ;; Undoes the effects of WATCH. Can be abbreviated RP. reset-perspective ] ] end ; Public Domain: ; To the extent possible under law, Uri Wilensky has waived all ; copyright and related or neighboring rights to this model.
There are 10 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Mouse Drag One Example.png | preview | Preview for 'Mouse Drag One Example' | over 12 years ago, by Uri Wilensky | Download |
This model does not have any ancestors.
This model does not have any descendants.