Event handlers respond to inputs (mouse, keyboard) or program changes such as execution of a method.
The following are Event Handlers available in Alice:
World Events:
When the World Starts
While the World Is Running
Keyboard Events:
When a Key is Typed
While a Key is Pressed
Let the Arrow Keys Move an Object
Mouse Events:
When the Mouse is Clicked on Something
While the Mouse is Pressed on Something
Let the Mouse Move the Camera
Let the Mouse Orient the Camera
Let the Mouse Move Objects
Condition Events:
When a variable changes
While something is true
When something becomes true
Monday, March 22, 2010
Thursday, March 4, 2010
Lesson 11 - Repetition
A While Statement is based a Boolean (true/false) condition and repeatedly executes it's containing statements as long as the condition is true. An Infinite loop is a loop that never becomes false.
Assignment:
Using the provided file crash.a2w; modify it so that when the trucks get to close to each other, the condition becomes false and the loop terminates. (Hint: Use a "proximity" function to specify that the front wheels of each truck are at least .5 meters away from each other.) Also, add the following actions.
1. Make a crash sound when they "appear" to collide.
2. Make the front right wheel of the Cement truck roll down the street after the collision.
Print the code and turn in to your teacher.
-------------------------------------------------------------------------------------------------
The Loop Statement allows coders to control the number of loop executions.
Assignment:
Open studentspeedingcar.a2w; Modify the Speedingcar world so that it calculates the total distance the car travels during its trip to the rest stop. Print the result (in the play output) when the car comes to a stop.
Speeding Car II
Modify SpeedingCar so that it displays the distance the car has traveled while it is moving. Continuously display the result on a 3D text object that stays visible in the upper portion of the disply window.
Horse Assignment:
Create an Alice world in which a horse (or other animal of your choice) is relaxing in a field. Define 5 different basic actions for the horse (sway it's tail, dip it's head, whinny, etc.) Use a loop to constantly keep the horse active, randomly choosing the next action. Add pauses of random duration between actions as well.
Assignment:Using the provided file crash.a2w; modify it so that when the trucks get to close to each other, the condition becomes false and the loop terminates. (Hint: Use a "proximity" function to specify that the front wheels of each truck are at least .5 meters away from each other.) Also, add the following actions.
1. Make a crash sound when they "appear" to collide.
2. Make the front right wheel of the Cement truck roll down the street after the collision.
Print the code and turn in to your teacher.
-------------------------------------------------------------------------------------------------
The Loop Statement allows coders to control the number of loop executions.
Assignment:Open studentspeedingcar.a2w; Modify the Speedingcar world so that it calculates the total distance the car travels during its trip to the rest stop. Print the result (in the play output) when the car comes to a stop.
Speeding Car II
Modify SpeedingCar so that it displays the distance the car has traveled while it is moving. Continuously display the result on a 3D text object that stays visible in the upper portion of the disply window.
Horse Assignment:
Create an Alice world in which a horse (or other animal of your choice) is relaxing in a field. Define 5 different basic actions for the horse (sway it's tail, dip it's head, whinny, etc.) Use a loop to constantly keep the horse active, randomly choosing the next action. Add pauses of random duration between actions as well.
Tuesday, March 2, 2010
Lesson 10 - Decisions
Using If/Else & While statements are an integral part of programming and learning logic.
"Control statements allow us to control the flow of our program's logic. Control statements make decisions based on the result of a condition. The condition produces a Boolean (true or false) result, which determines which statements are executed next." (Lewis & Depasquale, 42)

Lab:
Using Intersection3.a2w, obtained from the x:\4B folder; make the following changes:
1. Modify the decision statement to ensure that:
The Bike turns right 20% of the time.
The Bike turns left 40% of the time.
The Bike goes straight 40% of the time.
2. Ensure that there is a 60% chance that the bell will play when the biker turns left.
"Control statements allow us to control the flow of our program's logic. Control statements make decisions based on the result of a condition. The condition produces a Boolean (true or false) result, which determines which statements are executed next." (Lewis & Depasquale, 42)

Lab:
Using Intersection3.a2w, obtained from the x:\4B folder; make the following changes:
1. Modify the decision statement to ensure that:
The Bike turns right 20% of the time.
The Bike turns left 40% of the time.
The Bike goes straight 40% of the time.
2. Ensure that there is a 60% chance that the bell will play when the biker turns left.
Subscribe to:
Comments (Atom)