## CompSci 94 Fall 2013: Assignment #6

Due: Tuesday, Nov 5 - 11:59pm

15 points

This is individual work. You may talk to other students in the course about your design and for ideas, but you are to write the complete Alice program by yourself. You may receive help from the Professor, UTA's or TA.

## The Warmup - Putting heads on bodies

See the tutorial called "Headshots in Alice " on the assignment page, which shows you how to replace the head on a 3D body in Alice with a picture of a head. You should look over this tutorial (it is not to turn in). For the problem below you will need to build such a person.

## The Problem: Matching Code Game

### The Startup:

You start with three Brooms (Kitchen folder) enlarged several times, stuck in the ground with just the top part sticking up so they look like poles. Best to display them in order from left to right: broom, broom2 then broom3. (Note: Make sure you add three brooms one at a time. DO NOT put one broom in and make a copy of it. Copied objects share items and may confuse you and your program.) Then put a basketball (Sports folder) centered on each pole at the bottom as in the picture. In the program, the basketball will move up and down the pole to either the top of the pole or the bottom of the pole.

For each pole start with the basketball at the bottom of the pole, or "all the way down". The start is as shown below (except the beach balls should be invisible. See the note about their possible role below).

### The Game

A three-word code is where each word is either the word "up" or "down". These words are to represent the position of the basketballs on the poles for the solution. You will randomly generate the three words (using random). This code is not shown in the game. For the moment, assume the code is "down down up".

Each basketball is associated to be either up (on top of the pole) or down (at the bottom of the pole). If you click on a pole, its corresponding basketball position should change. If the basketball is up when you click on the pole, then the basketball should move all the way down to the bottom of the pole. If the basketball is down when you click on a pole, its basketball is changed to be all the way up on the pole. For example, in the figure above, the game started with all the basketballs at the bottom of the poles (in the "down" position), then the result below is after one click: the third pole is clicked once (basketball3 moves up), and then it matches the code of "down down up".

The game works as follows. You generate a three word code not equal to "down down down" (otherwise you would win right away) and not display the code. Then you click on the poles until their position matches the random code. A counter keeps track of how many times you have to click. The game ends when the basketballs on the poles match the three word random code. When the game ends the solution code should be displayed and something spectacular should happen to let you know the game is over.

Hint: To figure out if the basketball is up or down on its pole, one way to do this is to put an invisible object in the middle of the pole and ask the question if the basketball is above the object or not. In the first figure I have put beachballs in the middle of the pole. They are not invisible so you can see them, but should be made invisible when the game is played as shown in the second figure.

Make sure that your balls (both basketballs and beachballs) have the correct orientation, meaning if you tell them to go up, they go up towards the sky (and NOT to the right or down...).

Hint2: You probably want to use three code words. You may want to check something like "If basketball1 is in the up position and the code1 is up, then basketball1 matches its corresponding word code."

## Requirements:

1. You must use three brooms (resized larger) as poles and three basketballs to move up and down the poles. When the user clicks on a pole, the basketball on that pole should move to the new position.

2. You should have instructions telling the user how to play the game and how they can win.

3. You must have an event that can display the answer (the random three word code). The answer should appear for 4 seconds and then disappear. This will be helpful to you to see if your game is working correctly. In the figure below the solution is shown (and matches the positions of the basketballs).

4. You must have one counter that shows how many times the user has clicked on the poles. This counter must be displayed as 3D text. (In the example, this counter is shown in the top right corner).

5. Have a start message when the user can start the game. You need to make sure that all the setup has been completed before the user starts. For example, your random code words must be generated.

6. When the game is over (the random code has been matched) the user wins if the counter is less than 5. If the user wins, then something spectacular should happen including a text message and a well known person. For the well known person, you should find a picture of their face on the web, cut out the face, make a billboard out of it and attach it to the head of a 3D person in Alice (whose head you make invisible). For example, in the figure above, I have Coach K (his head is attached to the Coach head and the coach head is invisible) jumping in the air waving his arms and legs and a 3D text message displayed (You won!) indicating you have found the solution. You may do something else in addition as an attention getter, but must also display a text message and a well-known person constructed in the manner above.

You must also indicate if the user lost (clicked five or more times). In this case, just a losing message is fine.

7. The presentation must be nice. 20% of the grade is on presentation and style. This also includes comments, comment your code!

### Submission

Implement your design and create an Alice world. Be sure your animation has all the requirements listed above. Be sure to include comments in your code.

This part will be turned in two ways.

1. Turn in your Alice world on the web submit form. Create a text file called README.txt to include a comment with your name, how long you worked on the assignment and names of anyone you received help from. Turn in both the Alice world and the README file

You could load the two files OR place them in a folder, zip the folder with the two files and turn in the .zip file.

2. Create an html page that has at least two snapshots of your world and a description of what happens in the world. Link to this html page from your CompSci 94 page. We will look for it on your web page.