Hugo Hu / Mbed 2 deprecated BRAVEHEART

Dependencies:   mbed N5110 ShiftReg PinDetect

Committer:
Siriagus
Date:
Sat May 09 13:56:14 2015 +0000
Revision:
13:7ab71c7c311b
Parent:
12:8178fad5e660
Child:
15:d5eb13c4c1c6
Expanded functionallity of drawImage - inverse, flipX, flipY. Collision test for all entities. Added simple enemy.

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 9:da608ae65df9 3
Siriagus 12:8178fad5e660 4 /** An entity represents a movable character, such as the player, enemies etc.
Siriagus 12:8178fad5e660 5 * Note that the entity class does not contain the sprite (image) of the entity.
Siriagus 12:8178fad5e660 6 * Different sprites are given as 2D const int arrays in
Siriagus 12:8178fad5e660 7 * 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 8 */
Siriagus 9:da608ae65df9 9 class Entity
Siriagus 9:da608ae65df9 10 {
Siriagus 9:da608ae65df9 11 public:
Siriagus 11:adb68da98262 12 Entity() {x = y = width = height = vx = vy = 0; facingLeft = true; onGround = false;}
Siriagus 11:adb68da98262 13 Entity(int x, int y, int w, int h) : x(x), y(y), width(w), height(h) {vx = vy = 0; facingLeft = true; onGround = false;}
Siriagus 9:da608ae65df9 14
Siriagus 13:7ab71c7c311b 15 int x, y; /// Position of entity (origin: left upper corner)
Siriagus 12:8178fad5e660 16 int vx, vy; /// Velocity of entity
Siriagus 12:8178fad5e660 17 int width; /// Width of entity
Siriagus 12:8178fad5e660 18 int height; /// Height of entity
Siriagus 9:da608ae65df9 19
Siriagus 11:adb68da98262 20 bool facingLeft; /// True if the entity is facing left
Siriagus 12:8178fad5e660 21 bool onGround; /// True if entity is standing on the ground.
Siriagus 13:7ab71c7c311b 22
Siriagus 13:7ab71c7c311b 23 int getRight() {return x + width - 1;} /// Returns x-position of the right edge
Siriagus 13:7ab71c7c311b 24 int getBottom() {return y + height - 1;} /// Returns y-position of the bottom edge
Siriagus 13:7ab71c7c311b 25
Siriagus 9:da608ae65df9 26 };
Siriagus 9:da608ae65df9 27
Siriagus 9:da608ae65df9 28 #endif