A rouge-like rpg, heavily inspired on the binding of isaac. Running on a FRDM-K64F Mbed board. C++.
Dependencies: mbed MotionSensor
Entity/Entity.cpp@20:6405835af6e2, 2019-04-25 (annotated)
- Committer:
- el17sm
- Date:
- Thu Apr 25 04:40:30 2019 +0000
- Revision:
- 20:6405835af6e2
- Parent:
- 14:3361879490b2
the true updated headless only functional game
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el17sm | 7:4aaa37a711a1 | 1 | #include "Entity.h" |
el17sm | 7:4aaa37a711a1 | 2 | |
el17sm | 13:d04a6caba40d | 3 | // functions |
el17sm | 13:d04a6caba40d | 4 | void Entity::undo_move_x(bool status_x){ |
el17sm | 13:d04a6caba40d | 5 | if (status_x){ |
el17sm | 13:d04a6caba40d | 6 | position.x = prev_pos.x; |
el17sm | 13:d04a6caba40d | 7 | } |
el17sm | 13:d04a6caba40d | 8 | } |
el17sm | 13:d04a6caba40d | 9 | void Entity::undo_move_y(bool status_y){ |
el17sm | 13:d04a6caba40d | 10 | if (status_y){ |
el17sm | 13:d04a6caba40d | 11 | position.y = prev_pos.y; |
el17sm | 13:d04a6caba40d | 12 | } |
el17sm | 13:d04a6caba40d | 13 | } |
el17sm | 20:6405835af6e2 | 14 | void Entity::update_prev_pos(){prev_pos = position;} |
el17sm | 7:4aaa37a711a1 | 15 | |
el17sm | 13:d04a6caba40d | 16 | bool Entity::matrix_collision_test(float pos_x, float pos_y, int map_no){ |
el17sm | 13:d04a6caba40d | 17 | for (int j = pos_y; j < (int)pos_y + hitbox.height; j++){ |
el17sm | 13:d04a6caba40d | 18 | for(int i = pos_x; i < (int)pos_x + hitbox.width; i++){ |
el17sm | 13:d04a6caba40d | 19 | if ((j>=48) || (i>=84) || (j<0) || (i<0)) {} |
el17sm | 13:d04a6caba40d | 20 | else if ((level_map[0][j][i] == 1)) { |
el17sm | 13:d04a6caba40d | 21 | return true; |
el17sm | 13:d04a6caba40d | 22 | } |
el17sm | 13:d04a6caba40d | 23 | } |
el17sm | 13:d04a6caba40d | 24 | } |
el17sm | 13:d04a6caba40d | 25 | return false; |
el17sm | 13:d04a6caba40d | 26 | } |
el17sm | 13:d04a6caba40d | 27 | |
el17sm | 13:d04a6caba40d | 28 | void Entity::take_damage(int damage){ |
el17sm | 13:d04a6caba40d | 29 | hp -= damage; |
el17sm | 13:d04a6caba40d | 30 | } |
el17sm | 13:d04a6caba40d | 31 | |
el17sm | 14:3361879490b2 | 32 | bool Entity::death_check(){ |
el17sm | 14:3361879490b2 | 33 | if (hp <= 0){ |
el17sm | 14:3361879490b2 | 34 | return true; |
el17sm | 14:3361879490b2 | 35 | } |
el17sm | 14:3361879490b2 | 36 | return false; |
el17sm | 14:3361879490b2 | 37 | } |
el17sm | 14:3361879490b2 | 38 | |
el17sm | 13:d04a6caba40d | 39 | // mutators |
el17sm | 7:4aaa37a711a1 | 40 | |
el17sm | 7:4aaa37a711a1 | 41 | // accessors |
el17sm | 7:4aaa37a711a1 | 42 | bool Entity::get_moving(){return moving;} |
el17sm | 10:1a3499f6b583 | 43 | int Entity::get_hitbox_width(){return hitbox.width;} |
el17sm | 10:1a3499f6b583 | 44 | int Entity::get_hitbox_height(){return hitbox.height;} |
el17sm | 7:4aaa37a711a1 | 45 | int Entity::get_face(){return face;} |
el17sm | 7:4aaa37a711a1 | 46 | int Entity::get_sprite_width(){return sprite_size.width;} |
el17sm | 7:4aaa37a711a1 | 47 | int Entity::get_sprite_height(){return sprite_size.height;} |
el17sm | 7:4aaa37a711a1 | 48 | int Entity::get_offset_x(){return sprite_size.offset_x;} |
el17sm | 7:4aaa37a711a1 | 49 | int Entity::get_offset_y(){return sprite_size.offset_y;} |
el17sm | 7:4aaa37a711a1 | 50 | int Entity::get_pos_x(){return position.x;} |
el17sm | 11:63e54f6e7939 | 51 | int Entity::get_pos_y(){return position.y;} |
el17sm | 11:63e54f6e7939 | 52 | int Entity::get_prev_pos_x(){return prev_pos.x;} |
el17sm | 11:63e54f6e7939 | 53 | int Entity::get_prev_pos_y(){return prev_pos.y;} |