aboutsummaryrefslogtreecommitdiffstats
path: root/src/mob.cpp
diff options
context:
space:
mode:
authordrumsetmonkey <abelleisle@roadrunner.com>2016-05-18 08:17:59 -0400
committerdrumsetmonkey <abelleisle@roadrunner.com>2016-05-18 08:17:59 -0400
commit72941038ae15ed524e2a878d087d98bc97e946b4 (patch)
treec5609ec3994c5d993d1589696cd886a9592708dc /src/mob.cpp
parentd27a975710cf7ef02f755ef768f133e19df69fa5 (diff)
parente1def1b4167156da12fa30baac3b3ccc2d00d74c (diff)
Z INDEXING
Diffstat (limited to 'src/mob.cpp')
-rw-r--r--src/mob.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/mob.cpp b/src/mob.cpp
index db0b88a..1f998f7 100644
--- a/src/mob.cpp
+++ b/src/mob.cpp
@@ -39,6 +39,12 @@ void Page::act(void)
}
}
+void Page::onHit(unsigned int _health)
+{
+ (void)_health;
+ act();
+}
+
bool Page::bindTex(void)
{
glActiveTexture(GL_TEXTURE0);
@@ -72,6 +78,11 @@ void Door::act(void)
{
}
+void Door::onHit(unsigned int _health)
+{
+ (void)_health;
+}
+
bool Door::bindTex(void)
{
glActiveTexture(GL_TEXTURE0);
@@ -124,6 +135,11 @@ void Cat::act(void)
}
}
+void Cat::onHit(unsigned int _health)
+{
+ health += _health;
+}
+
bool Cat::bindTex(void)
{
glActiveTexture(GL_TEXTURE0);
@@ -148,6 +164,10 @@ Rabbit::Rabbit(void) : Mob()
tex = TextureIterator({"assets/rabbit.png", "assets/rabbit1.png"});
actCounterInitial = randGet() % 240 + 15;
actCounter = 1;
+
+ drop = {
+ std::make_tuple("Dank MayMay", 5, 1.00f)
+ };
}
void Rabbit::act(void)
@@ -170,6 +190,11 @@ void Rabbit::act(void)
}
}
+void Rabbit::onHit(unsigned int _health)
+{
+ takeHit(_health, 600);
+}
+
bool Rabbit::bindTex(void)
{
glActiveTexture(GL_TEXTURE0);
@@ -219,6 +244,11 @@ void Bird::act(void)
vel.x = direction ? -0.3f : 0.3f;
}
+void Bird::onHit(unsigned int _health)
+{
+ takeHit(_health, 1000);
+}
+
bool Bird::bindTex(void)
{
glActiveTexture(GL_TEXTURE0);
@@ -292,6 +322,11 @@ void Trigger::act(void)
}
}
+void Trigger::onHit(unsigned int _health)
+{
+ (void)_health;
+}
+
bool Trigger::bindTex(void)
{
return false;
@@ -347,3 +382,18 @@ void Mob::ride(Entity *e)
else
rider = e;
}
+
+void Mob::onDeath(void)
+{
+ vec2 q = vec2 {player->loc.x, game::SCREEN_HEIGHT - 100.0f};
+
+ ui::putTextL(q, "Player got: ");
+
+ for (const auto &d : drop) {
+ if ((randGet() % 100) < std::get<float>(d) * 100.0f) {
+ q.y -= 20;
+ ui::putTextL(q, "%d x %s", std::get<unsigned int>(d), std::get<std::string>(d).c_str());
+ player->inv->addItem(std::get<std::string>(d), std::get<unsigned int>(d));
+ }
+ }
+}