Aviod the falling Ball!
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
(a general understanding of what the model is trying to show or explain)
HOW IT WORKS
(what rules the agents use to create the overall behavior of the model)
HOW TO USE IT
(how to use the model, including a description of each of the items in the Interface tab)
THINGS TO NOTICE
(suggested things for the user to notice while running the model)
THINGS TO TRY
(suggested things for the user to try to do (move sliders, switches, etc.) with the model)
EXTENDING THE MODEL
(suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.)
NETLOGO FEATURES
(interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features)
RELATED MODELS
(models in the NetLogo Models Library and elsewhere which are of related interest)
CREDITS AND REFERENCES
(a reference to the model's URL on the web if it has one, as well as any other necessary credits, citations, and links)
Comments and Questions
; note that go (forever), setup, move left, and move left are buttons ; time-for-balls-to-spawn , max-population , create-balls num-balls-that-spawn-after-spawn-time , gravity are sliders globals [ population time ] breed [balls ball] breed [persons person] persons-own [ collision ] to setup set population 0 create-persons 1 [ ;creating the controllable turtle set color red set shape "person" set xcor -12 set ycor -9 set size 2 ] ask patches [ ;creating a nice background set pcolor 97 if pxcor <= 16 and pycor < -9 [set pcolor green] ] ask patch 14 14 [ set time 0 set plabel time ] end to check-collision ;used to check if the person gets hit by a ball ;if (distancexy xcor ycor) > # .... ask persons [ if sum [count balls-here] of neighbors > 0 ; if xy distance [set collision 1] ] end to move-right if population <= 20 [ask persons [set xcor xcor + 0.1] ] ifelse population > 20 and population < 40 [ask persons [set xcor xcor + 0.05] ] ;there's different xcor value to try and keep player movement consistant no matter how many things are happening [ask persons [set xcor xcor + 0.01] ] end to move-left if population <= 20 [ask persons [set xcor xcor - 0.1] ] ifelse population > 20 and population < 40 [ask persons [set xcor xcor - 0.05] ] ;there's different xcor value to try and keep player movement consistant no matter how many things are happening [ask persons [set xcor xcor - 0.01] ] end to go every 1 [ ask patch 14 14[ ;the patch serves as a timer, althought it's a very small timer set time time + 1 set plabel time ] ] every 0.1 [ ask persons [ check-collision if collision = 1 [ask balls [die] repeat 3 [ ht wait 0.5 st wait 0.5 ] user-message "Game Over" die ] ] ] if not any? persons [setup stop] every time-for-balls-to-spawn [ if population < max-population ; max-population controls how many balls are on the screen [ create-balls num-balls-that-spawn-after-spawn-time [ set shape "circle" set size 3 set xcor random 100 ;spawns the balls in randomly set ycor 15 set population population + 1 ;keeps track of how many balls on screen ] ] ] every 0.1 [ ask balls [ set ycor ycor - gravity ;how fast the balls fall to the ground ] ] ask balls [ if ycor <= -10 [set population population - 1 ;first tell the balls to - 1 of population cause they are going to die... and then they die | doesn't work other way round die ] ] end
There is only one version of this model, created about 3 years ago by Nathaniel Ciu.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Aviod the falling Ball!.png | preview | Preview for 'Aviod the falling Ball!' | about 3 years ago, by Nathaniel Ciu | Download |
This model does not have any ancestors.
This model does not have any descendants.