Skip to content

Engine Class

Nolan Burfield edited this page Jul 14, 2016 · 3 revisions

Functions

Engine(string name)

Stores the passed in values for use later when initializing the window. The height and width are set with the window and will make a full screen window.

Engine(string name, int width, int height)

Stores the passed in values for use later when initializing the window.

~Engine()

Cleans up the window and the graphics.

bool Initialize()

Builds the window and starts the graphics.

void Run()

Begins an infinite loop that will

  • grab the time change
  • check for an SDL_Event
  • update the graphics
  • render the graphics
  • swap out the window frame

Ends when m_running is set to false.

void Keyboard()

This will read the m_event to determine what what the event to process. At this point it only works with exiting.

unsigned int getDT()

Gets the difference in time from m_currentTimeMillis to current time.

long long GetCurrentTimeMillis()

Uses the sys/time.h gettimeofday() function to grab the current time and turns it into a long long.

Variables

Window *m_window

The window of the program.

string m_WINDOW_NAME

Name of the window.

int m_WINDOW_WIDTH

Width of the window.

int m_WINDOW_HEIGHT

Height of the window.

SDL_Event m_event

Any SDL event is save in the m_event;

Graphics *m_graphics

The graphics part of the program.

unsigned int m_DT

The updated change in time.

long long m_currentTimeMillis

Stores the previous time.

bool m_running

Used to kill the infinite loop. Only set on the exit of the window or escape key hit.

Notes

The setup of this may need to change when incorporating new input logic.

Clone this wiki locally