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