Code:#include "mage.h" #include "fireball.h" #include "level.h" Mage::Mage(Level *l, DrawEngine *de, int s_index, float x, float y, int lives) : Character(l, de, s_index, x, y, lives) { classID = MAGE_CLASSID; } bool Mage::keyPress(char c) { bool val = Character::keyPress(c); if (val == false) { if (c == keys.attack) { castSpell(); return true; } } return false; } void Mage::castSpell(void) { if (isValidMove((int)pos.x + facing.x, (int)pos.y + facing.y)) { Fireball *temp = new Fireball(lvl, dengine, SPRITE_FIREBALL, (int)pos.x + facing.x, (int)pos.y + facing.y, facing.x, facing.y); lvl->addNPC((Sprite *)temp); } }




Reply With Quote