Restricting Events Creating Conditional Events in Alice By Henry Qin

Slides:



Advertisements
Similar presentations
Visual Lists By Chris Brown under Prof. Susan Rodger Duke University July 2012.
Advertisements

Events in Alice By Henry Qin, edited by Jenna Hayes under the direction of Professor Susan Rodger Duke University, August 2008.
Alice Learning to program: Part Four Creating Sounds, Making Billboards, Fun with 3-D Text, New Events, and Rotating Objects by Ruthie Tucker and Jenna.
Coloring Randomly: Random Selection in Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008.
Using Functions in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University July 2008.
Lights Camera Action! Part 3: BDE Events By Deborah Nelson under the direction of Professor Susan Rodger Duke University July 2008.
Class-Level Variables in Alice By Jenna Hayes Under the direction of Professor Rodger Duke University, July 2008.
Wizard Game: Class-Level Variables in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July
Calvin and Hobbes Teach Properties and Functions Created by Daniel MacDonald under the direction of Professor Susan Rodger Duke University June 2013.
Creating Functions Deborah Nelson Duke University Professor Susan Rodger July 22, 2008.
Shorter of two objects and changing color Functions, events and setting the color Susan Rodger, Duke University June 2008.
Animated Charting Using the Alice Bar Chart Template World By Elizabeth Liang under the direction of Professor Susan Rodger Duke University December 2010.
Checking for Collisions Ellen Yuan Under the direction of Professor Susan Rodger at Duke University June 2014.
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
Making a Boat Racing Game in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2010.
Shorter of two objects and changing color V2 Functions, events and setting the color in sequence and randomly This is a modification of the Changing Color.
Alice Learning to program: Part Three Camera Control, Invisibility, and 3-D Text By Ruthie Tucker and Jenna Hayes, Under the direction of Professor Rodger.
Introduction to Arrays. definitions and things to consider… This presentation is designed to give a simple demonstration of array and object visualizations.
Checking for Collisions: Alternative Method Erin Taylor Under the Direction of Susan Rodger July 2015 Duke University.
Changing Color, Using Text Objects, and Random Selection in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
Teaching a character to walk in more than one world: Parameters and Inheritance. By Lana Dyck under the direction of Professor Susan Rodger Duke University.
Animating Objects in Groups: Using Arrays and Lists By Ruthie Tucker under the direction of Professor Susan Rodger Summer 2008.
By Melissa Dalis Professor Susan Rodger Duke University June 2011 Multiplication Table.
A Simple Quiz: Ask User Functions. By Lana Dyck under the direction of Professor Susan Rodger Duke University June 2009, added Part 2 July 2011.
An Introduction to Alice (Short Version) – Extras! Yossra Hamid Under the Supervision of Professor Susan Rodger Duke University, June 2014 This is a continuation.
Making a Timer in Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University July
Piñata Game: Keeping Score in Alice By Maggie Bashford Professor Susan Rodger Duke University July
1 ball, 2 ball, red ball, blue ball By Melissa Dalis Professor Susan Rodger Duke University June 2011.
Buttons and Birds: Introduction to Interactive Events in Alice By Henry Qin, edited by Jenna Hayes under the direction of Professor Susan Rodger Duke University,
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops Susan Rodger Duke University July 2011.
Can I get your number? By Melissa Dalis Professor Susan Rodger Duke University June 2011.
Making Billboards By Deborah Nelson Duke University, Under the direction of Professor Susan Rodger, July 14, 2008.
1 Quiz Template: Using the ‘ask user’ functions By Deborah Nelson Duke University Under the direction of Professor Susan Rodger July 2009.
Balancing the scales: Inequalities By Melissa Dalis Professor Susan Rodger Duke University June 2011.
Skater World: Part Four By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 1, 2009.
BDE tutorial By Deborah Nelson Duke University Under the direction of Professor Susan Rodger July 13, 2008.
Illuminating Computer Science CCIT 4-6Sep
Making Billboards By Deborah Nelson Duke University, Under the direction of Professor Susan Rodger, July 14, 2008.
By Melissa Dalis Professor Susan Rodger Duke University June 2011
The Essentials of Alice (Bunny)
Class-Level Variables in Alice
A Simple Quiz for Alice 3.2:
Alice Learning to program: Part Three Camera Control, Invisibility, and 3-D Text By Ruthie Tucker and Jenna Hayes, Under the direction of Professor Rodger.
An Introduction to Alice (Short Version)
Teaching Characters to Walk: Learning Methods, Part 1
Comparing objects and changing color
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops
Changing Color, Using Text Objects, and Random Selection in Alice
Let's Race! Typing on the Home Row
Vehicles and Conditionals
Skater World: Part Three
Alice Learning to program: Part Three By Ruthie Tucker and Jenna Hayes, Under the direction of Professor Rodger Duke University, 2008.
A Simple Quiz for Alice 3.2:
Objects in Alice: Positioning and Moving Them
Princess & Dragon Part 2: Teaching a Dragon to Fly—Methods & Properties By Elizabeth Liang under the direction of Professor Susan Rodger Duke University.
Checking for Collisions: Using Functions in Alice
Shark vs. TRex: Understanding “AsSeenBy” In Alice By Jenna Hayes
An Introduction to Alice
Using Functions in Alice
Restricting an Event with a Conditional
Princess & Dragon Part 3: A Knight Comes Riding In—Cameras & Events
How Tall Are You? Introducing Functions
Learning to Program: Part 3 Camera Control, Invisibility and 3-D Text
Headshots in Alice Duke University Professor Susan H. Rodger
Professor Susan Rodger
Alice and Daisies: Positioning and Moving Objects in Alice
Using Placeholders to Simplify your Methods: Learning Methods, Part 2
Shark vs. TRex: Understanding “AsSeenBy” In Alice By Jenna Hayes
under the direction of Professor Susan Rodger
Presentation transcript:

Restricting Events Creating Conditional Events in Alice By Henry Qin under the direction of Professor Susan Rodger Duke University July 2008

Step 1: Testing the World Download the Alice World that goes along with this tutorial. The world contains the beginnings of a game in which you have to find a chicken’s invisible chick, click on it, and then press enter to go to the next task. Play the world and follow the instructions. Once you have found the chick and he has appeared, press enter. This is how the game should work. The problem is, if you press enter before finding the chick, it will go to the second task anyway. Play the world again and press enter without even trying to find the chick. Your camera will go to the next task, even though the first task has not finished. This tutorial will teach you how to fix this problem, and make your chicken game work like a real game, so that you can’t move on until you’ve finished the first task.

Step 2: Creating a Boolean Variable First we need to create a boolean (true or false statement) variable that will be true if the first task is finished, and false if it is not. Click on world in the object tree and then go to the properties pane and click on create new variable. When the variable box pops up, name your variable taskOneCompleted. Make sure you have selected Boolean, and set your variable to false, because the variable should not be true until the first task is completed. Click OK when you’re done.

Step 3: Setting the Variable Now, we need to include code somewhere that changes taskOneCompleted to true when the chick is clicked on. For this, we want to look at the foundChick method, because as you can see in your events editor, this method runs when the chick is clicked on. Go to the world’s methods pane and click on edit next to foundChick. Go back to the properties pane and find taskOneCompleted. Drag and drop it to the bottom of your foundChick method. Select true. Now taskOneCompleted will be set to true when the chick is clicked on.

Step 4: Using the Variable Now we need to use the information that the boolean variable tells us; we need a method that tells Alice to only go to the second task if taskOneCompleted is true. We will create a new method for this. Go back to the methods pane, and click on create new method. Name it reactToEnter. First, drag an If Else statement into reactToEnter and set it to true.

Step 5: Building the Method Now go back to the world properties pane and find the taskOneCompleted variable. Drag and drop it over where your If Else statement says true. Go to the world methods pane and find the nextTask computer. Drag and drop it into your If Else statement.

Step 6: Editing the Event Now when we hit Enter instead of doing nextTask, we want Alice to do reactToEnter. Drag and drop reactToEnter from the methods pane to where it says nextTask onto the Enter event. Now play the world, and try to press Enter without first clicking on the invisible chick. Nothing happens! Only after you have found the chick will you be able to continue.

Conclusion You can use this tutorial to create other events that are restricted. The trick is to create a new variable and then a control method with an if/else that will only let the right method play if the conditions in the if are met. You can use the variables to keep track of which tasks have been completed by setting them to true from false after a task is complete. Enjoy creating games in Alice!