C++ for Game Engines


Introductions

Introduce yourselves!

Icebreaker: What is your favorite game of all time?


Groupwork

Given a game engine with a GameObject class definition.

  1. Write code for move() that moves the game object to a new (x,y) location. How do you differentiate the class (x,y) attributes from the method (x,y) parameters?

  2. Assume you want a Saucer class to be managed by the game engine. A Saucer has an (x,y) location and 10 hit points. Write the class definition.

  3. Now, assume the Saucer should gain 1 hit point every time it moves to a new (x,y) location. There are at least two ways to write this code.

    1. What are they? What are the advantages/disadvantages of each?

    2. Assume you want the game engine to move the Object as in 1). Write the Saucer::move() method.

  4. Assume the GameEngine just has a pointer to a GameObject (e.g., GameObject *p_o).

    1. What is the syntax for invoking the move() method?

    2. Assume the engine wants to invoke the object-specific move() method (e.g., Saucer::move()). How does this happen? What keyword do you need to add to the GameObject definition to make this work?


Hand-in

Have ONE person from each group submit the group's answers:

https://wpi.qualtrics.com/jfe/form/SV_9nW6BckzrVbDz0i

Make sure to include the names of all group members.

Happy C++-ing!

-- Mark