Space Invaders
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
extensions [ sound ] breed [ players player] breed [ grunt grunts ] breed [ beefys beefy ] breed [ shooters shooter ] breed [ bullets bullet ] bullets-own [ num enemy ] players-own [ enemy ] grunt-own [ enemy ] beefys-own [ enemy ] shooters-own [ enemy ] globals [ cycle xpos ypos score eypos canShoot bypos nume cooldown] to setup clear-all set cycle 0 reset-ticks set score 0 set canShoot 1 ask patch 4 -11 [ set pcolor green ] ask patch 5 -11 [ set pcolor green ] ask patch 4 -10 [ set pcolor green ] ask patch 5 -10 [ set pcolor green ] set-default-shape bullets "dot" create-players 1 [ set shape "default" set heading 0 set size 2 set color green set xcor 10 set ycor -15.5 ] set-default-shape grunt "grunt" create-grunt 11 [ set heading 0 set size 2 set color green set xcor who + who / 2 ] create-grunt 11 [ set heading 0 set size 2 set color green set xcor ( who - 11 ) + ( who - 11 ) / 2 set ycor 1 ] set-default-shape beefys "octopus" create-beefys 11 [ set heading 0 set size 2 set color green set xcor ( who - 22 ) + ( who - 22 ) / 2 set ycor -1 ] create-beefys 11 [ set heading 0 set size 2 set color green set xcor ( who - 33 ) + ( who - 33 ) / 2 set ycor -2 ] set-default-shape shooters "squid" create-shooters 11 [ set heading 0 set size 2 set color green set xcor ( who - 44 ) + ( who - 44 ) / 2 set ycor 2 ] ask grunt [ set enemy 1 ] ask beefys [ set enemy 1 ] ask shooters [ set enemy 1 ] ask players [ set enemy 0 ] ask bullets [ set enemy 0 ] set nume 55 set cooldown 0 end to go ecounter ask bullets [ collide ] if cooldown = 0 [ set canshoot 1 ] ifelse cooldown > 0 [ set cooldown cooldown - 1 ] [ set cooldown 5 ] if eypos < -15 or score = "gameover" [ set score "gameover" ask bullets [ die ] stop ] ask beefys [ set eypos ycor ] ifelse cycle = 0 or cycle = 59 [ down ][ ifelse cycle = 19 or cycle = 39 [ r ][ ifelse cycle = 79 or cycle = 99 [ l ][ ] ] ] ifelse cycle > 119 [ set cycle 0 ][ set cycle cycle + 1 ] ask bullets [ fd 1 if ycor > 15 [ die ] ] tick end to down ask beefys [ set ycor ycor - 1 ] ask grunt [ set ycor ycor - 1 ] ask shooters [ set ycor ycor - 1 ] end to r ask beefys [ set xcor xcor + 1 ] ask grunt [ set xcor xcor + 1 ] ask shooters [ set xcor xcor + 1 ] end to l ask beefys [ set xcor xcor - 1 ] ask grunt [ set xcor xcor - 1 ] ask shooters [ set xcor xcor - 1 ] end to shoot ask players [ set xpos xcor set ypos ycor ] ifelse score != "gameover" [ create-bullets 1 [ set color white set heading 0 set xcor xpos set ycor ypos + .75 ] go ][ ask bullets [die] stop ] end to collide set bypos ycor set num nume ask turtles-here with [ enemy = 1 and bypos >= eypos ] [ die ] ecounter if num > nume [ die] end to ecounter set nume count beefys + count shooters + count grunt end
There is only one version of this model, created 7 months ago by Ryken White.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Space Invaders.png | preview | Preview for 'Space Invaders' | 7 months ago, by Ryken White | Download |