Winter 2026 CS 32
Programming Assignment 3
Lemmings
Part 1 due 11:00 PM Monday, February 23
Part 2 due 11:00 PM Monday, March 2 Tuesday, March 3
The Project 3 specification document is posted.
Updates
-
2/22 11:00pm: If your program is built with these new versions of
GameController.h,
GameController.cpp, and
GraphObject.h, then at the end of execution,
it will write to cerr information about memory leaks of objects
derived from GraphObject. (It writes nothing if there are no such leaks.)
If you currently have no leaks, you can experiment to see what it reports by
temporarily commenting out a delete expression in a StudentWorld member
function.
-
2/19 11:45pm: If you're running an older version of Xcode (and can't upgrade
because you're runningan older version of macOS), you're probably getting an
error from Xcode complaining about a "future Xcode project file format". Try
downloading this skeleton project for older versions of Xcode.
-
2/19 11:40pm: If building a skeleton project gives you an error about a
"constexpr" in line 106 of Level.h, delete that word "constexpr" on that line.
(That fix was made to the skeletons several days ago.)
2/18 11:50pm: The Xcode skeleton is now available.
-
2/17 11:40pm: A new Windows skeleton and a second method for installing SFML
on Windows is now available. This should solve the problems some were having.
Also, there is now a Windows sample executable; see the last step of the
first Windows method for installing SFML to see how to run it.
To see what the game looks like in action, you'll have to do a little prep
work: In order to build and run Project 3, you'll need to install the SFML
package. (SFML = Simple and Fast Multimedia Library). How you do that
varies by platform.
On a Mac
-
Open a Terminal window.
-
If you haven't already installed the Homebrew package manager, do so by
running the one-line command shown under "Install Homebrew" on the
Homebrew page. That command is
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
-
To install SFML, run the command
brew install sfml
-
Verify that the installation path is
/opt/homebrew/Cellar/sfml or
/usr/local/Cellar/sfml by running the command
brew info sfml
Once SFML is installed, unzip the Mac
sample executable zip file. In that zip file is a file named README.txt
that tells you how to launch the program.
On Windows
-
Launch Visual Studio and open the Developer PowerShell by selecting Tools >
Command Line > Developer PowerShell. Run the command
vcpkg integrate install
This pops up a dialog box wanting your administrator password to integrate
vcpkg with Visual Studio. It's safe to do this and answer yes. If you do,
you'll never have to do this step again. Close the PowerShell window.
-
What you will have to do for any project you create that uses some package
(such as SFML) is tell Visual Studio to use that package for that project.
Download the Windows skeleton
project. When you open the Windows skeleton zip file, make sure you drag the
Lemmings folder in it to your desktop (or somewhere else) and in the folder
there, double-click on the .sln solution file to open the project in Visual
C++. It doesn't work if you try to double-click on the one embedded in the
zip file.
-
With the project open, select Tools > Command Line > Developer PowerShell,
which should open a PowerShell window in your project folder that contains
the .vcxproj file. Run the commands
vcpkg new --application
vcpkg add port sfml
-
In the Solution Explorer tab, right click the boldfaced project name
(Lemmings) and at the bottom of the menu that pops up, select Properties.
-
In the dialog that pops up, for Configurations at the top select All
Configurations from the dropdown. In the left frame under Configuation
Properties, select vcpkg. In the right frame next to Use Vcpkg Manifest,
select Yes instead of the default No. Click OK.
-
You should now be able to build and run the skeleton program. You can now
also see the game in action: Open the
Windows sample executable zip file and drag the folder named
LemmingsSample in it to your desktop. In that desktop folder, double-click
on the Lemmings application. (If the program crashes after 1 to 30 seconds
with a dialog box showing an error code 0xc0000022, try disabling your
antivirus software. Unfortunately, we can't tell the SEASnet Windows Server
to accept that there's no virus, so it may be impossible to run Lemmings on
that server.)
On Windows (another method)
On a system like the SEASnet Windows server where you don't have administrator
permissions or are otherwise constrained, or if the method above isn't
working for you, here's another method.
-
Decide where you want to install the SFML files; it can be whatever path you
want. Perhaps you'd like C:\tools on your own machine, or Z:\tools on the
SEASnet Windows server. In these instructions, we'll use C:\tools.
-
Download the latest stable version (SFML 3.0.2) from
https://www.sfml-dev.org/download/
and copy the SFML-3.0.2 folder from the zip file
SFML-3.0.2-windows-vc17-64-bit.zip into C:\tools. Rename C:\tools\SFML-3.0.2
to C:\tools\SFML.
-
Download the Windows skeleton
project. When you open the Windows skeleton zip file, make sure you drag the
Lemmings folder in it to your desktop (or somewhere else) and in the folder
there, double-click on the .sln solution file to open the project in Visual
C++. It doesn't work if you try to double-click on the one embedded in the
zip file.
-
If you installed SFML somewhere other than in C:\tools, select File > Open >
File... and open MyVariables.props. In the fifth line of that file, replace
"C:\tools" with the path to where you installed SFML.
-
You should now be able to build and run the skeleton program. See the last
step of the other Windows method above to see the game in action.
On Linux
-
Install SFML:
- Ubuntu, Debian:
sudo apt update; sudo apt install libsfml-dev
- Fedora:
sudo dnf install SFML-devel
-
You should now be able to build and run the
skeleton program. A Linux sample
executable is not yet available.
After Installing SFML
You can download the project skeletons with the code we've written, for Windows,
macOS with Xcode,
macOS on the command line, or
Linux, and make sure
you can build and run them. All they'll do is close the window after you type
q, but at least you can verify that the SFML library works
for you. Even if you're not ready to put time into this project at this
moment, test this now! You don't need to write any code to
test this.
The only files you will modify are Actor.h, Actor.cpp,
StudentWorld.h, and StudentWorld.cpp. Indeed, those will be the only code
files you'll turn in, so in implementing your solution, you must
not make and depend on any changes you make to code files
other than those four.
At some point in Project 3, you may find the
Stringstreams writeup helpful.
As a simple example of how a StudentWorld object and an actor object can
interact, this demo zip file has the StudentWorld and
Actor files for a simple demo that has one object appear that plays a sound
whenever you hit the space key. That object never dies, so type
q to end the demo. (Our framework intercepts the
q to end the game.)
Note for Xcode users
Your program may write a handful of log message lines to the Xcode console
window, starting with "Cannot index window tabs due to missing main bundle
identifier" and ending with "Reporter dsconnected ..." or maybe
"HALC_ProxyIOContext.cpp:1623 ...". You can ignore these messages. When
your program finishes, though, the last line should be the "Program ended
with exit code: 0" that Xcode writes.