starlogotng 101 treasure hunt game unit lesson 7: coordinate system

13
StarLogoTNG 101 Treasure Hunt Game Unit Lesson 7: Coordinate System

Upload: antony-reeves

Post on 21-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: StarLogoTNG 101 Treasure Hunt Game Unit Lesson 7: Coordinate System

StarLogoTNG 101

Treasure Hunt Game UnitLesson 7: Coordinate System

Page 2: StarLogoTNG 101 Treasure Hunt Game Unit Lesson 7: Coordinate System

Today’s Agenda

• Review• Mini-lesson on coordinate system in

SLTNG and new programming blocks• Programming activity• Wrap-up

Page 3: StarLogoTNG 101 Treasure Hunt Game Unit Lesson 7: Coordinate System

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.

Page 4: StarLogoTNG 101 Treasure Hunt Game Unit Lesson 7: Coordinate System

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 approximately 100 by 100.

• Thus, the range of x and y coordinates is -50 to +50.

y = +50

y = -50

X = +50X = -50

Page 5: StarLogoTNG 101 Treasure Hunt Game Unit Lesson 7: Coordinate System

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

Page 6: StarLogoTNG 101 Treasure Hunt Game Unit Lesson 7: Coordinate System

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?

Page 7: StarLogoTNG 101 Treasure Hunt Game Unit Lesson 7: Coordinate System

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)

Page 8: StarLogoTNG 101 Treasure Hunt Game Unit Lesson 7: Coordinate System

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.

• 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

90 degrees

180 degrees

270 degrees

45 degrees

Page 9: StarLogoTNG 101 Treasure Hunt Game Unit Lesson 7: Coordinate System

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?

Page 10: StarLogoTNG 101 Treasure Hunt Game Unit Lesson 7: Coordinate System

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.

Page 11: StarLogoTNG 101 Treasure Hunt Game Unit Lesson 7: Coordinate System

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.

Page 12: StarLogoTNG 101 Treasure Hunt Game Unit Lesson 7: Coordinate System

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.

Page 13: StarLogoTNG 101 Treasure Hunt Game Unit Lesson 7: Coordinate System

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?