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 N5110 ShiftReg PinDetect
Entity.h@18:709ea375b0df, 2015-05-11 (annotated)
- Committer:
- Siriagus
- Date:
- Mon May 11 04:40:23 2015 +0000
- Revision:
- 18:709ea375b0df
- Parent:
- 17:d6a3b29cab31
Fixed some formatting errors in documentation.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Siriagus | 9:da608ae65df9 | 1 | #ifndef ENTITY_H |
Siriagus | 9:da608ae65df9 | 2 | #define ENTITY_H |
Siriagus | 16:caf613d5b85e | 3 | /// @file Entity.h |
Siriagus | 9:da608ae65df9 | 4 | |
Siriagus | 12:8178fad5e660 | 5 | /** An entity represents a movable character, such as the player, enemies etc. |
Siriagus | 12:8178fad5e660 | 6 | * Note that the entity class does not contain the sprite (image) of the entity. |
Siriagus | 12:8178fad5e660 | 7 | * Different sprites are given as 2D const int arrays in |
Siriagus | 12:8178fad5e660 | 8 | * OBS! The entity's dimensions should be the same as the width and height or else this will lead to undefined behaviour! |
Siriagus | 12:8178fad5e660 | 9 | */ |
Siriagus | 9:da608ae65df9 | 10 | class Entity |
Siriagus | 9:da608ae65df9 | 11 | { |
Siriagus | 9:da608ae65df9 | 12 | public: |
Siriagus | 17:d6a3b29cab31 | 13 | Entity() {x = y = width = height = vx = vy = 0; facingLeft = true; onGround = false; dead = false;} |
Siriagus | 17:d6a3b29cab31 | 14 | Entity(int x, int y, int w = 0, int h = 0) : x(x), y(y), width(w), height(h) {vx = vy = 0; facingLeft = true; onGround = false; dead = false;} |
Siriagus | 9:da608ae65df9 | 15 | |
Siriagus | 18:709ea375b0df | 16 | /// Position of entity (origin: left upper corner) |
Siriagus | 18:709ea375b0df | 17 | int x, y; |
Siriagus | 18:709ea375b0df | 18 | |
Siriagus | 18:709ea375b0df | 19 | /// Velocity of entity |
Siriagus | 18:709ea375b0df | 20 | int vx, vy; |
Siriagus | 18:709ea375b0df | 21 | |
Siriagus | 18:709ea375b0df | 22 | /// Width of entity |
Siriagus | 18:709ea375b0df | 23 | int width; |
Siriagus | 9:da608ae65df9 | 24 | |
Siriagus | 18:709ea375b0df | 25 | /// Height of entity |
Siriagus | 18:709ea375b0df | 26 | int height; |
Siriagus | 18:709ea375b0df | 27 | |
Siriagus | 18:709ea375b0df | 28 | /// True if the entity is facing left |
Siriagus | 18:709ea375b0df | 29 | bool facingLeft; |
Siriagus | 18:709ea375b0df | 30 | /// True if entity is standing on the ground. |
Siriagus | 18:709ea375b0df | 31 | bool onGround; |
Siriagus | 18:709ea375b0df | 32 | |
Siriagus | 18:709ea375b0df | 33 | /// True if enemy is dead. |
Siriagus | 17:d6a3b29cab31 | 34 | bool dead; |
Siriagus | 13:7ab71c7c311b | 35 | |
Siriagus | 18:709ea375b0df | 36 | /// Returns x-position of the right edge |
Siriagus | 18:709ea375b0df | 37 | int getRight() {return x + width - 1;} |
Siriagus | 13:7ab71c7c311b | 38 | |
Siriagus | 18:709ea375b0df | 39 | /// Returns y-position of the bottom edge |
Siriagus | 18:709ea375b0df | 40 | int getBottom() {return y + height - 1;} |
Siriagus | 9:da608ae65df9 | 41 | }; |
Siriagus | 9:da608ae65df9 | 42 | |
Siriagus | 9:da608ae65df9 | 43 | #endif |