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.
Weapons/Weapons.cpp
- Committer:
- evanso
- Date:
- 2020-05-06
- Revision:
- 23:cc44e26c08fa
- Parent:
- 22:053c11a202e1
- Child:
- 27:8bb2bd97c319
File content as of revision 23:cc44e26c08fa:
#include "Weapons.h" Weapons::Weapons() { } Weapons::~Weapons() { } 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 + 2; }else{ position_x_bullet_ = spaceship_pos.x; position_y_bullet_ = spaceship_pos.y + 2; } #ifdef POSITION_BULLET_DEBUG printf("X = %d\n", position_x_bullet_); printf("Y = %d\n", position_y_bullet_); #endif } void Weapons::draw_bullet(N5110 &lcd){ // draws then moves the bullet position 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(){ Vector2D pos = {position_x_bullet_,position_y_bullet_}; return pos; } void Weapons::set_pos_one(Vector2D pos){ position_x_bullet_ = pos.x; position_y_bullet_ = pos.y; } Vector2D Weapons::get_pos_two(){ Vector2D pos = {position_x_bullet_+1,position_y_bullet_}; return pos; } 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_; }