Winter 2024 CS 32
Programming Assignment 3
Marble Madness
Part 1 due 11:00 PM Saturday, February 24
Part 2 due 11:00 PM Sunday, March 3
The Project 3 specification document is posted.
Updates
-
2/20 3:45pm: Tha sample executables were corrected so that Vertical RageBots
move vertically instead of horizontally.
-
2/18 1:40pm: There was a period of time before now when the spec said that the
chracter m in a level data file represented a marble. That has been
corrected to say the letter is b, which corresponds to what's actually
in the level files we provide. (At some point after the files were prepared
and Level.h was written, it was decided to call the items marbles, not, say,
beads.)
-
2/17 1:00pm: Spec pp. 13, 14, and 21 were corrected to show that the method
that returns the path to the assets directory is named assetPath(),
not assetDirectory().
To see what the game looks like in action:
-
Windows: Open the Windows sample
executable zip file and drag the folder named MarbleMadness in it to
your desktop. In that desktop folder, double-click on the MarbleMadness
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 MarbleMadness on that server.)
-
macOS: You'll need to have XQuartz installed to run the program.
-
Install XQuartz:
-
Click the download link, open the downloaded .pkg file, XQuartz.pkg, and
follow the installation instructions.
-
Log out and log back in again. (It's possible that you might not have to
do this step, but we're not sure.)
-
To verify the installation, open a Terminal window and run the command
echo $DISPLAY
. That should produce one line of output that
ends with org.xquartz:0
.
-
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.
-
Linux:
-
Install OpenGL and freeGLUT (already installed on the SEASnet Linux
servers cs32.seas.ucla.edu, lnxsrv06.seas.ucla.edu, lnxsrv07.seas.ucla.edu,
and lnxsrv09.seas.ucla.edu):
- Ubuntu:
sudo apt-get install freeglut3 freeglut3-dev
- Fedora:
sudo yum install freeglut freeglut-devel
-
Unzip the Linux sample executable
zip file. Change into the MarbleMadness directory. In that directory
there is a file named README that tells you how to launch the program.
You won't hear any sound effects. The Linux version builds and tries to
connect to an X11 server, so it should work if your DISPLAY environment
variable is set correctly. When we have a chance, we may have a way to
get sound effects working.
You can also 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 graphics 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 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.)
Notes for Visual C++ users:
-
When you open the Windows skeleton zip file, make sure you drag the
MarbleMadness folder 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 work with the one embedded in the zip
file.
-
If the Windows skeleton doesn't build for you,
you might need to ensure that your project is using Windows SDK Version
10.0.19041.0 or 10.18362.0 (or possibly 10.0.22000.0 or higher). To
do this:
-
Launch the Visual Studio Installer, find your version of Visual Studio,
and select Modify. In the list on the right side, under Desktop development
with C++, under Optional, make sure one of the Windows 11 SDK or Windows 10
SDK options numbered 10.0.18362.0 or higher is selected.
-
After modifying your Visual Studio installation, open the project in Visual
Studio and right-click on Solution 'MarbleMadness' above the list of source
files. Select Retarget Solution from the menu and choose the newly installed
version of the SDK if accepting "10.0 (latest installed version)" doesn't
work for you.
-
Build the project.
-
Also, if the skeleton crashes after 1 to 30 seconds with a dialog box
showing an error code 0xc0000022, try disabling your antivirus software
and building the executable.
Notes for Xcode users:
-
You might get a message at startup relating to the Assets
directory. If you want to fix the issue just for this project, select
File / Project Settings... and for Derived Data Location, select
Project-relative Location. If instead you want to fix it for every
project you create with Xcode, select Xcode / Preferences... and for the
Derived Data, select Relative. Alternatively, you could simply change the
assetDirectory string literal in main.cpp to be a full path name to wherever
you choose to put the Assets directory.
-
Your program may write a lot of log messages to the Xcode output window.
Each message starts with the date and time; the first message is
"Initializing libGL." 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, and above that you should see "No memory leaks were
detected".