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: Weapons/Weapons.cpp
- Revision:
- 20:febd920ec29e
- Parent:
- 19:1bc0a2d22054
- Child:
- 22:053c11a202e1
diff -r 1bc0a2d22054 -r febd920ec29e Weapons/Weapons.cpp --- a/Weapons/Weapons.cpp Sun May 03 18:15:58 2020 +0000 +++ b/Weapons/Weapons.cpp Mon May 04 10:47:06 2020 +0000 @@ -11,16 +11,17 @@ void Weapons::init(Vector2D spaceship_pos, bool spaceship_sprite_direction) { calc_bullets_start_pos(spaceship_pos, spaceship_sprite_direction); set_direction(spaceship_sprite_direction); + bullet_delete_cunter_ = 0; } void Weapons::calc_bullets_start_pos(Vector2D spaceship_pos, bool spaceship_sprite_direction_){ // Sets start position of bullet to spaceships nose if (spaceship_sprite_direction_){ position_x_bullet_ = spaceship_pos.x + 13; - position_y_bullet_ = spaceship_pos.y + 3; + position_y_bullet_ = spaceship_pos.y + 2; }else{ position_x_bullet_ = spaceship_pos.x; - position_y_bullet_ = spaceship_pos.y + 3; + position_y_bullet_ = spaceship_pos.y + 2; } #ifdef POSITION_BULLET_DEBUG printf("X = %d\n", position_x_bullet_); @@ -29,12 +30,16 @@ } void Weapons::draw_bullet(N5110 &lcd){ + // draws then moves the bullet lcd.drawLine(position_x_bullet_, position_y_bullet_, position_x_bullet_+1, position_y_bullet_, 1); if(bullet_direction_){ position_x_bullet_ += 3; }else{ position_x_bullet_ -= 3; } + + // increments counter + bullet_delete_cunter_++; } Vector2D Weapons::get_pos_one(){ @@ -47,6 +52,14 @@ return pos; } -bool Weapons::set_direction(bool spaceship_sprite_direction){ +void Weapons::set_direction(bool spaceship_sprite_direction){ bullet_direction_ = spaceship_sprite_direction; +} + +int Weapons::get_bullet_delete_counter(){ + return bullet_delete_cunter_; +} + +bool Weapons::get_direction(){ + return bullet_direction_; } \ No newline at end of file