Hugo Hu / Mbed 2 deprecated BRAVEHEART

Dependencies:   mbed N5110 ShiftReg PinDetect

Committer:
Siriagus
Date:
Mon May 11 03:52:18 2015 +0000
Revision:
17:d6a3b29cab31
Parent:
16:caf613d5b85e
Child:
18:709ea375b0df
Added sound effects ++

Who changed what in which revision?

UserRevisionLine numberNew 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 13:7ab71c7c311b 16 int x, y; /// Position of entity (origin: left upper corner)
Siriagus 12:8178fad5e660 17 int vx, vy; /// Velocity of entity
Siriagus 12:8178fad5e660 18 int width; /// Width of entity
Siriagus 12:8178fad5e660 19 int height; /// Height of entity
Siriagus 9:da608ae65df9 20
Siriagus 11:adb68da98262 21 bool facingLeft; /// True if the entity is facing left
Siriagus 12:8178fad5e660 22 bool onGround; /// True if entity is standing on the ground.
Siriagus 17:d6a3b29cab31 23 bool dead;
Siriagus 13:7ab71c7c311b 24
Siriagus 13:7ab71c7c311b 25 int getRight() {return x + width - 1;} /// Returns x-position of the right edge
Siriagus 13:7ab71c7c311b 26 int getBottom() {return y + height - 1;} /// Returns y-position of the bottom edge
Siriagus 13:7ab71c7c311b 27
Siriagus 9:da608ae65df9 28 };
Siriagus 9:da608ae65df9 29
Siriagus 9:da608ae65df9 30 #endif