Merged fixes, and animations branch
This commit is contained in:
commit
23e925a1b9
Binary file not shown.
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 258 KiB |
@ -377,17 +377,18 @@ class CircuitBackground extends MovingObject {
|
||||
|
||||
@override
|
||||
void resize(Vector2 newSize, double xRatio, double yRatio) {
|
||||
background1Size =
|
||||
Vector2(newSize.y * (background.width / background.height), newSize.y);
|
||||
background1Position.x *= xRatio;
|
||||
background1Position.y *= yRatio;
|
||||
background1Size.x *= xRatio;
|
||||
background1Size.y *= yRatio;
|
||||
background2Position.x *= xRatio;
|
||||
background2Position.y *= yRatio;
|
||||
background2Size.x *= xRatio;
|
||||
background2Size.y *= yRatio;
|
||||
windowA.position = background1Position;
|
||||
windowA.size = background1Size;
|
||||
overlayA.position = background1Position;
|
||||
overlayA.size = background1Size;
|
||||
|
||||
background2Position =
|
||||
Vector2(background1Position.x + background1Size.x - 1, 0);
|
||||
background2Size =
|
||||
Vector2(newSize.y * (background.width / background.height), newSize.y);
|
||||
windowB.position = background2Position;
|
||||
windowB.size = background2Size;
|
||||
overlayB.position = background2Position;
|
||||
|
@ -46,7 +46,10 @@ class LoseMenuOverlay extends StatelessWidget {
|
||||
),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: Text("Main Menu"),
|
||||
child: Text(
|
||||
" Main Menu ",
|
||||
style: overlayText,
|
||||
),
|
||||
),
|
||||
),
|
||||
// ),
|
||||
@ -70,7 +73,10 @@ class LoseMenuOverlay extends StatelessWidget {
|
||||
),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: Text("Replay"),
|
||||
child: Text(
|
||||
" Replay ",
|
||||
style: overlayText,
|
||||
),
|
||||
),
|
||||
),
|
||||
// ),
|
||||
|
@ -64,7 +64,7 @@ class Platform extends MovingObject {
|
||||
PlatformState.right: right,
|
||||
PlatformState.single: single,
|
||||
},
|
||||
current: PlatformState.single,
|
||||
current: PlatformState.mid,
|
||||
);
|
||||
|
||||
sprite.changePriorityWithoutResorting(PLATFORM_PRIORITY);
|
||||
@ -112,14 +112,19 @@ class Platform extends MovingObject {
|
||||
bool hasLeft = (left.x - sprite.position.x).abs() < 1.9 * sprite.size.x;
|
||||
bool hasRight = (sprite.position.x - right.x).abs() < 1.9 * sprite.size.x;
|
||||
|
||||
if (hasLeft && hasRight) {
|
||||
sprite.current = PlatformState.mid;
|
||||
} else if (hasLeft && !hasRight) {
|
||||
sprite.current = PlatformState.right;
|
||||
} else if (!hasLeft && hasRight) {
|
||||
sprite.current = PlatformState.left;
|
||||
} else {
|
||||
sprite.current = PlatformState.single;
|
||||
// If the platform cannot be seen by the player.
|
||||
if (!((sprite.x >= 0 && sprite.x <= gameRef.size.x) ||
|
||||
(sprite.x + sprite.width >= 0 &&
|
||||
sprite.x + sprite.width <= gameRef.size.x))) {
|
||||
if (hasLeft && hasRight) {
|
||||
sprite.current = PlatformState.mid;
|
||||
} else if (hasLeft && !hasRight) {
|
||||
sprite.current = PlatformState.right;
|
||||
} else if (!hasLeft && hasRight) {
|
||||
sprite.current = PlatformState.left;
|
||||
} else {
|
||||
sprite.current = PlatformState.single;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ class PlatformHolder extends Holder {
|
||||
late Image r2;
|
||||
late Image o1;
|
||||
late Image o2;
|
||||
bool noTopObstaclesForNext = false;
|
||||
bool noMiddleObstaclesForNext = false;
|
||||
int timeSinceLastTopHole = 0;
|
||||
int timeSinceLastBottomHole = 0;
|
||||
|
||||
@ -91,6 +93,7 @@ class PlatformHolder extends Holder {
|
||||
remove(objects[2], objects[2].length - 2);
|
||||
|
||||
timeSinceLastTopHole = 0;
|
||||
noTopObstaclesForNext = true;
|
||||
}
|
||||
if (bottomChance > 30) {
|
||||
Platform start = objects[5].elementAt(objects[5].length - 10) as Platform;
|
||||
@ -112,6 +115,7 @@ class PlatformHolder extends Holder {
|
||||
remove(objects[5], firstToRemove);
|
||||
|
||||
timeSinceLastBottomHole = 0;
|
||||
noMiddleObstaclesForNext = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,6 +133,13 @@ class PlatformHolder extends Holder {
|
||||
platform.row = level;
|
||||
gameRef.add(platform.sprite);
|
||||
objects[level].add(platform);
|
||||
if (level == 2 && noTopObstaclesForNext) {
|
||||
platform.prohibitObstacles = true;
|
||||
noTopObstaclesForNext = false;
|
||||
} else if (level == 5 && noMiddleObstaclesForNext) {
|
||||
platform.prohibitObstacles = true;
|
||||
noMiddleObstaclesForNext = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,8 @@ import 'package:firo_runner/moving_object.dart';
|
||||
import 'package:firo_runner/main.dart';
|
||||
import 'package:flame/effects.dart';
|
||||
import 'package:flame/flame.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flame/components.dart';
|
||||
import 'package:flame/image_composition.dart';
|
||||
import 'package:flutter/animation.dart';
|
||||
@ -78,9 +78,9 @@ class Runner extends Component with HasGameRef<MyGame> {
|
||||
if (gameRef.gameState.isPaused) {
|
||||
return;
|
||||
}
|
||||
previousState = runnerState;
|
||||
switch (event) {
|
||||
case "jump":
|
||||
previousState = runnerState;
|
||||
runnerState = event;
|
||||
sprite.current = RunnerState.jump;
|
||||
sprite.addEffect(MoveEffect(
|
||||
@ -100,6 +100,7 @@ class Runner extends Component with HasGameRef<MyGame> {
|
||||
if (belowPlatform()) {
|
||||
break;
|
||||
}
|
||||
previousState = runnerState;
|
||||
sprite.clearEffects();
|
||||
if (level - 1 < 0) {
|
||||
break;
|
||||
@ -123,20 +124,24 @@ class Runner extends Component with HasGameRef<MyGame> {
|
||||
));
|
||||
break;
|
||||
case "fall":
|
||||
previousState = runnerState;
|
||||
sprite.clearEffects();
|
||||
runnerState = event;
|
||||
sprite.current = RunnerState.fall;
|
||||
sprite.addEffect(getFallingEffect());
|
||||
break;
|
||||
case "kick":
|
||||
previousState = runnerState;
|
||||
runnerState = event;
|
||||
sprite.current = RunnerState.kick;
|
||||
break;
|
||||
case "run":
|
||||
previousState = runnerState;
|
||||
runnerState = event;
|
||||
sprite.current = RunnerState.run;
|
||||
break;
|
||||
case "float":
|
||||
previousState = runnerState;
|
||||
runnerState = event;
|
||||
sprite.current = RunnerState.float;
|
||||
sprite.addEffect(MoveEffect(
|
||||
@ -154,6 +159,7 @@ class Runner extends Component with HasGameRef<MyGame> {
|
||||
));
|
||||
break;
|
||||
case "duck":
|
||||
previousState = runnerState;
|
||||
runnerState = event;
|
||||
sprite.current = RunnerState.duck;
|
||||
sprite.addEffect(MoveEffect(
|
||||
@ -169,6 +175,7 @@ class Runner extends Component with HasGameRef<MyGame> {
|
||||
if (dead) {
|
||||
return;
|
||||
}
|
||||
previousState = runnerState;
|
||||
sprite.clearEffects();
|
||||
level = 11;
|
||||
sprite.addEffect(MoveEffect(
|
||||
@ -185,6 +192,7 @@ class Runner extends Component with HasGameRef<MyGame> {
|
||||
if (dead) {
|
||||
return;
|
||||
}
|
||||
previousState = runnerState;
|
||||
sprite.clearEffects();
|
||||
level = 11;
|
||||
sprite.addEffect(MoveEffect(
|
||||
@ -201,6 +209,7 @@ class Runner extends Component with HasGameRef<MyGame> {
|
||||
if (dead) {
|
||||
return;
|
||||
}
|
||||
previousState = runnerState;
|
||||
sprite.clearEffects();
|
||||
level = 11;
|
||||
sprite.addEffect(MoveEffect(
|
||||
@ -330,6 +339,14 @@ class Runner extends Component with HasGameRef<MyGame> {
|
||||
sprite.current = RunnerState.run;
|
||||
}
|
||||
|
||||
if (runnerState == "float" || runnerState == "double_jump") {
|
||||
if (onTopOfPlatform()) {
|
||||
updateLevel();
|
||||
sprite.clearEffects();
|
||||
event("run");
|
||||
}
|
||||
}
|
||||
|
||||
intersecting();
|
||||
sprite.update(dt);
|
||||
}
|
||||
@ -353,7 +370,11 @@ class Runner extends Component with HasGameRef<MyGame> {
|
||||
}
|
||||
|
||||
bool belowPlatform() {
|
||||
Rect runnerRect = sprite.toRect();
|
||||
Rect runnerRect = Rect.fromLTRB(
|
||||
sprite.toRect().left,
|
||||
sprite.toRect().top,
|
||||
sprite.toRect().right - sprite.toRect().width / 2,
|
||||
sprite.toRect().bottom);
|
||||
bool belowPlatform = false;
|
||||
for (List<MovingObject> platformLevel in gameRef.platformHolder.objects) {
|
||||
for (MovingObject p in platformLevel) {
|
||||
@ -443,14 +464,14 @@ class Runner extends Component with HasGameRef<MyGame> {
|
||||
}
|
||||
}
|
||||
|
||||
for (List<MovingObject> debrisLevel in gameRef.wallHolder.objects) {
|
||||
for (int i = 0; i < debrisLevel.length; i++) {
|
||||
for (List<MovingObject> wallLevel in gameRef.wallHolder.objects) {
|
||||
for (int i = 0; i < wallLevel.length; i++) {
|
||||
Rect slim = Rect.fromLTRB(
|
||||
runnerRect.left + sprite.width / 3,
|
||||
runnerRect.top + sprite.height / (runnerState == "duck" ? 3 : 6),
|
||||
runnerRect.right - sprite.width / 3,
|
||||
runnerRect.bottom - sprite.height / 3);
|
||||
String intersectState = debrisLevel[i].intersect(slim);
|
||||
String intersectState = wallLevel[i].intersect(slim);
|
||||
if (intersectState == "none") {
|
||||
continue;
|
||||
} else {
|
||||
|
@ -31,7 +31,7 @@ class Wall extends MovingObject {
|
||||
gameRef.blockSize *
|
||||
(gameRef.wallHolder.wall.width / gameRef.wallHolder.wall.height / 5) *
|
||||
2.0,
|
||||
gameRef.blockSize * 0.5,
|
||||
gameRef.blockSize * 0.35,
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user