void Items::useSword() { //sword script // Check if any entity other than the player is colliding with the line/sword //draw the line where the player is facing //check if any entity is colliding with it Room* tempRoom; tempRoom = player->getCurrentRoom(); float tempAngle =( player->getAngle() - 90) * (V2D_PI / 180.0f); V2DF swordPos(cos(tempAngle), sin(tempAngle)); V2DF tempColPos; swordPos.normalize(); swordPos.multiply(40); swordPos.add(player->getPosition()); for(int i = 0; i < tempRoom->EnemyCount(); i++) { if(swordPos.lineCrossesCircle(swordPos, player->getPosition(), tempRoom->getEnemy(i)->getPosition(), 16,tempColPos)) { // player->hit = 'Y'; tempRoom->getEnemy(i)->takeDmg(10); break; } /* else { player->hit = 'N'; } */ } }
void Items::updateBomb(float dT) { // update cooldown of explosion // CoolDownCtrl(dT, explosion); //if bomb is activated //set timer //blow up after timer is done //check for collisions when it blows up Room* tempRoom; tempRoom = player->getCurrentRoom(); if(bombState == 1) { CoolDownCtrl(dT, bombCldwn); if(bombCldwn.active == false) { for(int i = 0; i < tempRoom->EnemyCount(); i++) { if(tempRoom->getEnemy(i)->collisionCheck(&bomb, false) ) { //do damage to enemy here tempRoom->getEnemy(i)->takeDmg(30); } } bombState = 0; // explosion.active = true; } } }
void Items::boomCollision() { Room* tempRoom; tempRoom = player->getCurrentRoom(); for(int i = 0; i < tempRoom->EnemyCount(); i++) { if(tempRoom->getEnemy(i)->collisionCheck(&bomb,false) != NONE) { //do damage to enemy here tempRoom->getEnemy(i)->takeDmg(30); } } }