Lab 1 - A Simple Game

GitHub Classroom Assignment Page

The base code for this lab can be found on GitHub here

This assignment is due on Friday 1/19.

The above base code is just a recommendation - you can start from any CSC 471 base code, or from any of your past 471 assignments. You can also start from scratch if you want!

Please note that this lab can be completed in pairs - it is up to you.

Overview

This assignment requires you to develop a simple 3D game program in which a player moves around a 3D scene and collides with objects, collecting them. In the game, key presses control the player’s position and the player’s view direction is controlled via the mouse. The game scene includes a ground plane. When the game starts the only 3D object that appears in the scene is the ground plane. But, every few seconds a new object automatically appears on the ground plane at a random position. After an object has entered the game it moves at a constant velocity to a new position every frame, though objects must avoid colliding with other objects and they must not move off the grid. The goal of the game is for the player to collect all the objects by colliding with them. Points are scored by successfully capturing an object (“hit”).

Learning Objectives

Problem Specifications

Here are the rules of this game and specifications for your implementation of the game.

1. Ground plane

The 3D scene contains a ground plane that is in the X-Z plane (i.e., in the plane defined by the plane equation y = 0). You may include any other scene elements you’d like (for example some simple hierarchical models in the scene) - if you do include scene elements you do not need to compute collision with them, but I encourage you to try.

2. Game objects

Sitting on the ground plane, during the game one or more 3D objects which have a clear orientation (i.e. a front and back) will appear over time. The size, structure, color, and other attributes of the objects will be determined by the game developer (you). With the exception that the object must be a mesh file (.obj). These objects must be shaded! Use vertex buffer objects and vertex array objects to display the game objects.

3. Game Player

During the game the current value of several variables is displayed (in text within the game window or to the console): frame rate, count of # of 3D objects currently in the scene, count of # of objects encountered (i.e. collided with = game score).

Note: This game uses no spatial dataset for determining whether objects might collide. Objects will be stored in a linked list (or vector), and processing them (collision checking and drawing) will be done by linear list traversal. Thus, all objects are drawn even if they are outside the field of view (they will be clipped by the OpenGL rendering pipeline).

Checking for object collisions will be an O(N^2) complexity operation (for N = # of 3D objects). Thus, if the player is slow at picking up objects, more and more objects will be created and the frame rate may get slower (depending on mesh complexity and number of objects). Potentially, slower frame rate makes motion control for the player more difficult, so poor play is penalized and leads to low scores. Limit the number of meshes that can enter the game to 10-50 (your choice depending on scaling - more meshes makes non-overlapping placement challenging depending on scale).


In general, this lab is intended for you to consider how you might like to proto-type software design for your team game. Think about: how you might like to design a game object class, a camera class, a more sophisticated shader class (consider using how to handle uniform and attribute variables in general) and other aspects of your game. This is a chance to practice/experiment with various software design choices - your goal is for your team to choose the best “lab 1” to use as the start to your final game project. You can look at these articles on game programming patterns:

http://gameprogrammingpatterns.com/contents.html

And this opinion piece about OO vs. entity:

http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/

Programming Design and Implementation Information

(if you want to propose an alternative reasonable design you can).

0. 3D object class

This is a good time to design a C++ class for your 3D object (I like most part of this short intro: http://homes.cs.washington.edu/~tom/c++example/c++.pdf)

1. The class traditionally includes a constructor, destructor, a step (update) function, and a draw function.

You may include other functions if needed.

  1. If the new position would be off the grid, negate the direction vector and recompute the new position.
  2. If the new position would cause the object’s bounding box to intersect the bounding of any other object, do not update the position.

2. 3D objects collection

Note: this is an O(N^2) computation. Later in this course you will learn algorithms to reduce the complexity of such a comparison.

Grading: