void Enemy::update() { Animation::update(); SDL_Rect previousState = pos; if (!isPlaying)//If not going to die { pos.x += moveSpeed * direction.first; pos.y += moveSpeed * direction.second; } if (Physics::checkCollision(mms->curMap->mapCollider, pos)) { pos = previousState; direction.first = -direction.first; direction.second = -direction.second; } if ( mms->bomb != nullptr && mms->bomb->getInteraction(*this) == BombCharStatus::COLLISION ) { pos = previousState; direction.first = -direction.first; direction.second = -direction.second; } turnRandom(); if (getCurFrame() == noOfFrames - 1 ) { isDead = true; } }
/** * respondTurn * * Turns the robot a random amount */ void respondTurn(void) { turnRandom(300000,1800000); }