Game Design Lab 1
Due Wednesday, September 2
Part 1: Introduction/review of C++ and Classes
This lab is intended to make sure everybody thinks about object oriented programming and C++, in preparation to use it in creating a game engine. The file lab1main.cpp is given, and contains a test routine expecting a class called "astronaut". The astronaut class must have 4 properties and 2 methods. The properties are:
- name : The name of the astronaut. Data type is string.
- age : The age of the astronaut, which must default to 26. Data type is int, or unsigned int if you prefer.
- alive : Whether or not the astronaut is alive. This must start as true. Data type is bool.
- flights : Number of space flights the astronaut has experienced. This should start at 0.
Methods are as follows:
- A constructor : This takes one string argument, which is the astronaugt's name. It is used to initialize the name property.
- void fly() : This is called when the astronaut is flown. It must increment flights. It should also give a 10% chance the astronaut dies, in which case the alive property will be changed to false.
Note from looking at lab1main.cpp that all properties are expected to be public. This stakes a position in an unresolved CS debate, which contradicts the standard practice given in many tutorials. It will simplify your code in this case. Do keep in mind that in many cases it is preferred to add extra methods soley to access properties (accessor methods). Take CS211 and CS311 (you may have already) for a more detailed discussion of the nature of object-oriented programming. At some point, you will likely form a strong opinion on this topic, and this point may have been in the past.
Upload your lab1class.h file to Canvas.
Part 2: Building an OpenGL Demo
Since we'll discuss OpenGL in class, it's important that everyone can build an OpenGL program. This is not too difficult on either Linux or Windows, but people have had trouble with MacOS in this class in the past. Hopefully if you have a mac, you can figure it out. You don't have to turn in anything for this part.
Linux option
The computers in the lab have Linux installed, and certainly you can too. The class demo is available as simple_demo_linux.zip from the class examples. Download it, extract it, run the makefile, and it may work. If you have a build error related to libraries, make sure glfw3 and glm are installed.
Windows option
The class demo is also available with a Visual Studio 2022 project. This worked fine for me on the lab computers. Download simple_demo_windows.zip from the class examples, extract it, open the .sln or .vcproj file with Visual Studio, and try to run it. The required libraries should already be in the folder, so I think it will just work.