void GameView::CollideWithWall(Monster& monster) { const math::Vector3& vel = monster.GetVelocity(); if (monster.GetPosition().x < 0 || monster.GetPosition().x > width) { monster.SetVelocity(-vel.x, vel.y, vel.z); } if (monster.GetPosition().y < 0 || monster.GetPosition().y > height) { monster.SetVelocity(vel.x, -vel.y, vel.z); } }
void FastWorldDrawer::paintMonsters() { std::list<Monster *>::const_iterator it; for (it = manager->GetModel()->GetMonsters().begin(); it != manager->GetModel()->GetMonsters().end(); ++it) { glPushMatrix(); Monster *monster = *it; glTranslatef(monster->GetPosition().getX(), monster->GetPosition().getY(), 0); glRotatef(monster->GetAngle() * 180 / M_PI, 0, 0, 1); glCallList(monsterListIndex); glPopMatrix(); } }
void GameView::CollideWithCatchers(Monster& monster) { if (monster.IsAlive()) { std::vector<CatchersPtr>::iterator it = m_catchers.begin(); while (it != m_catchers.end()) { if (*it && (*it)->IsAlive()) { bool result = CollideWithCatcher(monster, *(*it)); if (result) { monster.SetState(Monster::StateDieing); SpawnCatcher(monster.GetPosition()); ++m_catchedMonsters; MM::manager.PlaySample("scream_01", false, .2f); break; } } ++it; } } }
bool GameView::CollideWithCatcher(Monster& monster, Catcher& cathcer) { IPoint deltaPoint = monster.GetPosition() - cathcer.GetPosition(); float distance = std::sqrt(deltaPoint.x * deltaPoint.x + deltaPoint.y * deltaPoint.y); return distance < monster.Height() * 0.5f + cathcer.GetRadius(); }