![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Matis Requis 201241242
Dependencies: mbed
Tempest Game
Game Screen
The board is made of 12 columns. The Hero stays at the top of the column
Game Controls
To control the hero spaceship point the joystick to the column you want the hero to go to.
Press the A button to shoot a bullet in the column you are currently in.
Hero/Hero.cpp
- Committer:
- MatisRequis
- Date:
- 2020-05-19
- Revision:
- 2:d59a92e65bd9
- Child:
- 4:8e3ba8d6d915
File content as of revision 2:d59a92e65bd9:
#include "Hero.h" Hero::Hero() { } Hero::~Hero() { } void Hero::init(int column) { _column = column; } void Hero::draw(N5110 &lcd) { Vector2D xypos = getxy(); _x = xypos.x; _y = xypos.y; if (_column < 3 && _column >= 0) { lcd.drawRect(_x+4, _y, 6, 2, FILL_BLACK); lcd.drawLine(_x+2, _y+1, _x+12, _y+1, 1); lcd.drawLine(_x+2, _y+3, _x+3, _y+5, 1); lcd.drawLine(_x+12, _y+3, _x+11, _y+5, 1); } else if (_column < 6 && _column > 2) { lcd.drawRect(_x-2, _y+4, 2, 6, FILL_BLACK); } else if (_column < 9 && _column > 5) { //lcd.drawRect(); } else { //lcd.drawRect(); } } void Hero::update(Direction d) { if (_column < 3 && _column >= 0) { if (d == W) { if (_column == 0) { _column = 11; } else { _column--; } } else if (d == E) { if (_column == 11) { _column = 0; } else { _column++; } } } else if (_column < 6 && _column > 2) { if (d == N) { if (_column == 0) { _column = 11; } else { _column--; } } else if (d == S) { if (_column == 11) { _column = 0; } else { _column++; } } } else if (_column < 9 && _column > 5) { if (d == E) { if (_column == 0) { _column = 11; } else { _column--; } } else if (d == W) { if (_column == 11) { _column = 0; } else { _column++; } } } else { if (d == S) { if (_column == 0) { _column = 11; } else { _column--; } } else if (d == N) { if (_column == 11) { _column = 0; } else { _column++; } } } } Vector2D Hero::getxy() { if (_column == 0) { Vector2D p = {21, 1}; return p; } else if (_column == 1) { Vector2D p = {35, 1}; return p; } else if (_column == 2) { Vector2D p = {49, 1}; return p; } else if (_column == 3) { Vector2D p = {65, 3}; return p; } else if (_column == 4) { Vector2D p = {65, 17}; return p; } else if (_column == 5) { Vector2D p = {65, 31}; return p; } else if (_column == 6) { Vector2D p = {63, 47}; return p; } else if (_column == 7) { Vector2D p = {49, 47}; return p; } else if (_column == 8) { Vector2D p = {35, 47}; return p; } else if (_column == 9) { Vector2D p = {19, 45}; return p; } else if (_column == 10) { Vector2D p = {19, 31}; return p; } else if (_column == 11) { Vector2D p = {19, 17}; return p; } Vector2D p = {0,0}; return p; }