Esempio n. 1
0
void sv::ObstacleManager::UpdateLevel(ulong deltaTime)
{
	m_PassedTime += deltaTime;
	if(m_PassedTime > SPAWN_TIME_OB)
	{
		m_PassedTime -= SPAWN_TIME_OB;
		m_Step ++;
		if(m_Step == m_LevelSize)
			m_Step = 0;
		
		ObstacleMsg obstacleMsg;
		bool obstacleCreated = false;

		for(uchar i=0; i<GetGrid()->GetNumberLanes(); ++i)
		{
			if(m_Level[m_Step][i] != ' ')
			{
				uchar category = m_Level[m_Step][i] - 'a' +1;
				Obstacle* ob = CreateObstacle(category, i);
				obstacleMsg.AddObstacle(ob->GetId(), category, ob->GetPos());
				obstacleCreated = true;
			}
		}

		if(obstacleCreated)
			GetGame()->SendMsg(&obstacleMsg);
	}
}
Esempio n. 2
0
void sv::ObstacleManager::Update(ulong deltaTime)
{
	Iterator iter = First();
	while(iter)
	{
		Obstacle* obstacle = Get(iter);
		iter = Next(iter);

		obstacle->Update(deltaTime);
		if( obstacle->IsEdge() )
			HandleCollision(obstacle);
		if( obstacle->GetPos() == Grid::InvalidPos )
			DeleteObstacle(obstacle);
	}

	UpdateLevel(deltaTime);
}