Commit d79b3598 authored by Viktor Lidholt's avatar Viktor Lidholt

Improves on demo game balance and adds levels for lasers

parent 1c3831e8
......@@ -4,7 +4,7 @@ final double _gameSizeWidth = 320.0;
double _gameSizeHeight = 320.0;
final double _chunkSpacing = 640.0;
final int _chunksPerLevel = 6;
final int _chunksPerLevel = 8;
final bool _drawDebug = false;
......@@ -198,33 +198,39 @@ class GameDemoNode extends NodeWithSize {
lbl.position = new Point(0.0, yPos + _chunkSpacing / 2.0 - 150.0);
_level.addChild(lbl);
} else if (part == 1) {
_objectFactory.addAsteroids(10 + level * 4, 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 == 2) {
_objectFactory.addEnemyScoutSwarm(4 + level * 2, yPos);
} else if (part == 3) {
_objectFactory.addAsteroids(10 + level * 4, 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 == 4) {
_objectFactory.addEnemyDestroyerSwarm(2 + level, yPos);
} else if (part == 5) {
_objectFactory.addAsteroids(10 + level * 4, 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 == 6) {
_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));
}
}
void fire() {
Laser shot0 = new Laser(_objectFactory, -90.0);
int laserLevel = _objectFactory.playerState.laserLevel;
Laser shot0 = new Laser(_objectFactory, laserLevel, -90.0);
shot0.position = _level.ship.position + new Offset(17.0, -10.0);
_level.addChild(shot0);
Laser shot1 = new Laser(_objectFactory, -90.0);
Laser shot1 = new Laser(_objectFactory, laserLevel, -90.0);
shot1.position = _level.ship.position + new Offset(-17.0, -10.0);
_level.addChild(shot1);
if (_playerState.sideLaserActive) {
Laser shot2 = new Laser(_objectFactory, 0.0);
Laser shot2 = new Laser(_objectFactory, laserLevel, 0.0);
shot2.position = _level.ship.position + new Offset(17.0, -10.0);
_level.addChild(shot2);
Laser shot3 = new Laser(_objectFactory, 180.0);
Laser shot3 = new Laser(_objectFactory, laserLevel, 180.0);
shot3.position = _level.ship.position + new Offset(-17.0, -10.0);
_level.addChild(shot3);
}
......
......@@ -92,7 +92,7 @@ class LevelLabel extends GameObject {
canBeDamaged = false;
Label lbl = new Label(
"LEVEL $level",
"L E V E L $level",
new TextStyle(
textAlign: TextAlign.center,
color:new Color(0xffffffff),
......@@ -156,27 +156,54 @@ class Ship extends GameObject {
}
class Laser extends GameObject {
double impact = 1.0;
Laser(GameObjectFactory f, double r) : super(f) {
// Add sprite
_sprt = new Sprite(f.sheet["explosion_particle.png"]);
_sprt.scale = 0.5;
_sprt.colorOverlay = new Color(0xff95f4fb);
_sprt.transferMode = sky.TransferMode.plus;
_sprt.rotation = r + 90.0;
addChild(_sprt);
double impact = 0.0;
final List<Color> laserColors = [
new Color(0xff95f4fb),
new Color(0xff5bff35),
new Color(0xffff886c),
new Color(0xffffd012),
new Color(0xfffd7fff)
];
Laser(GameObjectFactory f, int level, double r) : super(f) {
// Game object properties
radius = 10.0;
removeLimit = 640.0;
canDamageShip = false;
canBeDamaged = false;
impact = 1.0 + level * 0.5;
// Offset for movement
_offset = new Offset(math.cos(radians(r)) * 10.0, math.sin(radians(r)) * 10.0);
// Drawing properties
rotation = r + 90.0;
int numLasers = level % 3 + 1;
Color laserColor = laserColors[(level ~/ 3) % laserColors.length];
// Add sprites
List<Sprite> sprites = [];
for (int i = 0; i < numLasers; i++) {
Sprite sprt = new Sprite(f.sheet["explosion_particle.png"]);
sprt.scale = 0.5;
sprt.colorOverlay = laserColor;
sprt.transferMode = sky.TransferMode.plus;
addChild(sprt);
sprites.add(sprt);
}
// Position the individual sprites
if (numLasers == 2) {
sprites[0].position = new Point(-3.0, 0.0);
sprites[1].position = new Point(3.0, 0.0);
} else if (numLasers == 3) {
sprites[0].position = new Point(-4.0, 0.0);
sprites[1].position = new Point(4.0, 0.0);
sprites[2].position = new Point(0.0, -2.0);
}
}
Sprite _sprt;
Offset _offset;
void move() {
......
......@@ -28,6 +28,8 @@ class PlayerState extends Node {
final SpriteSheet _sheetUI;
final SpriteSheet _sheetGame;
int laserLevel = 0;
Sprite _sprtBgScore;
ScoreDisplay _scoreDisplay;
Sprite _sprtBgCoins;
......
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