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
- Committer:
- el17sm
- Date:
- 2019-05-02
- Revision:
- 28:98848e6a77a2
- Parent:
- 27:a1b41626f57c
- Child:
- 29:6b8411bb040a
File content as of revision 28:98848e6a77a2:
#include "Entity.h" // Functions void Entity::undo_move_x(bool status_x) { if (status_x) { position.x = prev_pos.x; } } void Entity::undo_move_y(bool status_y) { if (status_y) { position.y = prev_pos.y; } } void Entity::update_prev_pos() { prev_pos = position; } bool Entity::matrix_collision_test(float pos_x, float pos_y, int * map) { for (int j = pos_y; j < (int)pos_y + hitbox.height; j++) { for(int i = pos_x; i < (int)pos_x + hitbox.width; i++) { if ((j>=screen_height) || (i>=screen_width) || (j<0) || (i<0)) {} // To allow movement towards outside of the map else if (*((map+j*screen_width)+i) == 1) { return true; } } } return false; } // mutators void Entity::set_position(float x, float y) { position.x = x; position.y = y; } void Entity::position_add_x(float change_x) { position.x += change_x; } void Entity::position_add_y(float change_y) { position.y += change_y; } // accessors bool Entity::get_moving() { return moving; } bool Entity::is_damaged_by_collision() { return _damage_self_upon_collision; } int Entity::get_hp_drop_chance() { return _hp_drop_chance; } int Entity::get_hitbox_width() { return hitbox.width; } int Entity::get_hitbox_height() { return hitbox.height; } int Entity::get_face() { return face; } int Entity::get_sprite_width() { return sprite_size.width; } int Entity::get_sprite_height() { return sprite_size.height; } int Entity::get_offset_x() { return sprite_size.offset_x; } int Entity::get_offset_y() { return sprite_size.offset_y; } int Entity::get_pos_x() { return position.x; } int Entity::get_pos_y() { return position.y; } int Entity::get_prev_pos_x() { return prev_pos.x; } int Entity::get_prev_pos_y() { return prev_pos.y; } int Entity::get_attack() { return attack; } int Entity::get_hp() { return hp; } float Entity::get_velocity() { return velocity; }