Commit fc6f91c2 authored by Viktor Lidholt's avatar Viktor Lidholt

Merge pull request #1024 from vlidholt/master

Improvements to demo game
parents 75a63e0b edbf5b73
...@@ -80,7 +80,6 @@ class GameDemoNode extends NodeWithSize { ...@@ -80,7 +80,6 @@ class GameDemoNode extends NodeWithSize {
PlayerState _playerState; PlayerState _playerState;
// Game properties // Game properties
double _scrollSpeed = 2.0;
double _scroll = 0.0; double _scroll = 0.0;
int _framesToFire = 0; int _framesToFire = 0;
...@@ -95,11 +94,11 @@ class GameDemoNode extends NodeWithSize { ...@@ -95,11 +94,11 @@ class GameDemoNode extends NodeWithSize {
void update(double dt) { void update(double dt) {
// Scroll the level // Scroll the level
_scroll = _level.scroll(_scrollSpeed); _scroll = _level.scroll(_playerState.scrollSpeed);
_starField.move(0.0, _scrollSpeed); _starField.move(0.0, _playerState.scrollSpeed);
_background.move(_scrollSpeed * 0.1); _background.move(_playerState.scrollSpeed * 0.1);
_nebula.move(_scrollSpeed); _nebula.move(_playerState.scrollSpeed);
// Add objects // Add objects
addObjects(); addObjects();
...@@ -226,11 +225,11 @@ class GameDemoNode extends NodeWithSize { ...@@ -226,11 +225,11 @@ class GameDemoNode extends NodeWithSize {
_level.addChild(shot1); _level.addChild(shot1);
if (_playerState.sideLaserActive) { if (_playerState.sideLaserActive) {
Laser shot2 = new Laser(_objectFactory, laserLevel, 0.0); Laser shot2 = new Laser(_objectFactory, laserLevel, -45.0);
shot2.position = _level.ship.position + new Offset(17.0, -10.0); shot2.position = _level.ship.position + new Offset(17.0, -10.0);
_level.addChild(shot2); _level.addChild(shot2);
Laser shot3 = new Laser(_objectFactory, laserLevel, 180.0); Laser shot3 = new Laser(_objectFactory, laserLevel, -135.0);
shot3.position = _level.ship.position + new Offset(-17.0, -10.0); shot3.position = _level.ship.position + new Offset(-17.0, -10.0);
_level.addChild(shot3); _level.addChild(shot3);
} }
......
...@@ -462,6 +462,7 @@ enum PowerUpType { ...@@ -462,6 +462,7 @@ enum PowerUpType {
shield, shield,
speedLaser, speedLaser,
sideLaser, sideLaser,
speedBoost,
} }
List<PowerUpType> _powerUpTypes = new List.from(PowerUpType.values); List<PowerUpType> _powerUpTypes = new List.from(PowerUpType.values);
......
...@@ -30,6 +30,12 @@ class PlayerState extends Node { ...@@ -30,6 +30,12 @@ class PlayerState extends Node {
int laserLevel = 0; int laserLevel = 0;
static const double normalScrollSpeed = 2.0;
double scrollSpeed = normalScrollSpeed;
double _scrollSpeedTarget = normalScrollSpeed;
Sprite _sprtBgScore; Sprite _sprtBgScore;
ScoreDisplay _scoreDisplay; ScoreDisplay _scoreDisplay;
Sprite _sprtBgCoins; Sprite _sprtBgCoins;
...@@ -80,12 +86,15 @@ class PlayerState extends Node { ...@@ -80,12 +86,15 @@ class PlayerState extends Node {
_sideLaserFrames += 300; _sideLaserFrames += 300;
} else if (type == PowerUpType.speedLaser) { } else if (type == PowerUpType.speedLaser) {
_speedLaserFrames += 300; _speedLaserFrames += 300;
} else if (type == PowerUpType.speedBoost) {
_speedBoostFrames += 300;
} }
} }
int _shieldFrames = 0; int _shieldFrames = 0;
bool get shieldActive => _shieldFrames > 0; bool get shieldActive => _shieldFrames > 0 || _speedBoostFrames > 0;
bool get shieldDeactivating => _shieldFrames > 0 && _shieldFrames < 60; bool get shieldDeactivating =>
math.max(_shieldFrames, _speedBoostFrames) > 0 && math.max(_shieldFrames, _speedBoostFrames) < 60;
int _sideLaserFrames = 0; int _sideLaserFrames = 0;
bool get sideLaserActive => _sideLaserFrames > 0; bool get sideLaserActive => _sideLaserFrames > 0;
...@@ -93,6 +102,9 @@ class PlayerState extends Node { ...@@ -93,6 +102,9 @@ class PlayerState extends Node {
int _speedLaserFrames = 0; int _speedLaserFrames = 0;
bool get speedLaserActive => _speedLaserFrames > 0; bool get speedLaserActive => _speedLaserFrames > 0;
int _speedBoostFrames = 0;
bool get speedBoostActive => _speedBoostFrames > 0;
void flashBgSprite(Sprite sprt) { void flashBgSprite(Sprite sprt) {
sprt.actions.stopAll(); sprt.actions.stopAll();
ActionTween flash = new ActionTween( ActionTween flash = new ActionTween(
...@@ -107,6 +119,15 @@ class PlayerState extends Node { ...@@ -107,6 +119,15 @@ class PlayerState extends Node {
if (_shieldFrames > 0) _shieldFrames--; if (_shieldFrames > 0) _shieldFrames--;
if (_sideLaserFrames > 0) _sideLaserFrames--; if (_sideLaserFrames > 0) _sideLaserFrames--;
if (_speedLaserFrames > 0) _speedLaserFrames--; if (_speedLaserFrames > 0) _speedLaserFrames--;
if (_speedBoostFrames > 0) _speedBoostFrames--;
// Update speed
if (speedBoostActive)
_scrollSpeedTarget = normalScrollSpeed * 6.0;
else
_scrollSpeedTarget = normalScrollSpeed;
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