Skip to content

Commit

Permalink
Player starts at random place, boss starts at player last spot
Browse files Browse the repository at this point in the history
  • Loading branch information
dmacdonald committed Jan 29, 2012
1 parent 08d6dc0 commit 7f4ef4a
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions src/PlayState.as
Expand Up @@ -301,8 +301,22 @@ package
var enemy:Enemy;
var primaryAttribute:Class;
var attributeClass:Class;

var playerSpawnPointInt:int = Math.floor(FlxG.random() * spawnPoints.length - 1);
var playerSpawnPoint:FlxPoint = new FlxPoint(FlxG.width/ 2, FlxG.height / 2);;


for each (spawnPoint in spawnPoints)
{
if (spawnPoints.indexOf(spawnPoint) == playerSpawnPointInt)
{
if (FlxU.getDistance(spawnPoint, player.position) > 200)
{
playerSpawnPoint = spawnPoint;
continue;
}
}

primaryAttribute = PlayState.getRandomAttribute();

for (var i:int = 0; i < 10; ++i) {
Expand All @@ -326,7 +340,7 @@ package
enemies.add(enemy);
}
}
boss = new Enemy(300, 300, enemyBullets, true);
boss = new Enemy(player.x, player.y, enemyBullets, true);
boss.addAttributes(bossAttributes);
addEmitter(boss, 50);
enemies.add(boss);
Expand All @@ -341,8 +355,17 @@ package
bossHealthBar.trackParent(-8, -24);
add(bossHealthBar);

player.x = FlxG.width / 2;
player.y = FlxG.height / 2;
if (playerSpawnPoint != null)
{
player.x = playerSpawnPoint.x;
player.y = playerSpawnPoint.y;
}
else
{
player.x = FlxG.width / 2;
player.y = FlxG.height / 2;
}

player.health = Player.INITIAL_HEALTH;
player.addAttribute(new WeaponPistolAttribute);
player.color = 0xffffff;
Expand Down

0 comments on commit 7f4ef4a

Please sign in to comment.