Dana Vrajitoru
B583/C490 Game Programming and Design

B583/C490 Homework 1

Due Date: Thursday, September 4, 2013.

Here is an example (http://www.cs.iusb.edu/~danav/teach/b583/hangmanYl.swf) of what the completed homework should be like.

Ex. 1. Complete Lab1.

Ex. 2. Continue the same program by adding the following features:

a. Create something special with the graphics for the case where the player loses. Two suggestions for this:

Either of these two methods is acceptable.

b. Add functionaly to restart the game after winning or losing. For this, you'll have to write a function called replayGame without parameters where all the values that need to be reset are taken care of, including the manipulation of the stick figure. Then you'll have to add a button with the caption Replay and attach an event to it that calls this function.

You can test the function replayGame by calling it in the function playLetter when the number of misses is 7 or the number of characters left to guess is 0. That way when the player enters anything after winning or losing, the game is restarted. You can keep this feature even after you add the button.

You'll find a button in the Components (third tool up in the little bar between the Stage and the Properties), then User Interface. Simply drag one to the stage. Adjust the size and position it where you want. Then in the Properties area you'll see a list of properties specific to this object, one of them being the Label. Change that to Replay. At the top of the Properties area, give this button the instance name replayBtn.

In the code at the top, import the module flash.events.MouseEvent. Then add the following function:

function clickReplay(event_object:MouseEvent) 
{
    replayGame();
}

Finally, add the following line next to the place where you added the event handler for the input text box:

replayBtn.addEventListener(MouseEvent.CLICK, clickReplay);

Turn in: the source file .fla and the compiled version .swf. Upload the files to Assignments - Homework 1 in Oncourse.