![](/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.
Diff: Bullet/Bullet.cpp
- Revision:
- 10:2ae9d4145410
- Parent:
- 9:759b419fec3b
--- a/Bullet/Bullet.cpp Tue May 26 07:26:13 2020 +0000 +++ b/Bullet/Bullet.cpp Tue May 26 16:31:22 2020 +0000 @@ -8,6 +8,7 @@ } +//initialises the current column and position in the column of the bullet and draws the path void Bullet::init(int column) { _currentpos = 0; _column = column; @@ -15,20 +16,37 @@ } +//draws the bullet void Bullet::draw(N5110 &lcd) { - _x = _board.drawcolumn[_column][_currentpos].x; - _y = _board.drawcolumn[_column][_currentpos].y; + getxy(); lcd.drawRect(_x, _y, 2, 2, FILL_BLACK); } +//updates the bullet, moving it forward void Bullet::update() { _currentpos++; } +//checks if the bullet has reached the end of the lane int Bullet::checkdelete() { if (_currentpos > 13) { return 1; } else { return 0; } +} + +//gets the coordinates of the bullet +Vector2D Bullet::getxy() { + _x = _board.drawcolumn[_column][_currentpos].x; + _y = _board.drawcolumn[_column][_currentpos].y; + + Vector2D bulletxy = {_board.drawcolumn[_column][_currentpos].x, _board.drawcolumn[_column][_currentpos].y}; + return bulletxy; +} + +//gets the current column and position in the column +Vector2D Bullet::getcolumnpos() { + Vector2D p = {_column, _currentpos}; + return p; } \ No newline at end of file