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 Class Reference
Entity Abstract Class. More...
#include <Entity.h>
Inherited by Bullets, Headless, Health, Player, Skull, Snake, and Walls.
Public Member Functions | |
| virtual void | move (float x_value, float y_value, char *map, bool *doorways)=0 |
| a virtual function movement of the entity to be inherited | |
| virtual void | take_damage (int damage)=0 |
| a virtual function of the action when taking damage to be inherited | |
| virtual void | draw (N5110 &lcd)=0 |
| a virtual function of drawing the entity to be inherited | |
| void | undo_move_x (bool condition) |
| a function to undo entity's movement in the x direction if condition is true | |
| void | undo_move_y (bool condition) |
| a function to undo entity's movement in the y direction if condition is true | |
| void | update_prev_pos () |
| updates the _prev_pos into _position | |
| bool | entity_to_map_collision_test (float pos_x, float pos_y, char *two_d_map, bool *doorways) |
| checks if the entity collides the map | |
| void | set_position (float x, float y) |
| mutates position of the entity to x and y | |
| void | position_add_x (float change_x) |
| adds change_x onto x-position of the entity | |
| void | position_add_y (float change_y) |
| adds change_y onto y-position of the entity | |
| int | get_hp_drop_chance () |
| gets the entity's chance to drop a health | |
| int | get_hitbox_width () |
| gets the entity's hitbox width | |
| int | get_hitbox_height () |
| gets the entity's hitbox height | |
| int | get_face () |
| gets the entity's face | |
| int | get_sprite_width () |
| gets the entity's sprite width | |
| int | get_sprite_height () |
| gets the entity's sprite height | |
| int | get_offset_x () |
| gets the entity's sprite x-offset | |
| int | get_offset_y () |
| gets the entity's sprite y-offset | |
| int | get_pos_x () |
| gets the entity's x-position | |
| int | get_pos_y () |
| gets the entity's y-position | |
| int | get_prev_pos_x () |
| gets the entity's previous x-position | |
| int | get_prev_pos_y () |
| gets the entity's previous y-position | |
| int | get_attack () |
| gets the entity's attack | |
| int | get_hp () |
| gets the entity's hp | |
| float | get_velocity () |
| gets the entity's velocity | |
Protected Attributes | |
| Hitbox | _hitbox |
| A struct containing hitbox data for the entity width and height. | |
| SpriteSize | _sprite_size |
| A struct containing sprite size data for the entity, to be used when drawing sprites on top of their hitboxes sprite width, sprite height, sprite offset x from hitbox, sprite offset y from hitbox. | |
| Position | _position |
| A struct containing the position of the entity, this position is the top-left corner of the hitbox. | |
| Position | _prev_pos |
| A struct containing the position of the entity one loop behind. | |
| FrameCount | _frame |
| A struct containing frame count, frame number and frame max. | |
| int | _hp |
| The health point of an entity. | |
| int | _attack |
| The damage the entity does if it attacks another entity. | |
| int | _face |
| The direction the entity is facing. | |
| float | _velocity |
| The speed the entity moves. | |
| int | _hp_drop_chance |
| The chance(out of 100) of dropping a heart when the entity is deleted. | |
Detailed Description
Entity Abstract Class.
- Date:
- May 2019
Definition at line 12 of file Entity.h.
Member Function Documentation
| virtual void draw | ( | N5110 & | lcd ) | [pure virtual] |
| bool entity_to_map_collision_test | ( | float | pos_x, |
| float | pos_y, | ||
| char * | two_d_map, | ||
| bool * | doorways | ||
| ) |
checks if the entity collides the map
- Parameters:
-
pos_x entity's x-position pos_y entity's y-position two_d_map the 2d map array that dictates where there are walls or empty space doorways an array that dictates which side of the wall has a doorway
- Returns:
- true if entity collide with the map
Definition at line 21 of file Entity.cpp.
| int get_attack | ( | ) |
| int get_face | ( | ) |
| int get_hitbox_height | ( | ) |
| int get_hitbox_width | ( | ) |
| int get_hp | ( | ) |
| int get_hp_drop_chance | ( | ) |
gets the entity's chance to drop a health
- Returns:
- _hp_drop_chance
Definition at line 66 of file Entity.cpp.
| int get_offset_x | ( | ) |
gets the entity's sprite x-offset
- Returns:
- _sprite_size.offset_x
Definition at line 90 of file Entity.cpp.
| int get_offset_y | ( | ) |
gets the entity's sprite y-offset
- Returns:
- _sprite_size.offset_y
Definition at line 94 of file Entity.cpp.
| int get_pos_x | ( | ) |
| int get_pos_y | ( | ) |
| int get_prev_pos_x | ( | ) |
gets the entity's previous x-position
- Returns:
- _prev_pos.x
Definition at line 106 of file Entity.cpp.
| int get_prev_pos_y | ( | ) |
gets the entity's previous y-position
- Returns:
- _prev_pos.y
Definition at line 110 of file Entity.cpp.
| int get_sprite_height | ( | ) |
gets the entity's sprite height
- Returns:
- _sprite_size.height
Definition at line 86 of file Entity.cpp.
| int get_sprite_width | ( | ) |
| float get_velocity | ( | ) |
| virtual void move | ( | float | x_value, |
| float | y_value, | ||
| char * | map, | ||
| bool * | doorways | ||
| ) | [pure virtual] |
a virtual function movement of the entity to be inherited
- Parameters:
-
x_value either joystick x or player's x position y_value either joystick y or player's y position map the 2d map array that dictates where there are walls or empty space doorways an array that dictates which side of the wall has a doorway
Implemented in Skull, Health, Headless, Snake, Bullets, Player, and Walls.
| void position_add_x | ( | float | change_x ) |
adds change_x onto x-position of the entity
- Parameters:
-
change_x displacement x
Definition at line 56 of file Entity.cpp.
| void position_add_y | ( | float | change_y ) |
adds change_y onto y-position of the entity
- Parameters:
-
change_y displacement y
Definition at line 60 of file Entity.cpp.
| void set_position | ( | float | x, |
| float | y | ||
| ) |
mutates position of the entity to x and y
- Parameters:
-
x x-coordinate value y y-coordinate value
Definition at line 50 of file Entity.cpp.
| virtual void take_damage | ( | int | damage ) | [pure virtual] |
| void undo_move_x | ( | bool | condition ) |
a function to undo entity's movement in the x direction if condition is true
- Parameters:
-
condition a boolean statement
Definition at line 4 of file Entity.cpp.
| void undo_move_y | ( | bool | condition ) |
a function to undo entity's movement in the y direction if condition is true
- Parameters:
-
condition a boolean statement
Definition at line 10 of file Entity.cpp.
| void update_prev_pos | ( | ) |
updates the _prev_pos into _position
Definition at line 16 of file Entity.cpp.
Field Documentation
int _attack [protected] |
FrameCount _frame [protected] |
Hitbox _hitbox [protected] |
int _hp_drop_chance [protected] |
Position _position [protected] |
Position _prev_pos [protected] |
SpriteSize _sprite_size [protected] |
Generated on Tue Jul 19 2022 23:32:07 by
1.7.2