Initial boss fight in demo game
This commit is contained in:
@@ -4,7 +4,7 @@ final double _gameSizeWidth = 320.0;
|
||||
double _gameSizeHeight = 320.0;
|
||||
|
||||
final double _chunkSpacing = 640.0;
|
||||
final int _chunksPerLevel = 8;
|
||||
final int _chunksPerLevel = 9;
|
||||
|
||||
final bool _drawDebug = false;
|
||||
|
||||
@@ -210,6 +210,8 @@ class GameDemoNode extends NodeWithSize {
|
||||
_objectFactory.addEnemyScoutSwarm(4 + level * 2, yPos);
|
||||
} else if (part == 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 {
|
||||
|
||||
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 {
|
||||
void update(double dt) {
|
||||
_countDown -= 1;
|
||||
if (_countDown <= 0) {
|
||||
print("SHOOT!!");
|
||||
|
||||
// Shoot at player
|
||||
EnemyLaser laser = new EnemyLaser(f, rotation, 5.0, new Color(0xffffe38e));
|
||||
laser.position = position;
|
||||
@@ -409,8 +407,6 @@ class EnemyLaser extends Obstacle {
|
||||
|
||||
double rad = radians(rotation);
|
||||
_movement = new Offset(math.cos(rad) * speed, math.sin(rad) * speed);
|
||||
|
||||
print("LASER!!");
|
||||
}
|
||||
|
||||
Sprite _sprt;
|
||||
@@ -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 {
|
||||
Collectable(GameObjectFactory f) : super(f) {
|
||||
canDamageShip = false;
|
||||
|
||||
@@ -36,6 +36,8 @@ class PlayerState extends Node {
|
||||
|
||||
double _scrollSpeedTarget = normalScrollSpeed;
|
||||
|
||||
EnemyBoss boss;
|
||||
|
||||
Sprite _sprtBgScore;
|
||||
ScoreDisplay _scoreDisplay;
|
||||
Sprite _sprtBgCoins;
|
||||
@@ -87,7 +89,7 @@ class PlayerState extends Node {
|
||||
} else if (type == PowerUpType.speedLaser) {
|
||||
_speedLaserFrames += 300;
|
||||
} else if (type == PowerUpType.speedBoost) {
|
||||
_speedBoostFrames += 300;
|
||||
_speedBoostFrames += 150;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,10 +124,18 @@ class PlayerState extends Node {
|
||||
if (_speedBoostFrames > 0) _speedBoostFrames--;
|
||||
|
||||
// Update speed
|
||||
if (speedBoostActive)
|
||||
_scrollSpeedTarget = normalScrollSpeed * 6.0;
|
||||
else
|
||||
_scrollSpeedTarget = normalScrollSpeed;
|
||||
if (boss != null) {
|
||||
Point globalBossPos = boss.convertPointToBoxSpace(Point.origin);
|
||||
if (globalBossPos.y > (_gameSizeHeight - 400.0))
|
||||
_scrollSpeedTarget = 0.0;
|
||||
else
|
||||
_scrollSpeedTarget = normalScrollSpeed;
|
||||
} else {
|
||||
if (speedBoostActive)
|
||||
_scrollSpeedTarget = normalScrollSpeed * 6.0;
|
||||
else
|
||||
_scrollSpeedTarget = normalScrollSpeed;
|
||||
}
|
||||
|
||||
scrollSpeed = GameMath.filter(scrollSpeed, _scrollSpeedTarget, 0.1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user