aboutsummaryrefslogtreecommitdiffstats
path: root/include/entities.hpp
diff options
context:
space:
mode:
authordrumsetmonkey <abelleisle@roadrunner.com>2016-04-13 08:47:22 -0400
committerdrumsetmonkey <abelleisle@roadrunner.com>2016-04-13 08:47:22 -0400
commit8b0f74445b509d8e59ec89854f2e149ad1948d4e (patch)
treece7e6a7a62468ed88e885d1fff64e72eb18db433 /include/entities.hpp
parent51f57a9eb06cd0a4a967915ee60a323fc85fafba (diff)
parentfa4b6e00fd204998f6011420bdad60477b7a2f12 (diff)
Merge branch 'master' of https://github.com/tcsullivan/gamedev
Diffstat (limited to 'include/entities.hpp')
-rw-r--r--include/entities.hpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/include/entities.hpp b/include/entities.hpp
index 5ab4066..6cd5731 100644
--- a/include/entities.hpp
+++ b/include/entities.hpp
@@ -13,6 +13,7 @@
#define NPCp(n) ((NPC *)n)
#define Structurep(n) ((Structures *)n)
#define Mobp(n) ((Mob *)n)
+#define Objectp(n) ((Object *)n)
#define PLAYER_INV_SIZE 43 // The size of the player's inventory
#define NPC_INV_SIZE 3 // Size of an NPC's inventory
@@ -102,18 +103,18 @@ public:
glTexCoord2f(.25*index.x, .125*index.y); glVertex2i(loc.x, loc.y + width);
glEnd();
}
- void update( float _gravity, float ground_y ) {
+ void update(float _gravity, float ground_y) {
// handle ground collision
- if ( loc.y < ground_y ) {
+ if (loc.y < ground_y) {
loc.y = ground_y;
- if ( bounce ) {
+ if (bounce) {
vel.y *= -0.2f;
vel.x /= 4;
} else {
vel.x = vel.y = 0;
canMove = false;
}
- } else if ( gravity && vel.y > -1 )
+ } else if (gravity && vel.y > -1)
vel.y -= _gravity * deltaTime;
}
bool kill(float delta){
@@ -188,6 +189,9 @@ public:
void follow(Entity *e);
+ bool isNear(Entity e);
+ bool isInside(vec2 coord) const;
+
virtual ~Entity(){}
};