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:
- 82:3211b31e9421
- Parent:
- 36:27aa597db3d2
- Child:
- 85:87bc28b151d8
--- a/Weapons/Weapons.cpp Mon May 25 15:59:14 2020 +0000 +++ b/Weapons/Weapons.cpp Mon May 25 18:39:51 2020 +0000 @@ -10,9 +10,9 @@ void Weapons::init(Vector2D sprite_pos, bool sprite_direction, bool bullet_type) { - // bullet for alien or for spacship + // Bullet for alien or for spacship set_direction(sprite_direction); - if (bullet_type){ + if (bullet_type) { calc_bullets_start_pos(sprite_pos, sprite_direction); }else{ calc_alien_bullets_start_pos(sprite_pos, sprite_direction); @@ -20,8 +20,8 @@ bullet_delete_counter_ = 0; } -void Weapons::smart_bomb(N5110 &lcd){ - // turn backlight off and on twice +void Weapons::smart_bomb(N5110 &lcd) { + // Turn backlight off and on twice lcd.backLightOff(); wait(0.02); lcd.backLightOn(); @@ -33,9 +33,9 @@ void Weapons::calc_bullets_start_pos(Vector2D spaceship_pos, -bool spaceship_sprite_direction_){ +bool spaceship_sprite_direction_) { // Sets start position of bullet to spaceships nose - if (spaceship_sprite_direction_){ + if (spaceship_sprite_direction_) { position_x_ = spaceship_pos.x + 13; position_y_ = spaceship_pos.y + 2; }else{ @@ -48,54 +48,54 @@ #endif } -void Weapons::draw_bullet(N5110 &lcd){ - // draws then moves the bullet position +void Weapons::draw_bullet(N5110 &lcd) { + // Draws then moves the bullet position lcd.drawLine(position_x_, position_y_, position_x_+1, position_y_, 1); - if(direction_){ + if(direction_) { position_x_ += 3; }else{ position_x_ -= 3; } - // increments counter + // Increments counter bullet_delete_counter_++; } void Weapons::calc_alien_bullets_start_pos(Vector2D alien_pos, -bool alien_sprite_direction_){ +bool alien_sprite_direction_) { // Sets start position of bullet to middle of alien position_x_ = alien_pos.x + 3; position_y_ = alien_pos.y + 3; - //gets a random direction for the bullet to travel in + // Gets a random direction for the bullet to travel in set_random_move(); } -void Weapons::draw_alien_bullet(N5110 &lcd,Direction d_){ - // draws then moves the bullet position +void Weapons::draw_alien_bullet(N5110 &lcd,Direction d_) { + // Draws then moves the bullet position lcd.drawLine(position_x_, position_y_, position_x_+1, position_y_, 1); - //Moves bullet in random direction and accomodates for spaceship movement + // Moves bullet in random direction and accomodates for spaceship movement move_direction(); position_x_ += calc_sprite_movement(d_); - // increments counter + // Increments counter bullet_delete_counter_++; } -void Weapons::set_pos_one(Vector2D pos){ +void Weapons::set_pos_one(Vector2D pos) { position_x_ = pos.x; position_y_ = pos.y; } -void Weapons::set_direction(bool sprite_direction){ +void Weapons::set_direction(bool sprite_direction) { direction_ = sprite_direction; } -int Weapons::get_bullet_delete_counter(){ +int Weapons::get_bullet_delete_counter() { return bullet_delete_counter_; } -bool Weapons::get_direction(){ +bool Weapons::get_direction() { return direction_; } \ No newline at end of file