Game Engineering – II |Assignment – 5

For this assignment I had to give the game the ability to move the camera as well as the any meshes that were to be rendered. Also, the game had to have the ability to switch out meshes at will.

Here is the executable MyGame_

Controls :

  • F1 – F2 — Move camera up – down
  • F3 – F4 — Move camera left – right
  • directional keys — move shape
  • ENTER — Change shape

For these requirements the biggest this that needed to be implemented was a gameObject class that would be responsible fora mesh-effect pair including its rigid body state (for movement and rotation). As well for the camera, I needed to implement a similar class and not just a configuration built-in to the graphics library because, this gives the game programmer the ability to not only move the camera but also be able to add more cameras to the game for viewing from different angles.

Here is a screenshot of the gameObject interface.


As you can see instead of submitting the mesh and effect data directly from MyGame.cpp I now do it through the gameObject itself. Thus, each of these objects has to call this function to render onto the game screen. Giving it the elapsed second count is required for movement which brings us to the modified interface for submitting data shape data to the graphics library.


Here our submission function has been modified to also take in the objects transform data and the elapsed second count since the last update (explained below). This is required for Graphics.cpp so that it knows where on the screen the object needs to be rendered.

This in turn increased the amount of information that needed to be cached which now sits at 884 bytes. This was because each mesh to be rendered now required positional data for each draw call (64 bytes);

On another note the mesh positions when being rendered needed to be extrapolated to be at the right location because our simulation keeps running even as the rendering data has been submitted to graphics.cpp and so when it’s actually time to draw the shape on the screen, its position would have changed from what was initially submitted. Hence I have my interface also require the user to submit the elapsed second count.

And finally, the simulation itself.


P.S I also update my effect class to take in an optional input for specifying the render state.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s