7.4

Week 9 Set b

home work!

Programming Language ISL+

Due Date Thursday 10/31 at 9:00pm (Week 9)

Purpose To further your implementation of Pacman.

Graded Exercises

These Violent Delights Have Violent Ends

Ghosts swarming the screen is all good and fun, but they’re not doing much right now. In this iteration of the game, if a ghost collides with Pacman, then Pacman, tragically, dies.

But not necessarily permanently. To give our favorite yellow glutton a fighting chance, Pacman can have more than one life!

Exercise 1 Like many doctors, DrRacket gets sick sometimes, too. In fact, DrRacket 7.4 has quite a nasty bug affecting big-bang programs. Unlike human doctors, we can cure DrRacket by replacing it with a younger version of itself. Download and use Racket 7.3 for this and future assignments to make Pacman go much faster.

Exercise 2 Incorporate the feedback you received on your last Pacman assignment; make the suggested improvements and fix any bugs that may still exist.

Exercise 3 Update your data definition to incorporate the notion of lives. Fix related functions and tests to work with your new data definition.

Exercise 4 Update your main function to take in another natural number, representing the number of times Pacman can die before the game ends.

Exercise 5 Update your on-tick handler to detect and handle Pacman/ghost collisions. If a ghost collides with Pacman, all of the ghosts should return to their initial positions, and Pacman should return to his and lose a life, without getting to eat any pellet or super dot that may have been at that position (i.e., the position where Pacman and ghost collided). Note that this will likely involve multiple changes to your data definitions, as game pieces need to know where they began.

Warning: the complexity of this handler is about to change significantly. Think through edge cases carefully, and be sure to write tests for them. In particular, collisions can occur if a ghost lands on Pacman, or if a ghost and Pacman "swap places".

Exercise 6 Update your stop-when handler to end the game when Pacman has no more lives. The end screen should also indicate whether or not Pacman was victorious in eating everything before he died.