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@12:8178fad5e660, 2015-05-08 (annotated)
- Committer:
- Siriagus
- Date:
- Fri May 08 23:51:26 2015 +0000
- Revision:
- 12:8178fad5e660
- Parent:
- 11:adb68da98262
- Child:
- 13:7ab71c7c311b
Added template drawImage function which can draw images of any dimension.
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 | 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 | 12:8178fad5e660 | 15 | int x, y; /// Position of entity |
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 | 9:da608ae65df9 | 22 | }; |
Siriagus | 9:da608ae65df9 | 23 | |
Siriagus | 9:da608ae65df9 | 24 | #endif |