예제 #1
0
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);
	}
}
예제 #2
0
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();
    }

}
예제 #3
0
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;
		}
	}
}
예제 #4
0
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();
}