Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Graphics Class Reference
#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.
- 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 | ( | ) |
| ~Graphics | ( | ) |
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.
Generated on Thu Jul 14 2022 01:14:35 by
1.7.2