Commit bdb8092f authored by Viktor Lidholt's avatar Viktor Lidholt

Merge pull request #1029 from vlidholt/master

Initial boss fight in demo game
parents ed8c1cb6 bd610f43
...@@ -4,7 +4,7 @@ final double _gameSizeWidth = 320.0; ...@@ -4,7 +4,7 @@ final double _gameSizeWidth = 320.0;
double _gameSizeHeight = 320.0; double _gameSizeHeight = 320.0;
final double _chunkSpacing = 640.0; final double _chunkSpacing = 640.0;
final int _chunksPerLevel = 8; final int _chunksPerLevel = 9;
final bool _drawDebug = false; final bool _drawDebug = false;
...@@ -210,6 +210,8 @@ class GameDemoNode extends NodeWithSize { ...@@ -210,6 +210,8 @@ class GameDemoNode extends NodeWithSize {
_objectFactory.addEnemyScoutSwarm(4 + level * 2, yPos); _objectFactory.addEnemyScoutSwarm(4 + level * 2, yPos);
} else if (part == 7) { } else if (part == 7) {
_objectFactory.addAsteroids(10 + level * 2, yPos, 0.0 + (level * 0.2).clamp(0.0, 0.7)); _objectFactory.addAsteroids(10 + level * 2, yPos, 0.0 + (level * 0.2).clamp(0.0, 0.7));
} else if (part == 8) {
_objectFactory.addBossFight(level, yPos);
} }
} }
......
...@@ -61,4 +61,13 @@ class GameObjectFactory { ...@@ -61,4 +61,13 @@ class GameObjectFactory {
level.addChild(obj); level.addChild(obj);
} }
void addBossFight(int l, double yPos) {
EnemyBoss boss = new EnemyBoss(this);
boss.position = new Point(0.0, yPos + _chunkSpacing / 2.0);
boss.setupActions();
level.addChild(boss);
playerState.boss = boss;
}
} }
...@@ -377,8 +377,6 @@ class EnemyDestroyer extends Obstacle { ...@@ -377,8 +377,6 @@ class EnemyDestroyer extends Obstacle {
void update(double dt) { void update(double dt) {
_countDown -= 1; _countDown -= 1;
if (_countDown <= 0) { if (_countDown <= 0) {
print("SHOOT!!");
// Shoot at player // Shoot at player
EnemyLaser laser = new EnemyLaser(f, rotation, 5.0, new Color(0xffffe38e)); EnemyLaser laser = new EnemyLaser(f, rotation, 5.0, new Color(0xffffe38e));
laser.position = position; laser.position = position;
...@@ -409,8 +407,6 @@ class EnemyLaser extends Obstacle { ...@@ -409,8 +407,6 @@ class EnemyLaser extends Obstacle {
double rad = radians(rotation); double rad = radians(rotation);
_movement = new Offset(math.cos(rad) * speed, math.sin(rad) * speed); _movement = new Offset(math.cos(rad) * speed, math.sin(rad) * speed);
print("LASER!!");
} }
Sprite _sprt; Sprite _sprt;
...@@ -421,6 +417,39 @@ class EnemyLaser extends Obstacle { ...@@ -421,6 +417,39 @@ class EnemyLaser extends Obstacle {
} }
} }
class EnemyBoss extends Obstacle {
EnemyBoss(GameObjectFactory f) : super(f) {
radius = 48.0;
_sprt = new Sprite(f.sheet["enemy_destroyer_1.png"]);
_sprt.scale = 0.64;
addChild(_sprt);
maxDamage = 40.0;
constraints = [new ConstraintRotationToNode(f.level.ship, dampening: 0.05)];
}
Sprite _sprt;
int _countDown = randomInt(120) + 240;
void update(double dt) {
_countDown -= 1;
if (_countDown <= 0) {
// Shoot at player
EnemyLaser laser = new EnemyLaser(f, rotation, 5.0, new Color(0xffffe38e));
laser.position = position;
f.level.addChild(laser);
_countDown = 60 + randomInt(120);
}
}
void destroy() {
f.playerState.boss = null;
super.destroy();
}
}
class Collectable extends GameObject { class Collectable extends GameObject {
Collectable(GameObjectFactory f) : super(f) { Collectable(GameObjectFactory f) : super(f) {
canDamageShip = false; canDamageShip = false;
......
...@@ -36,6 +36,8 @@ class PlayerState extends Node { ...@@ -36,6 +36,8 @@ class PlayerState extends Node {
double _scrollSpeedTarget = normalScrollSpeed; double _scrollSpeedTarget = normalScrollSpeed;
EnemyBoss boss;
Sprite _sprtBgScore; Sprite _sprtBgScore;
ScoreDisplay _scoreDisplay; ScoreDisplay _scoreDisplay;
Sprite _sprtBgCoins; Sprite _sprtBgCoins;
...@@ -87,7 +89,7 @@ class PlayerState extends Node { ...@@ -87,7 +89,7 @@ class PlayerState extends Node {
} else if (type == PowerUpType.speedLaser) { } else if (type == PowerUpType.speedLaser) {
_speedLaserFrames += 300; _speedLaserFrames += 300;
} else if (type == PowerUpType.speedBoost) { } else if (type == PowerUpType.speedBoost) {
_speedBoostFrames += 300; _speedBoostFrames += 150;
} }
} }
...@@ -122,10 +124,18 @@ class PlayerState extends Node { ...@@ -122,10 +124,18 @@ class PlayerState extends Node {
if (_speedBoostFrames > 0) _speedBoostFrames--; if (_speedBoostFrames > 0) _speedBoostFrames--;
// Update speed // Update speed
if (boss != null) {
Point globalBossPos = boss.convertPointToBoxSpace(Point.origin);
if (globalBossPos.y > (_gameSizeHeight - 400.0))
_scrollSpeedTarget = 0.0;
else
_scrollSpeedTarget = normalScrollSpeed;
} else {
if (speedBoostActive) if (speedBoostActive)
_scrollSpeedTarget = normalScrollSpeed * 6.0; _scrollSpeedTarget = normalScrollSpeed * 6.0;
else else
_scrollSpeedTarget = normalScrollSpeed; _scrollSpeedTarget = normalScrollSpeed;
}
scrollSpeed = GameMath.filter(scrollSpeed, _scrollSpeedTarget, 0.1); scrollSpeed = GameMath.filter(scrollSpeed, _scrollSpeedTarget, 0.1);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment