Setup
This lab builds on some of the code in Lab 4. You need to have at least completed the AnimatedSprite
implementation to continue onto Lab 5.
Do the following to prepare your Lab05
project:
- Unlike the prior labs, you DO NOT want to copy over all your .h/cpp files from
Lab04
. Instead, only copy over the following files (make sure you copy using Finder or Explorer to copy files, don’t drag-and-drop within Visual Studio/Visual Studio Code as this will not copy properly):- Actor.h/cpp
- AnimatedSprite.h/cpp
- CollisionComponent.h/cpp
- MoveComponent.h/cpp
- Open your repo in Visual Studio or Visual Studio Code as usual
- Now you need to change the build target from “Lab04” to “Lab05.” In Visual Studio (PC) this is via the dropdown near the play button. For Visual Studio Code (Mac), you should change both instances of “Lab04” on the bottom toolbar (one for the build target and the other for the run target)
- In Ghost.cpp, change line 61 to set the starting animation to “up”
Now you should be able to compile and run the game, and see something like this:
You can move Pac-Man with the WASD
keys, but the red ghost (Blinky) will just hang out in the starting spot.
If you don’t see Pac-Man unless Pac-Man moves, it means you need to fix your AnimatedSprite
so that Update
does the wrapping and SetTexture
call even if the animation is paused.
If you don’t see Pac-Man or the ghost at all, you may need to rebuild the game project. To do this, on PC do Build>Rebuild Lab05.exe. On Mac, do Command+Shift+P to bring up the command palette and find “CMake Clean Rebuild.”
If it still doesn’t work (or you’re on Visual Studio Code on Mac), the usual culprits are either something wrong with your AnimatedSprite
or your CollisionComponent
. Make sure you passed the unit tests on the prior assignments.
Now you’re ready for part 1 of the lab.