Asteroids+with+Procedures

Asteroids Game
This game looks very complex but follows simple rules. The main objective is to learn about  blocks.

[[file:Asteroids.sltng]]
Procedures allow programming rules to be made for individual agents or everyone but not be placed in the  sections. A link block is placed in the  section directing you to the procedure found elsewhere in the window. This allows for better organization of programming.

In the  block you have links to procedures for the Fighter-Movement/Firing, Asteroid-Asteroid Motion, and Projectile-Projectile Motion. You also have a procedure in  for Asteroids-Asteroid break down. These procedures are found in the window sections for the agents involved.



You have the movement commands you are familiar with. The last coding section directs to only allow 4 projectiles on the screen at a time and to allow an agent to be hatched. Hatching involved another agent being created. We change the agent being “hatched” from a Fighter to a Projectile using  as well as size and color.
 * There is one procedure for Fighter-Movement/Firing (found in the Fighter Window Section).**



The projectiles move forward at a rate of 5. If the x and y coordinates are less than or equal to -49 or greater than or equal to 49, the projectile will die and disappear off Spaceland. **This is to keep projectiles from bouncing forever off walls.**
 * There is only one procedure for the Projectile.**



The first procedure is the motion of each Asteroid. The second procedure states that if the size of an Asteroid is larger than 3 (when hit by projectile in collisions) then hatch another Asteroid, subtract its size by 2, and have it move in a random direction left from 0-360 degrees. If the size is smaller than 3, the asteroid dies and disappears off of Spaceland (when hit by a projectile). **This is to keep smaller and smaller asteroids from being hatched that are too small to see from destroying your fighter.**
 * There are two procedures for the Asteroids.**




 * Try the game. There is a bug in the Starlogo TNG program. If the game crashes, press the  block first and then the  block repeatedly until the game starts normally.**