ELEC2645 (2018/19) / Mbed 2 deprecated el17aj

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

GameEngine Class Reference

GameEngine Class Reference

GameEngine Class. More...

#include <GameEngine.h>

Public Member Functions

void init (int CrossHairsSpeed, int fps)
 Initisalise the game with cross hair speed and frames per second.
void read_input (Gamepad &pad)
 read input from gamepad
void update (Gamepad &pad)
 updates the gamepad based on inputs
void draw (N5110 &lcd)
 draws sprites on the display
bool get_game_over ()
 returns if the game is over or not
void set_game_over (bool is_game_over)
 sets if game is over or not

Detailed Description

GameEngine Class.

Author:
Adam Jones, University of Leeds Controls Game
Date:
April 2019 Revision 1.0
#include "mbed.h"
#include "Gamepad.h"
#include "N5110.h"
#include "GameEngine.h"






int main()
{ 
    //initialise game object
    GameEngine game;
    int crossHairsSpeed = 5;
    int fps = 16
    game.init(crossHairsSpeed, fps);
    
    //read input from gamepad
    Gamepad pad;
    game.read_input(pad);
    
    //update game state
    game.update(pad);
    
    /draw game state
    game.draw(lcd);
    
    //returns if game is over or not
    bool isOver = game.get_game_over();
    
    //sets if game is over or not
    game.set_game_over(false); //false = not over, true = over

}

Definition at line 62 of file GameEngine.h.


Member Function Documentation

void draw ( N5110 lcd )

draws sprites on the display

Parameters:
lcdthe N5110 object

Definition at line 50 of file GameEngine.cpp.

bool get_game_over (  )

returns if the game is over or not

Returns:
game over

a boolean value

Definition at line 147 of file GameEngine.cpp.

void init ( int  CrossHairsSpeed,
int  fps 
)

Initisalise the game with cross hair speed and frames per second.

Parameters:
crosshairs speed

max speed of the cross hairs in pixels per frame

Parameters:
fpsthe fps of the game

Definition at line 15 of file GameEngine.cpp.

void read_input ( Gamepad pad )

read input from gamepad

Parameters:
gamepadthe gamepad object

Definition at line 44 of file GameEngine.cpp.

void set_game_over ( bool  is_game_over )

sets if game is over or not

Parameters:
gameover

a boolean value

Definition at line 151 of file GameEngine.cpp.

void update ( Gamepad pad )

updates the gamepad based on inputs

Parameters:
gamepadthe gamepad object

Definition at line 69 of file GameEngine.cpp.