Example #1
0
void ScenarioDefend::Update(double dt, bool multiplay)
{
	this->multiplay = multiplay;
	if (timer.GetTimeLeft() > 0){
		if (Enemy::enemyList.size() <= 0){//check for wave completion
			wave++;
			amountToSpawn += increment;

			SpawnEnemies();
			MoveEnemies();
		}
	}
	if (Enemy::enemyList.size() > 0){
		for (vector<Enemy*>::iterator it = Enemy::enemyList.begin(); it != Enemy::enemyList.end();){//check if enemies reached destination
			if ((*it)->reachedDestination){
				HP -= 1;
				if (HP <= 0){// LOSE
					stopScenario = true;
				}

				delete *it;
				it = Enemy::enemyList.erase(it);
			}
			else{
				it++;
			}
		}
	}
	if (timer.GetTimeLeft() <= 0 && Enemy::enemyList.size() <= 0){// WIN
		winScenario = true;
		stopScenario = true;
	}
}
Example #2
0
bool World::PredictWorld(const Action& action) {
	if (data_points_.empty() || enemies_.empty()) {
		return true;
	}
	auto closest_data_points = MoveEnemies();
	if (!PerfromHeroAction(action)) {
		return false;
	};
	CollectData(closest_data_points);
	return true;
}
Example #3
0
ScenarioDefend::ScenarioDefend(int health, double duration, int increment, bool multiplay)
{

	this->increment = increment;
	amountToSpawn = increment;
	HP = health;
	wave = 1;
	winScenario = false;
	timer.StartCountdown(duration);
	this->multiplay = multiplay;

	SpawnEnemies();
	MoveEnemies();
}
Example #4
0
void UpdateGameState(float deltaTime) {

	player.Move(deltaTime, SPEED);
	MoveEnemies(deltaTime);

	//draw sprites
	DrawSprite(player.iSpriteID);

	for (int i = 0; i < enemyArr1Length; i++) {
		for (int j = 0; j < enemyArr2Length; j++) {
			DrawSprite(alienShips[i][j].iSpriteID);
		}
	}

	DrawLine(0, 40, iScreenWidth, 40, SColour(0x00, 0xFC, 0x00, 0xFF)); //doesn't acctually draw anything?

	//drawstrings
	SetFont(pInvadersFont);
	DrawString("SCORE < 1 >", iScreenWidth * 0.025f, iScreenHeight - 2);
	DrawString("0000", iScreenWidth * 0.11f, iScreenHeight - 32);
	DrawString("HI-SCORE", iScreenWidth * 0.35f, iScreenHeight - 2);
	DrawString("0020", iScreenWidth * (0.05f + 0.35f), iScreenHeight - 32);
	DrawString("SCORE < 2 >", iScreenWidth * 0.65f, iScreenHeight - 2);
}
Example #5
0
void UpdateGameState(float deltaTime) {
	player.Fire(buttonDown);
	player.Move(deltaTime, 300.f);
	MoveEnemies(deltaTime);
	
}