In this lab you will create a touch-screen version of the Whack A Mole game. In the arcade game, moles pop out of holes and your job is to “whack” them by hitting them before they go back into their hole. In our version of the game, the moles are drawn on a screen. When they appear, you touch them with your finger to “whack” them. Perhaps we should rename the game “Pet the Mole”.
You will need to support three different configurations of the game: 9 moles, 6 moles, and 4 moles. The user chooses the configuration by sliding the switches appropriately. Watch the videos in the Videos Section to view the three different board configurations.
As was done with prior labs, the Whack a Mole game is conceptually organized and developed in two parts: display (wamDisplay) and control (wamControl). wam is an abbreviation for Whack A Mole and it helps shorten file-names, function-names, variable-names, etc.
free()to implement dynamically-sized arrays.
The organization of the game is similar to past labs where the display code is separated from the control code. However, in this lab, the display code will be significantly smarter than in past labs. Responsibilities for the display code include:
The controller is quite simple (my controller only has three states). The responsibilities of the controller include:
Four files are provided:
wamMain.c. Of these all but
wamDisplay.c are complete and should not be modified by you. Some code is found in
wamDisplay.c to get you started using
malloc() to implement a dynamic array and to provide a definition for mole-info records (more on this later). All of these files can be found near the bottom of this lab in the Source Code Section.
Note: Much of the functionality of the various functions is described in the commented code in the provided files. Carefully read these comments as it will save you a lot of time.
This following sections discuss how the wamDisplay and wamControl code are organized. Links to source code are also provided.
wamMain.c. Pushing the slide switches should not interrupt game play.
#definestatements or add include statements as necessary. Otherwise, no modifications of the .h files are allowed. Also complete the
free()to allocate and deallocate memory for the mole-info records when resizing the game.
wamControl_setMsPerTick()function to inform the controller how many ms transpire between each tick. In turn, the wamDisplay software must use
wamControl_getRandomMoleAwakeInterval()to set the tick counts for
ticksUntilDormantvariables in the mole-info record.
The game will be completed in two milestones.
wamDisplay.c. There is a
wamDisplay_runMilestone1_test()function declaration provided for this purpose.
Follow this procedure to submit your source code to learning-suite.