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: N5110 PinDetect PowerControl mbed
Entity.h
00001 #ifndef ENTITY_H 00002 #define ENTITY_H 00003 /// @file Entity.h 00004 00005 /** An entity represents a movable character, such as the player, enemies etc. 00006 * Note that the entity class does not contain the sprite (image) of the entity. 00007 * Different sprites are given as 2D const int arrays in 00008 * OBS! The entity's dimensions should be the same as the width and height or else this will lead to undefined behaviour! 00009 */ 00010 class Entity 00011 { 00012 public: 00013 Entity() {x = y = width = height = vx = vy = 0; facingLeft = true; onGround = false; dead = false;} 00014 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;} 00015 00016 /// Position of entity (origin: left upper corner) 00017 int x, y; 00018 00019 /// Velocity of entity 00020 int vx, vy; 00021 00022 /// Width of entity 00023 int width; 00024 00025 /// Height of entity 00026 int height; 00027 00028 /// True if the entity is facing left 00029 bool facingLeft; 00030 /// True if entity is standing on the ground. 00031 bool onGround; 00032 00033 /// True if enemy is dead. 00034 bool dead; 00035 00036 /// Returns x-position of the right edge 00037 int getRight() {return x + width - 1;} 00038 00039 /// Returns y-position of the bottom edge 00040 int getBottom() {return y + height - 1;} 00041 }; 00042 00043 #endif
Generated on Tue Jul 12 2022 21:59:47 by
1.7.2