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.
Dependencies: mbed MotionSensor
Entity/Bullets/Bullets.cpp
- Committer:
- el17sm
- Date:
- 2019-04-24
- Revision:
- 14:3361879490b2
- Parent:
- 13:d04a6caba40d
- Child:
- 15:44d5cc33d389
File content as of revision 14:3361879490b2:
#include "Bullets.h"
Bullets::Bullets(float pos_x, float pos_y, int dir){
moving = true;
face = 0;
hp = 1;
hitbox.width = 2;
hitbox.height = 2;
position.x = pos_x;
position.y = pos_y;
sprite_size.width = 2;
sprite_size.height = 2;
sprite_size.offset_x = 0;
sprite_size.offset_y = 0;
direction = dir;
}
void Bullets::move(float speed, float unused){
if (direction == 0){
position.y -= speed;
}
else if (direction == 1){
position.x += speed;
}
else if (direction == 2){
position.y += speed;
}
else if (direction == 3){
position.x -= speed;
}
}
int * Bullets::get_frame(){
return (int *) bullets_sprite;
}
bool Bullets::out_of_bounds_check(){
if (matrix_collision_test(position.x, position.y, 0)){
return true;
}
else if ((!(0 < position.x < 84)) || (!(0 < position.y < 48))){
return true;
}
return false;
}