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-22
- Revision:
- 5:a3c9a5837a7c
- Parent:
- 4:8e3ba8d6d915
- Child:
- 6:037dfa5064a1
File content as of revision 5:a3c9a5837a7c:
#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+11, _y+1, 1); lcd.drawLine(_x+2, _y+3, _x+3, _y+4, 1); lcd.drawLine(_x+11, _y+3, _x+10, _y+4, 1); } else if (_column < 6 && _column > 2) { lcd.drawLine(_x, _y+4, _x, _y+9, 1); lcd.drawLine(_x-1, _y+2,_x-1, _y+11, 1); lcd.drawLine(_x-3, _y+2, _x-4, _y+3, 1); lcd.drawLine(_x-3, _y+11, _x-4, _y+10, 1); } else if (_column < 9 && _column > 5) { lcd.drawLine(_x-4, _y, _x-9, _y, 1); lcd.drawLine(_x-2, _y-1, _x-11, _y-1, 1); lcd.drawLine(_x-2, _y-3, _x-3, _y-4, 1); lcd.drawLine(_x-11, _y-3, _x-10, _y-4, 1); } else if (_column < 12 && _column > 8) { lcd.drawLine(_x, _y-4, _x, _y-9, 1); lcd.drawLine(_x+1, _y-2, _x+1, _y-11, 1); lcd.drawLine(_x+3, _y-2, _x+4, _y-4, 1); lcd.drawLine(_x+3, _y-11, _x+4, _y-10, 1); } } void Hero::update(float d, float mag, int a) { _d = d; _mag = mag; if (_d < 0) { } else if (_d <= 15) { _column = 1; } else if (_d <= 45) { _column = 2; } else if (_d <= 75) { _column = 3; } else if (_d <= 105) { _column = 4; } else if (_d <= 135) { _column = 5; } else if (_d <= 165) { _column = 6; } else if (_d <= 195) { _column = 7; } else if (_d <= 225) { _column = 8; } else if (_d <= 255) { _column = 9; } else if (_d <= 285) { _column = 10; } else if (_d <= 315) { _column = 11; } else if (_d <= 345) { _column = 0; } else { _column = 1; } if (a == 1) { shoot = 1; } } 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 = {48, 1}; return p; } else if (_column == 3) { Vector2D p = {64, 3}; return p; } else if (_column == 4) { Vector2D p = {64, 17}; return p; } else if (_column == 5) { Vector2D p = {64, 30}; return p; } else if (_column == 6) { Vector2D p = {62, 46}; return p; } else if (_column == 7) { Vector2D p = {48, 46}; return p; } else if (_column == 8) { Vector2D p = {35, 46}; return p; } else if (_column == 9) { Vector2D p = {19, 44}; return p; } else if (_column == 10) { Vector2D p = {19, 30}; return p; } else if (_column == 11) { Vector2D p = {19, 17}; return p; } else { Vector2D p = {0,0}; return p; } }