Andreas Garmannslund / Mbed 2 deprecated SimplePlatformGame

Dependencies:   N5110 PinDetect PowerControl mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Entity.h Source File

Entity.h

Go to the documentation of this file.
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