ELEC2645 (2018/19) / Mbed 2 deprecated EL17MCD

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Graphics Class Reference

Graphics Class Reference

Graphics Class. More...

#include <Graphics.h>

Public Member Functions

 Graphics ()
 Constructor.
 ~Graphics ()
 Destructor.
void draw_tank_l (int x, int y, N5110 &lcd)
 Draw the left tank sprite.
void draw_turret_l (int x, int y, int angle, N5110 &lcd)
 Draw the left tank's turret sprite.
void draw_left_victory (N5110 &lcd)
 Show left tank victory screen.
void draw_tank_r (int x, int y, N5110 &lcd)
 Draw the right tank sprite.
void draw_turret_r (int x, int y, int angle, N5110 &lcd)
 Draw the right tank's turret sprite.
void draw_right_victory (N5110 &lcd)
 Show right tank victory screen.
void draw_projectile (int x, int y, N5110 &lcd)
 Draw the projectile sprite.
void draw_wind_bar (float wind, N5110 &lcd)
 Draws a bar/arrow that indicates the strength and direction of the wind.
void draw_reticle (int x, int y, float angle, N5110 &lcd)
 Draws a dot to indicate where the tank is aiming.
void draw_parkinson_map (int x, int y, N5110 &lcd)
 Draws a building obstacle on the map.
void show_health (int current, Gamepad &pad)
 Lights LEDs equal to the input value.
void start_up (int alt, Gamepad &pad)
 Toggles three LEDS on at a time for the start up screen.
void draw_start_up_screen (N5110 &lcd)
 Draws the start up screen visuals.

Detailed Description

Graphics Class.

Holds the sprites and governs their use. Governs the use of LEDs in the game.

Author:
Maxim C. Delacoe
Date:
April 2019
#include "mbed.h"
#include "N5110.h"
#include "Gamepad.h"
#include "Graphics.h"
 
N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
Gamepad pad;
Graphics _graphics;
 
 
int main() {
    
  lcd.init();
  
  while (1) {
    
    int _mag = pad.get_mag(); 
    int _angle = pad.get_angle();
    
    lcd.clear();
    _graphics.draw_tank_l(10, 0, lcd); // Draw tank in appropriate position.                                                          
    _graphics.draw_turret_l(10, 0, _angle, lcd); 
    if (_mag >= 0.5) {                           // only draw the reticle if the joystick is not in
      _graphics.draw_reticle(10, 0, _angle, lcd);    // a neutral position.
    } 
    lcd.refresh();  
  }                
} 

Definition at line 46 of file Graphics.h.


Constructor & Destructor Documentation

Graphics (  )

Constructor.

Non user specified.

Definition at line 10 of file Graphics.cpp.

~Graphics (  )

Destructor.

Non user specified.

Definition at line 15 of file Graphics.cpp.


Member Function Documentation

void draw_left_victory ( N5110 lcd )

Show left tank victory screen.

Parameters:
x*

The left tank turret's position in the x direction

Parameters:
y*

The left tank turret's position in the y direction

Parameters:
angle*

The tank turret's angle

Parameters:
lcd*

The lcd object from N5110 class

Definition at line 102 of file Graphics.cpp.

void draw_parkinson_map ( int  x,
int  y,
N5110 lcd 
)

Draws a building obstacle on the map.

Parameters:
x*

The map object's position in the x direction

Parameters:
y*

The map object's position in the y direction

Parameters:
lcd*

The lcd object from N5110 class

Definition at line 235 of file Graphics.cpp.

void draw_projectile ( int  x,
int  y,
N5110 lcd 
)

Draw the projectile sprite.

Parameters:
x*

The projectile's position in the x direction

Parameters:
y*

The projectile's position in the y direction

Parameters:
lcd*

The lcd object from N5110 class

Definition at line 204 of file Graphics.cpp.

void draw_reticle ( int  x,
int  y,
float  angle,
N5110 lcd 
)

Draws a dot to indicate where the tank is aiming.

Parameters:
x*

The left tank turret's position in the x direction

Parameters:
y*

The left tank turret's position in the y direction

Parameters:
angle*

The tank turret's angle

Parameters:
lcd*

The lcd object from N5110 class

Definition at line 226 of file Graphics.cpp.

void draw_right_victory ( N5110 lcd )

Show right tank victory screen.

Parameters:
x*

The right tank turret's position in the x direction

Parameters:
y*

The right tank turret's position in the y direction

Parameters:
angle*

The tank turret's angle

Parameters:
lcd*

The lcd object from N5110 class

Definition at line 194 of file Graphics.cpp.

void draw_start_up_screen ( N5110 lcd )

Draws the start up screen visuals.

Parameters:
lcd*

The lcd object from N5110 class

Definition at line 312 of file Graphics.cpp.

void draw_tank_l ( int  x,
int  y,
N5110 lcd 
)

Draw the left tank sprite.

Parameters:
x*

The tank's position in the x direction

Parameters:
y*

The tank's position in the y direction

Parameters:
lcd*

The lcd object from N5110 class

Definition at line 20 of file Graphics.cpp.

void draw_tank_r ( int  x,
int  y,
N5110 lcd 
)

Draw the right tank sprite.

Parameters:
x*

The tank's position in the x direction

Parameters:
y*

The tank's position in the y direction

Parameters:
lcd*

The lcd object from N5110 class

Definition at line 112 of file Graphics.cpp.

void draw_turret_l ( int  x,
int  y,
int  angle,
N5110 lcd 
)

Draw the left tank's turret sprite.

Parameters:
x*

The left tank turret's position in the x direction

Parameters:
y*

The left tank turret's position in the y direction

Parameters:
angle*

The tank turret's angle

Parameters:
lcd*

The lcd object from N5110 class

Definition at line 33 of file Graphics.cpp.

void draw_turret_r ( int  x,
int  y,
int  angle,
N5110 lcd 
)

Draw the right tank's turret sprite.

Parameters:
x*

The right tank turret's position in the x direction

Parameters:
y*

The right tank turret's position in the y direction

Parameters:
angle*

The tank turret's angle

Parameters:
lcd*

The lcd object from N5110 class

Definition at line 125 of file Graphics.cpp.

void draw_wind_bar ( float  wind,
N5110 lcd 
)

Draws a bar/arrow that indicates the strength and direction of the wind.

Parameters:
wind*

The acceleration due to wind in the x direction

Parameters:
lcd*

The lcd object from N5110 class

Definition at line 213 of file Graphics.cpp.

void show_health ( int  current,
Gamepad pad 
)

Lights LEDs equal to the input value.

Parameters:
current*

The player's current health

Parameters:
pad*

The pad object from Gamepad class

Definition at line 274 of file Graphics.cpp.

void start_up ( int  alt,
Gamepad pad 
)

Toggles three LEDS on at a time for the start up screen.

Parameters:
alt*

The value of the alternator/incrementer

Parameters:
pad*

The pad object from Gamepad class

Definition at line 298 of file Graphics.cpp.