Animated Programming
Alice animated programming. MUST HAVE AND USE ALICE 3 IDE!
Alice Programming Assignment
Program Requirements
This Alice program will contain 2 scenes. In the first scene, two people will spin multiple times. In the second scene, two people will move towards one another, until one collides with the other and says “Excuse me”.
Create an Alice program that minimally does the following:
Setting the Scene
Start with a blank slate.
Add two person objects to the scene, on opposite sides of the screen (i.e. one on the left side of the screen and one on the right side of the screen).
Position the objects so that they are at the same Z-axis position within the scene.
Creating Methods
Add two scene methods.
Add a shot method called collide.
Within the person class, add a procedure method, which causes a person to spin.
Coding the Actions
Add code to the spin method to make the person:
Simultaneously reposition their arms in the air (can just lift both arms out straight to each side, or do something fancier).
Rotate once around (360 degrees).
Bring both arms down (back to the starting position, at their sides).
Add code to the first scene method to:
Prompt the user to enter how many times the people should spin.
In a while loop, validate the number of times entered:
o If the number of times entered is less than 1
§ Have one of the people say that they have to spin at least once
§ Read another value from the user
Loop until a valid value is entered (1 or more).
In a count loop:
o Invoke the spin method to make both people spin the specified number of times, at the same time.
Add code to the collide method to:
Take 2 parameters, distance1 and distance2.
o distance1 defines the amount that the first person will move each time.
o distance2 defines the amount that the second person will move each time.
Loop until one person collides with the other, as follows: In a while loop:
o Move the first person distance1 towards the second person
o Check to see if the first person collided with the second person.
o If so:
§ Have that person say something like “Excuse me”
§ Back that person up by distance1
§ Set some value that will cause the loop to exit
o Otherwise:
§ Move the second person distance2 towards the first person.
§ Check to see if the second person collided with the first person.
§ If so:
Have that person say something like “Excuse me”
Back that person up by distance2
Set some value that will cause the loop to exit
Add code to the second scene method to:
Turn the people so that they face each other.
Calculate and store the distance between the two people.
Have one of the people say how much distance is between them.
Create a variable called moveDistance1 to hold the distance the first person will move each time, and set it to be one fifth of the distance between them.
Have the first person say how far s/he will move, and state that the second person must move a smaller distance than s/he will.
Create a variable called moveDistance2 to hold the distance the second person will move each time. Prompt the user to enter this distance and store it in the moveDistance2 variable.
Within a while loop,
o Test to see whether the value the user entered for moveDistance2 is invalid (i.e. not less than the value of moveDistance1)
o If the value entered is invalid, have the second person say something about the amount being incorrect, before prompting for and reading another value.
Loop until a valid value is entered for moveDistance2.
Invoke the collision method to move the people until they collide, passing in the two moveDistance variable values as arguments.
Make sure the duration of each movement in your animation is long enough to view comfortably. Run, test, and debug your Alice program, until it works correctly.
Add-on assignment
Additionally you may add one or more methods that will cause the objects to perform some other behavior more than once.
NOTE: The new behavior cannot be a behavior implemented by any of the course materials.
The method(s) should be invoked from an additional extraCreditScene method.
Warning: Do not attempt to implement the add-on assignment until you have first successfully implemented the normal part of the assignment. You will not receive any credit if the normal part of the assignment is not functioning properly. Be sure to save a copy of the normal part of the assignment, in case your efforts on the extra credit are unsuccessful.
Before submitting your program file, you MUST re-name it as follows:
Lastname-aliceAssn5.a3p
For example: Smith-aliceAssn5.a3p
11 years ago 20