Lecture:: 01-07-2013

posted Jan 7, 2013, 6:17 AM by Samuel Konstantinovich   [ updated Jan 8, 2013, 10:31 AM ]
Ack Monsters! Activity (for this activity, sliders will be denoted with the bold and underscores e.g. num_people

You will learn to make breeds behave in different ways depending on their state. Like with a corpse person vs a tired person.


There are two breeds: monsters and towers.

Setup:

Create num_towers towers, and num_monsters monsters.
The towers should be white, and "house" shaped. 
The monsters should be gray, and you can import a "monster" shape from the turtle shape editor. 
All turtles should be size 2 and placed randomly on the world. 

Every time the program runs go:
Tower behavior: all towers rotate by rotate_speed degrees, and project a cone of light (yellow patches) This cone is tower_angle degrees wide, and tower_radius long.  

Monster behavior:
Monsters on a yellow patch turn "scared" 
Monsters on a black patch turn "angry"
#UPDATE FOR IMPROVED AI HERE#
You may want a variable to keep track of the state. Only monsters need this variable.
*Optionally make the monsters have different shapes for angry and scared states.*

Angry monsters:
 Fade* to color 2.
 Wiggle at a speed of .3 and random angle of 30. This makes the monster travel across the screen like a normal wiggle. 

Scared monsters:
  Fade* to color 8.
  Wiggle at a speed of .1 and random angle of 360. This makes the monster wiggle in place like they are scared. 

*:When I say fade that means the monster changes its color by 0.25 towards that color every time so that the color changes slowly.


Comments