Sample Code

NOTE: All .c files were originally .cpp files but WordPress won’t let me upload .cpp files. >:(

 

Project: Lux

World.cpp

This is the main physics manager file for my physics engine that was used in Lux.  The code may have been a little ugly, but it is the central control point for my entire physics engine and it needs to be able to handle all portions of my physics engine such as rigid body dynamics, collision detection, collision resolution, and ray tracing.

 

Project: Straight Lines

GameEngine.cpp

This is the main framework file for my solo project, Straight Lines.  I use a fair amount of #defines to control various setting switches for the game engine.

 

Project: Straight Lines

GameObject.h
GameObject.cpp

This is the base class for all game logic objects implemented in the game component.  It fills in basic functionality required by all component objects and provides some game related functionality for derived types.

 

Project: Straight Lines

EnemyObjectFactory.cpp

This is a factory class for pre-allocating enemy game objects and initializing them.  This class allows me to load all the enemy objects for a single level during load time and quickly add them to the game at runtime to avoid having to initialize a full game object from scratch while the game is running.  Using a factory class also helps tremendously with debugging and some level design for the game.

 

Project: Straight Lines

Replay.cpp

This is the class that holds a single instance of a replay.  For Straight Lines, a single replay holds all the non-deterministic events that occur in one level, and records the rand seed so that a level can be played back again.

Comments are closed.