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.
Diff: My_game_clases/Objects.cpp
- Revision:
- 14:739115711bf8
- Parent:
- 13:1dbef50789ed
- Child:
- 16:e2aaef863d7c
--- a/My_game_clases/Objects.cpp Wed Apr 29 12:48:40 2020 +0000 +++ b/My_game_clases/Objects.cpp Wed Apr 29 13:51:14 2020 +0000 @@ -51,7 +51,7 @@ lcd.drawSprite(_cannon_pos,40,6,6,(int *)_cannon); } -void Objects::draw_shots(N5110 &lcd) +void Objects::draw_shots(N5110 &lcd,Gamepad &pad) { for (int i = 0; i < _shot_y_pos.size(); i++) { @@ -63,8 +63,10 @@ //adds another shot if the distance between //y pos of the initial pos and previous shot pos is more than 7 if(_shot_y_pos[_shot_y_pos.size() - 1 ] + 7 < _initial_shot_pos || _shot_y_pos.size() < 1) { - _shot_y_pos.push_back(_initial_shot_pos); - _shot_x_pos.push_back(_cannon_pos + 2); + if(pad.A_held()) { + _shot_y_pos.push_back(_initial_shot_pos); + _shot_x_pos.push_back(_cannon_pos + 2); + } } //erasing a shot if the y position is below 0 if(_shot_y_pos[0] <= 0) {