diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2016-04-28 11:46:17 -0400 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2016-04-28 11:46:17 -0400 |
commit | 62df9319f06bb52da8878522117ebe85fc5226b5 (patch) | |
tree | c5b2543bbce0463eeef5d0921e41765d8e6d9dc7 /src/items.cpp | |
parent | e2fb36d5da705278fb84246400945f430794d5e7 (diff) | |
parent | 68cb663a370747c325eeeeea66cca86803e4b8e5 (diff) |
Merge branch 'master' of https://github.com/tcsullivan/gamedev
Diffstat (limited to 'src/items.cpp')
-rw-r--r-- | src/items.cpp | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/src/items.cpp b/src/items.cpp new file mode 100644 index 0000000..403c49e --- /dev/null +++ b/src/items.cpp @@ -0,0 +1,124 @@ +#include <inventory.hpp> +#include <entities.hpp> + +extern Player *player; + +/************************************************************************************ +* GLOBAL * +************************************************************************************/ + +/************************************************** +* USE ITEM * +**************************************************/ + +int BaseItem::useItem() +{ + return 0; +} + +int Sword::useItem() +{ + std::cout << "Swing!" << std::endl; + if (player->left) + rotation += 10.0f; + else + rotation -= 10.0f; + return 0; +} + +int Bow::useItem() +{ + return 0; +} + +// TODO chance to hurt +int RawFood::useItem() +{ + return 0; +} + +int Food::useItem() +{ + std::cout << "Yum!" << std::endl; + return 0; +} + + +/************************************************** +* CLONE * +**************************************************/ + +BaseItem* BaseItem::clone() +{ + return new BaseItem(*this); +} + +Sword* Sword::clone() +{ + return new Sword(*this); +} + +Bow* Bow::clone() +{ + return new Bow(*this); +} + +Food* Food::clone() +{ + return new Food(*this); +} + +RawFood* RawFood::clone() +{ + return new RawFood(*this); +} + +/************************************************************************************ +* ITEM SPECIFIC * +************************************************************************************/ + +/************************************************** +* ITEM * +**************************************************/ + +Item::~Item() +{ + delete tex; +} + +GLuint Item::rtex() +{ + return tex->image[0]; +} + +GLuint Item::rtex(int n) +{ + return tex->image[n]; +} + +/************************************************** +* SWORD * +**************************************************/ + +float Sword::getDamage() +{ + return damage; +} + +/************************************************** +* BOW * +**************************************************/ + +float Bow::getDamage() +{ + return damage; +} + +/************************************************** +* FOODS * +**************************************************/ + +float RawFood::getHealth() +{ + return health; +} |