Aviod the falling Ball!
Model was written in NetLogo 6.2.1
•
Viewed 126 times
•
Downloaded 6 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
; 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 over 2 years ago by Nathaniel Ciu.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Aviod the falling Ball!.png | preview | Preview for 'Aviod the falling Ball!' | over 2 years ago, by Nathaniel Ciu | Download |
This model does not have any ancestors.
This model does not have any descendants.