Wakka Wakka

This week we are taking our video game to the next level. The prototype works good. I decided to make a number of noteworthy additions, including sounds. I had used sampled clips before in Java. I even knew the libraries I needed to include.

So Pacman chomps on a pellet. The game is supposed to make this wakka-wakka sound. I got an audio file that has the sound. Just got to play it each time Pacman goes over a pellet. The first time I tried it out I heard nothing. I figured this could not be right. I played sounds before for my last game.

Then I looked at my game loop. For now we are settling for choppy animation until we get all the mechanics down tight. To prevent the game from running too fast, I sleep() for a second each iteration through the game loop. Turns out you cannot play a clip and sleep immediately afterwards. Drat.

When I finally implement the full animations, hopefully the sound will play fully. For now I just moved my sound playing earlier up in my game loop, giving it some time to execute before the thread sleeps. Next up my partner has to add more AI to make the ghosts "smarter". Currently Pacman can outsmart them and leave them lost.