A rouge-like rpg, heavily inspired on the binding of isaac. Running on a FRDM-K64F Mbed board. C++.

Dependencies:   mbed MotionSensor

Committer:
el17sm
Date:
Mon Apr 29 02:45:17 2019 +0000
Revision:
26:abbc19edc5c1
Parent:
24:26369d92a06a
Child:
27:a1b41626f57c
RoomEngine done, no test yet, Room h partial done;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el17sm 7:4aaa37a711a1 1 #include "Entity.h"
el17sm 7:4aaa37a711a1 2
el17sm 13:d04a6caba40d 3 // functions
el17sm 22:7abf4581bc9b 4 void Entity::undo_move_x(bool status_x)
el17sm 22:7abf4581bc9b 5 {
el17sm 22:7abf4581bc9b 6 if (status_x) {
el17sm 13:d04a6caba40d 7 position.x = prev_pos.x;
el17sm 13:d04a6caba40d 8 }
el17sm 13:d04a6caba40d 9 }
el17sm 22:7abf4581bc9b 10 void Entity::undo_move_y(bool status_y)
el17sm 22:7abf4581bc9b 11 {
el17sm 22:7abf4581bc9b 12 if (status_y) {
el17sm 13:d04a6caba40d 13 position.y = prev_pos.y;
el17sm 13:d04a6caba40d 14 }
el17sm 13:d04a6caba40d 15 }
el17sm 22:7abf4581bc9b 16 void Entity::update_prev_pos()
el17sm 22:7abf4581bc9b 17 {
el17sm 22:7abf4581bc9b 18 prev_pos = position;
el17sm 26:abbc19edc5c1 19 }
el17sm 7:4aaa37a711a1 20
el17sm 22:7abf4581bc9b 21 bool Entity::matrix_collision_test(float pos_x, float pos_y, int map_no)
el17sm 22:7abf4581bc9b 22 {
el17sm 22:7abf4581bc9b 23 for (int j = pos_y; j < (int)pos_y + hitbox.height; j++) {
el17sm 22:7abf4581bc9b 24 for(int i = pos_x; i < (int)pos_x + hitbox.width; i++) {
el17sm 13:d04a6caba40d 25 if ((j>=48) || (i>=84) || (j<0) || (i<0)) {}
el17sm 13:d04a6caba40d 26 else if ((level_map[0][j][i] == 1)) {
el17sm 13:d04a6caba40d 27 return true;
el17sm 13:d04a6caba40d 28 }
el17sm 13:d04a6caba40d 29 }
el17sm 13:d04a6caba40d 30 }
el17sm 13:d04a6caba40d 31 return false;
el17sm 13:d04a6caba40d 32 }
el17sm 13:d04a6caba40d 33
el17sm 13:d04a6caba40d 34 // mutators
el17sm 7:4aaa37a711a1 35
el17sm 24:26369d92a06a 36 void Entity::position_add_x(float change_x)
el17sm 24:26369d92a06a 37 {
el17sm 24:26369d92a06a 38 position.x += change_x;
el17sm 24:26369d92a06a 39 }
el17sm 24:26369d92a06a 40 void Entity::position_add_y(float change_y)
el17sm 24:26369d92a06a 41 {
el17sm 24:26369d92a06a 42 position.y += change_y;
el17sm 24:26369d92a06a 43 }
el17sm 24:26369d92a06a 44
el17sm 7:4aaa37a711a1 45 // accessors
el17sm 22:7abf4581bc9b 46 bool Entity::get_moving()
el17sm 22:7abf4581bc9b 47 {
el17sm 22:7abf4581bc9b 48 return moving;
el17sm 22:7abf4581bc9b 49 }
el17sm 22:7abf4581bc9b 50 int Entity::get_hitbox_width()
el17sm 22:7abf4581bc9b 51 {
el17sm 22:7abf4581bc9b 52 return hitbox.width;
el17sm 22:7abf4581bc9b 53 }
el17sm 22:7abf4581bc9b 54 int Entity::get_hitbox_height()
el17sm 22:7abf4581bc9b 55 {
el17sm 22:7abf4581bc9b 56 return hitbox.height;
el17sm 22:7abf4581bc9b 57 }
el17sm 22:7abf4581bc9b 58 int Entity::get_face()
el17sm 22:7abf4581bc9b 59 {
el17sm 22:7abf4581bc9b 60 return face;
el17sm 22:7abf4581bc9b 61 }
el17sm 22:7abf4581bc9b 62 int Entity::get_sprite_width()
el17sm 22:7abf4581bc9b 63 {
el17sm 22:7abf4581bc9b 64 return sprite_size.width;
el17sm 22:7abf4581bc9b 65 }
el17sm 22:7abf4581bc9b 66 int Entity::get_sprite_height()
el17sm 22:7abf4581bc9b 67 {
el17sm 22:7abf4581bc9b 68 return sprite_size.height;
el17sm 22:7abf4581bc9b 69 }
el17sm 22:7abf4581bc9b 70 int Entity::get_offset_x()
el17sm 22:7abf4581bc9b 71 {
el17sm 22:7abf4581bc9b 72 return sprite_size.offset_x;
el17sm 22:7abf4581bc9b 73 }
el17sm 22:7abf4581bc9b 74 int Entity::get_offset_y()
el17sm 22:7abf4581bc9b 75 {
el17sm 22:7abf4581bc9b 76 return sprite_size.offset_y;
el17sm 22:7abf4581bc9b 77 }
el17sm 22:7abf4581bc9b 78 int Entity::get_pos_x()
el17sm 22:7abf4581bc9b 79 {
el17sm 22:7abf4581bc9b 80 return position.x;
el17sm 22:7abf4581bc9b 81 }
el17sm 22:7abf4581bc9b 82 int Entity::get_pos_y()
el17sm 22:7abf4581bc9b 83 {
el17sm 22:7abf4581bc9b 84 return position.y;
el17sm 22:7abf4581bc9b 85 }
el17sm 22:7abf4581bc9b 86 int Entity::get_prev_pos_x()
el17sm 22:7abf4581bc9b 87 {
el17sm 22:7abf4581bc9b 88 return prev_pos.x;
el17sm 22:7abf4581bc9b 89 }
el17sm 22:7abf4581bc9b 90 int Entity::get_prev_pos_y()
el17sm 22:7abf4581bc9b 91 {
el17sm 22:7abf4581bc9b 92 return prev_pos.y;
el17sm 23:5a8f75e93508 93 }
el17sm 23:5a8f75e93508 94 int Entity::get_attack()
el17sm 23:5a8f75e93508 95 {
el17sm 23:5a8f75e93508 96 return attack;
el17sm 23:5a8f75e93508 97 }
el17sm 23:5a8f75e93508 98 int Entity::get_hp()
el17sm 23:5a8f75e93508 99 {
el17sm 23:5a8f75e93508 100 return hp;
el17sm 22:7abf4581bc9b 101 }