Star Logo TNG 101 Treasure Hunt Game Unit

  • Slides: 13
Download presentation
Star. Logo. TNG 101 Treasure Hunt Game Unit Lesson 7: Coordinate System

Star. Logo. TNG 101 Treasure Hunt Game Unit Lesson 7: Coordinate System

Today’s Agenda • Review • Mini-lesson on coordinate system in SLTNG and new programming

Today’s Agenda • Review • Mini-lesson on coordinate system in SLTNG and new programming blocks • Programming activity • Wrap-up

Review • Program the moving enemy agents to compete with the player agent to

Review • Program the moving enemy agents to compete with the player agent to “collect” treasure. • Also, whenever a moving enemy collides with a treasure, the enemy “leaves a mark” by stomping a crater that’s colored yellow. • If a player walks into a yellow crater, the score goes to 0.

Coordinate System • Spaceland uses an x and y coordinate system. • (0, 0)

Coordinate System • Spaceland uses an x and y coordinate system. • (0, 0) is located in the center of the green square. • The green square is X = -50 approximately 100 by 100. • Thus, the range of x and y coordinates is -50 to +50. y = +50 X = +50 y = -50

New blocks: set x, set y, set xy • Found in the Movement drawer

New blocks: set x, set y, set xy • Found in the Movement drawer • Take number arguments • xcor and ycor are variables that keep track of each agent’s present location

Set x, Set y, Set xy Practice • What do the following two sections

Set x, Set y, Set xy Practice • What do the following two sections of blocks do? • How can you change the setup section above so that the player appears in the bottom right corner?

Set x, Set y, Set xy Practice • Recall: What happened when you collided

Set x, Set y, Set xy Practice • Recall: What happened when you collided with a tree in the obstacles project? How was the “set xy” block used to do this? (click for answer) • Brainstorm other uses of set x, set y, and set xy in your treasure game. (hint: setup, collision)

New blocks: set heading, heading • Found in the “Movement” drawer. • Takes a

New blocks: set heading, heading • Found in the “Movement” drawer. • Takes a number argument. • Heading is a variable that represents the current direction of an agent. 270 degrees • A heading of 0 means that the agent is facing “north, ” which is “up” when one looks down on the green plane from above. • Recall that there are 360 degrees in a circle. See diagram on right for what different values of heading mean. 0 degrees 45 degrees 90 degrees 180 degrees

Set heading Practice • What do the following sections of programming code do? •

Set heading Practice • What do the following sections of programming code do? • How can you use the “set heading” block in your treasure hunt game?

Guided Programming 1 • Open the current version of your treasure game. Save next

Guided Programming 1 • Open the current version of your treasure game. Save next version. • Use “set xy” and “set heading” in the setup block to place your player agent in a certain location facing a certain direction at the start of the game. • You may need the Create [player agent] Do block.

Guided Programming 2 • Implement new game features by programming interactions between the terrain

Guided Programming 2 • Implement new game features by programming interactions between the terrain and agents. • Example #1: – Trigger: If the player agent steps on a blue patch, – Response: the player’s size is set to 2 and the player stamps the patch back to green. • Example #2: – Trigger: If enemy agents steps on a blue patch, – Response: the enemy agents change direction (heading is randomly set). • In Setup, use Scatter PC block to randomly set the patch color of 1/100 of Spaceland to blue.

Programming Activity • Choose a trigger and response from the class brainstorm list or

Programming Activity • Choose a trigger and response from the class brainstorm list or make one up of your own. • Write it down on your activity sheet in this form: If…(trigger) then…(response). • Implement your idea. • TIP: Implement the idea one small step at a time, testing each step to make sure it works before going on to the next step.

Wrap Up • • Describe your “trigger and response” feature. What collision results did

Wrap Up • • Describe your “trigger and response” feature. What collision results did you try? What worked? What didn’t work? What challenges did you have? What was fun? What questions do you have? What new game ideas do you have?