Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due
Programming Assignment 3
Wonky Kong
Part 1 due 11:00 PM Sunday, February 23
Part 2 due 11:00 PM Sunday, March 2
The Project 3 specification document is posted.
Updates
-
2/23 4:40pm: The spec has been updated to clarify the relationship between StudentWorld's destructor and its cleanUp() method. The page 11 paragraph starting "The code that you write" has been updated, and the page 19 "cleanUp() Details" section has a new paragraph starting "IMPORTANT NOTE:".
2/20 12:30am: Details of the Ladder class that were missing from the original version of the spec have been added on page 29 of the spec.
2/17 10:30pm: For Xcode users: If you're building and running under Xcode and instead of the program starting with the welcome window, you get the message failed to open display '', do the following:
- In a Terminal window, type echo $DISPLAY and see if it writes one line like /private/tmp/com.apple.launchd.jyOB2CIw2y/org.xquartz:0 although the text jyOB2CIw2y might be some other 10-character sequence.
-
In main.cpp, insert the following line as the first statement of the main routine:
setenv("DISPLAY", "/private/tmp/com.apple.launchd.jyOB2CIw2y/org.xquartz:0", 1);
except that you should replace the jyOB2CIw2y with the 10-character you saw for step 1.
To see what the game looks like in action:
- Windows: Open the Windows sample executable zip file and drag the folder named WonkyKongSample in it to your desktop. In that desktop folder, double-click on the WonkyKong 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 WonkyKong 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.
-
Install XQuartz:
-
Linux: Here's how to run the sample executable on your own Linux computer:
-
Install OpenGL and freeGLUT (already installed on the SEASnet Linux servers cs32.seas.ucla.edu, lnxsrv14.seas.ucla.edu, lnxsrv16.seas.ucla.edu, and lnxsrv17.seas.ucla.edu):
- Ubuntu: sudo apt install freeglut3-dev
- Fedora: sudo dnf install freeglut-devel
- Unzip the Linux sample executable zip file. Change into the WonkyKongSample 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. Since the SEASnet remote Linux server doesn't know about your computer's screen, you won't be able to run the program; you'll get a message freeglut (WonkyKong): failed to open display ''.
-
Install OpenGL and freeGLUT (already installed on the SEASnet Linux servers cs32.seas.ucla.edu, lnxsrv14.seas.ucla.edu, lnxsrv16.seas.ucla.edu, and lnxsrv17.seas.ucla.edu):
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.)
Notes for Visual C++ users:
- When you open the Windows skeleton zip file, make sure you drag the WonkyKong 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 double-click on 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 'WonkyKong' 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 the "No memory leaks were detected" that our framework writes if all of the dynamically allocated objects you displayed on the screen were properly deleted.