Steven Mahasin / Mbed 2 deprecated DreamDungeon

Dependencies:   mbed MotionSensor

Committer:
el17sm
Date:
Wed Apr 24 03:09:00 2019 +0000
Revision:
14:3361879490b2
Parent:
13:d04a6caba40d
Child:
15:44d5cc33d389
Death of Entities and Bullets done, Laser problem (fire rate);

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el17sm 13:d04a6caba40d 1 #include "Bullets.h"
el17sm 13:d04a6caba40d 2
el17sm 13:d04a6caba40d 3 Bullets::Bullets(float pos_x, float pos_y, int dir){
el17sm 13:d04a6caba40d 4 moving = true;
el17sm 13:d04a6caba40d 5 face = 0;
el17sm 13:d04a6caba40d 6 hp = 1;
el17sm 13:d04a6caba40d 7 hitbox.width = 2;
el17sm 13:d04a6caba40d 8 hitbox.height = 2;
el17sm 13:d04a6caba40d 9 position.x = pos_x;
el17sm 13:d04a6caba40d 10 position.y = pos_y;
el17sm 13:d04a6caba40d 11 sprite_size.width = 2;
el17sm 13:d04a6caba40d 12 sprite_size.height = 2;
el17sm 13:d04a6caba40d 13 sprite_size.offset_x = 0;
el17sm 13:d04a6caba40d 14 sprite_size.offset_y = 0;
el17sm 13:d04a6caba40d 15 direction = dir;
el17sm 13:d04a6caba40d 16 }
el17sm 13:d04a6caba40d 17
el17sm 13:d04a6caba40d 18 void Bullets::move(float speed, float unused){
el17sm 14:3361879490b2 19 if (direction == 0){
el17sm 14:3361879490b2 20 position.y -= speed;
el17sm 14:3361879490b2 21 }
el17sm 14:3361879490b2 22 else if (direction == 1){
el17sm 14:3361879490b2 23 position.x += speed;
el17sm 14:3361879490b2 24 }
el17sm 14:3361879490b2 25 else if (direction == 2){
el17sm 14:3361879490b2 26 position.y += speed;
el17sm 14:3361879490b2 27 }
el17sm 14:3361879490b2 28 else if (direction == 3){
el17sm 14:3361879490b2 29 position.x -= speed;
el17sm 14:3361879490b2 30 }
el17sm 13:d04a6caba40d 31 }
el17sm 13:d04a6caba40d 32
el17sm 13:d04a6caba40d 33 int * Bullets::get_frame(){
el17sm 13:d04a6caba40d 34 return (int *) bullets_sprite;
el17sm 14:3361879490b2 35 }
el17sm 14:3361879490b2 36
el17sm 14:3361879490b2 37 bool Bullets::out_of_bounds_check(){
el17sm 14:3361879490b2 38 if (matrix_collision_test(position.x, position.y, 0)){
el17sm 14:3361879490b2 39 return true;
el17sm 14:3361879490b2 40 }
el17sm 14:3361879490b2 41 else if ((!(0 < position.x < 84)) || (!(0 < position.y < 48))){
el17sm 14:3361879490b2 42 return true;
el17sm 14:3361879490b2 43 }
el17sm 14:3361879490b2 44 return false;
el17sm 13:d04a6caba40d 45 }