StarLogoTNG 101 Treasure Hunt Game Unit Lesson 9: Variables.

Slides:



Advertisements
Similar presentations
Introduction to Macromedia Director 8.5 – Lingo
Advertisements

Summer Computing Workshop. Introduction to Variables Variables are used in every aspect of programming. They are used to store data the programmer needs.
Congratulations! You have just installed the Presentation Game Add-In.
New Mexico User Test Starlogo TNG September 16, 2006 Starlogo TNG September 16, 2006.
 Variables  What are they?  Declaring and initializing variables  Common uses for variables  Variables you get “for free” in Processing ▪ Aka: Built-in.
Events Chapter 7. Interactivity The real world is interactive User determines order of actions instead of programmer.
While Loops. Challenge: ● Ask the user a simple math questions ● Continue asking the question until the user gets it right.
StarLogoTNG 101 Treasure Hunt Game Unit Lesson 4: Forever and Procedures.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
StarLogoTNG 101 Treasure Hunt Game Unit Lesson 6: Terrain.
Mrs. Chapman. Tabs (Block Categories) Commands Available to use Script Area where you type your code Sprite Stage All sprites in this project.
CIS101 Introduction to Computing Week 11. Agenda Your questions Copy and Paste Assignment Practice Test JavaScript: Functions and Selection Lesson 06,
CIS101 Introduction to Computing Week 12 Spring 2004.
INTRODUCTION TO SCRATCH. About Me Resources Scratch Website Learn Scratch Washington-Lee Computer.
Mr. Wortzman. Tabs (Block Categories) Available Blocks Script Area Sprite Stage All sprites in this project.
StarLogoTNG Treasure Hunt Game Unit Lesson 1: Basic Movement.
Android Apps: Building Blocks Module 6, Intro to I.T., Fall 2011 Sam Scott.
Fell View Computer Club StarLogo TNG – Session Two.
Fish Chomp. The screen where you can see what happens when you play your game is called the STAGE. The SCRIPT BANK is where the types of instructions.
CSCI 101 Introduction to Software Development and Design.
Modeling and Simulation Module 1: Lesson 1
Variables and Functions Chapter Variables Named storage location in computer’s memory Programs may need to store data when running o Stored in.
MrsBillinghurst. net A2 Computing A2 Computing Projects Game Animation in Pascal.
Creative Commons Attribution 3.0 creativecommons.org/licenses/by/3.0 Key Abstractions in Game Maker Foundations of Interactive Game Design Prof. Jim Whitehead.
This will let you see the game you are going to play on the inside. It will help you see what all goes into creating instance to that goes into setting.
by Chris Brown under Prof. Susan Rodger Duke University June 2012
StarLogoTNG 101 Treasure Hunt Game Unit Lesson 3: Treasures and Hazards.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
MAT Meyer Week 2 Programming VB: ‘basics’ Review & preview: Events, variables, statements, etc. Images, Control arrays, For/Next Assignment: read.
KeyListener and Keyboard Events Another type of listener listens for keyboard entry – the KeyListener which generates KeyEvents –to implement KeyListener,
CPS120 Introduction to Computer Science Iteration (Looping)
StarLogoTNG 101 Treasure Hunt Game Unit Lesson 2: Keyboard Controls.
 Agenda 2/20/13 o Review quiz, answer questions o Review database design exercises from 2/13 o Create relationships through “Lookup tables” o Discuss.
PHP Conditional Statements Conditional statements in PHP are used to perform different actions based on different conditions. Conditional Statements Very.
Scratch Programming Lesson 4 Question asking and answering.
StarLogoTNG Treasure Hunt Game Unit Lesson 1: Basic Movement.
Java server pages. A JSP file basically contains HTML, but with embedded JSP tags with snippets of Java code inside them. A JSP file basically contains.
Visual Basic Games: Week 4 Recap Parallel structures Initialization Prepare for Memory Scoring Shuffling Homework: when ready, move on to next game/chapter.
Game Maker – Getting Started What is Game Maker?.
11 Getting Player Input Using a Gamepad Session 3.1.
StarLogoTNG 101 Treasure Hunt Game Unit Lesson 7: Coordinate System.
Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008.
CHAPTER 2 The Game Loop - Variables, Types, Classes and Objects in XNA XNA Game Studio 4.0.
Controlling Program Flow with Decision Structures.
StarLogoTNG 101 Treasure Hunt Game Unit Lesson 8: Hatch.
StarLogoTNG 101 Treasure Hunt Game Unit Wrap Up. Today’s Agenda Review Mini-lesson and programming practice on set camera and ID Finish making the treasure.
M1G Introduction to Programming 2 2. Creating Classes: Game and Player.
Lives and Scoring Games Programming in Scratch. Games Programming in Scratch L2 Lives and Scoring Learning Objectives Define a variable Understand the.
The Stingray Example Program CMT3311. Stingray - an example 2D game May be useful as a simple case study Most 2D games need to solve generic problems.
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
Scratch Programming Cards
Unit 2 Technology Systems
Create a Halloween Computer Game in Scratch
Broadcasting (Adding a new level)
Games Programming in Scratch
Welcome to Computer Science Jeopardy
Lesson 10: Building an App: Color Sleuth
Chapter 16 – Programming your App’s Memory
Learning Objective LO: We’re learning to understand when it is appropriate to use particular data types.
Lesson 2: Building Blocks of Programming
Lesson 8: Boolean Expressions and "if" Statements
Visual Basic Programming Chapter Four Notes Working with Variables, Constants, Data Types, and Expressions GROUPBOX CONTROL The _____________________________________.
HAPPY NEW YEAR! Lesson 7: If-statements unplugged
Game Loop Update & Draw.
ICT Gaming Lesson 3.
Game Over Module 4 Lesson 2.
creating a ecosystems model in net logo
Web Programming and Design
Presentation transcript:

StarLogoTNG 101 Treasure Hunt Game Unit Lesson 9: Variables

Today’s Agenda Review Mini-lesson on variables and new blocks Implement new game features Wrap-up

Review Whenever a moving enemy agent collides with a hazard, program the enemy to “hatch” a half size version of itself and have the child enemy head in a different direction from the parent. The hazard dies. Whenever the moving enemy collides with a treasure, if the moving enemy is smaller than 1, it increases its size back to 1. The treasure dies. Whenever the moving enemy collides with itself, program the enemy to “hatch” a new treasure. Challenge: How can you use “random” so that the enemy only has a 50% chance of hatching a new treasure?

Variables What is a variable? (hint: what are some examples from math or science classes?) A variable in programming is like a container that holds a value that can change. The value can be a number, a boolean (true or false), or a string (characters like a word or phrase). Hello 258 TrueFalse Bye

Variables You’ve already used some variables such as score, xcor, and color. What are some other examples of already defined variables in StarLogo TNG? Look in the Traits drawer. What type of variables are pen down?, pen up? and alive? How can you tell?

Agent monitor window If you click once on any agent in Spaceland, you bring up its monitor. Here you’ll see the current values of its already defined variables. You can even change the values and immediately see the effect on that particular agent.

Variables You define (or create a container for) a variable using the blocks in the Variables drawer. There are two kinds of variables: agent and shared. If you define a shared variable, there is only one variable container for the whole game. If you define an agent variable, every agent of a certain breed gets its own variable container.

Shared vs. Agent Shared variable Agent Variable

Variables: Practice 1 Classify each of the following variables as agent or shared: 1.Size 2.Xcor 3.Score 4.Breed

Variables: Practice 2 How would you define variables for each of these purposes: 1.The number of treasures left in the game 2.The energy content of each bullet. 3.The number of “lives” that the player has 4.The number of bonus “speed boosts” that can be triggered by the player

Setting the value of a variable Set variable block found in My Blocks palette. Shared variable only: Slider – can be adjusted by the user in the Runtime window.

Setting the value of a variable Typically, you want to set the starting value of each variable in the Setup block as a part of resetting the game. For agent variables, you can set the starting value as part of the Create-Do block or the Hatch-Do block. When the game is running, you’ll change the variable as needed by using the set variable block with an expression or constant.

Getting the value of a variable You want to “get” the value of a variable as part of changing its value (see previous set variable example) or to compare it to another number as a way of making a decision. To get the variable, go to the My Blocks palette and look inside the drawer of the canvas section where you declared the variable.

Getting the value of a variable So, in our example with the mana variable, the player collects “mana” and then can use mana to do special things like let the player move faster for a certain period of time.

Monitor Use the monitor block in the Setup and Run drawer to show the value of shared variables.

Guided Programming Open the current version of your “treasure game your initials.sltng” Save next version Define an agent number variable called “energy” in the thrown projectile section of the canvas. When hatching the projectiles, set energy to 100. In the Run (forever) block, in the projectile’s section, decrease the energy variable by 1. When the energy gets down to zero, the projectile dies.

Guided Programming Note the addition of the energy variable in the agent monitor window of a projectile agent.

Brainstorm uses for Variables What other uses for variables can you think of for your game? Here are some ideas: The number of treasures left in the game The energy content of each bullet. The number of “lives” that the player has The number of bonus “speed boosts” that can be triggered by the player Timer to track the “life” of certain agents or events

Programming Activity Implement a new game element that uses at least one variable. Decide on the game element, consider which type of variable is most appropriate, and then follow the steps below. Three basic steps to using a variable: 1.Define the variable 2.Initialize the variable (setup, create, hatch) 3.Use the variable (change it, compare it, etc.)

Wrap Up Describe your new game feature that uses one or more variables. 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?