diff --git a/assets/images/death-glitched-frames.png b/assets/images/death-glitched-frames.png new file mode 100644 index 0000000..274ce43 Binary files /dev/null and b/assets/images/death-glitched-frames.png differ diff --git a/lib/Runner.dart b/lib/Runner.dart index 09367d0..2ea257d 100644 --- a/lib/Runner.dart +++ b/lib/Runner.dart @@ -17,6 +17,7 @@ enum RunnerState { fall, die, electro, + glitch, } class Runner extends Component with HasGameRef { @@ -81,7 +82,7 @@ class Runner extends Component with HasGameRef { // sprite.position, Vector2(sprite.x, (level - 1) * gameRef.blockSize), ], - speed: 50, + speed: 150, curve: Curves.bounceIn, onComplete: () { updateLevel(); @@ -99,7 +100,7 @@ class Runner extends Component with HasGameRef { path: [ Vector2(sprite.x, (level - 2) * gameRef.blockSize), ], - speed: 100, + speed: 150, curve: Curves.ease, onComplete: () { updateLevel(); @@ -164,6 +165,14 @@ class Runner extends Component with HasGameRef { sprite.current = RunnerState.electro; gameRef.die(); break; + case "glitch": + if (dead) { + return; + } + runnerState = event; + sprite.current = RunnerState.glitch; + gameRef.die(); + break; default: break; } @@ -298,7 +307,7 @@ class Runner extends Component with HasGameRef { (runnerState == "duck" || runnerState == "float")) { continue; } else if (aboveIntersect != "none") { - event("die"); + event("glitch"); return; } } else if (intersectState == "left" && runnerState == "kick") { @@ -306,7 +315,7 @@ class Runner extends Component with HasGameRef { // bugLevel[i].remove(); // bugLevel.removeAt(i); } else { - event("die"); + event("glitch"); return; } } @@ -397,6 +406,16 @@ class Runner extends Component with HasGameRef { ), ); + SpriteAnimation dyingGlitch = await loadSpriteAnimation( + 'death-glitched-frames.png', + SpriteAnimationData.sequenced( + amount: 8, + stepTime: 0.1, + textureSize: Vector2(512, 512), + loop: false, + ), + ); + sprite = SpriteAnimationGroupComponent( animations: { RunnerState.run: running, @@ -407,6 +426,7 @@ class Runner extends Component with HasGameRef { RunnerState.fall: falling, RunnerState.die: dying, RunnerState.electro: dyingElectrocuted, + RunnerState.glitch: dyingGlitch, }, current: RunnerState.run, ); diff --git a/lib/main.dart b/lib/main.dart index 471ddf3..d5d9ec5 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -116,10 +116,10 @@ class MyGame extends BaseGame with PanDetector, TapDetector, KeyboardEvents { bool isTooNearOtherObstacles(Rect rect) { Rect obstacleBounds = Rect.fromLTRB( - 2 * rect.left - rect.right - 1, - 2 * rect.top - rect.bottom - 1, - 2 * rect.right - rect.left + 1, - 2 * rect.bottom - rect.top + 1); + 3 * rect.left - 2 * rect.right - 1, + 3 * rect.top - 2 * rect.bottom - 1, + 3 * rect.right - 2 * rect.left + 1, + 3 * rect.bottom - 2 * rect.top + 1); for (List wireLevel in wireHolder.wires) { for (Wire wire in wireLevel) { if (wire.intersect(obstacleBounds) != "none") {