Added the feature where if you kick a bug, you get a Firo coin to the right that you can collect.
This commit is contained in:
parent
df5814820b
commit
d676116fd8
@ -25,7 +25,8 @@ class BugHolder extends Holder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool generateBug(MyGame gameRef, int level, bool force) {
|
bool generateBug(MyGame gameRef, int level,
|
||||||
|
{bool force = false, double xPosition = 0}) {
|
||||||
if (objects[level].isNotEmpty) {
|
if (objects[level].isNotEmpty) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -18,16 +18,17 @@ class CoinHolder extends Holder {
|
|||||||
return coin;
|
return coin;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool generateCoin(MyGame gameRef, int level, bool force) {
|
bool generateCoin(MyGame gameRef, int level,
|
||||||
if (total() > 5) {
|
{bool force = false, double xPosition = 0}) {
|
||||||
|
if (total() > 5 && !force) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (objects[level].isNotEmpty) {
|
if (objects[level].isNotEmpty && !force) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (random.nextInt(100) > 25) {
|
if (random.nextInt(100) > 25 && !force) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
int nearestPlatform = getNearestPlatform(level);
|
int nearestPlatform = getNearestPlatform(level);
|
||||||
@ -36,7 +37,9 @@ class CoinHolder extends Holder {
|
|||||||
gameRef.platformHolder.getPlatformOffScreen(nearestPlatform);
|
gameRef.platformHolder.getPlatformOffScreen(nearestPlatform);
|
||||||
double xCoordinate = -100;
|
double xCoordinate = -100;
|
||||||
|
|
||||||
if (level == 0) {
|
if (force) {
|
||||||
|
xCoordinate = xPosition;
|
||||||
|
} else if (level == 0) {
|
||||||
xCoordinate = gameRef.size.x;
|
xCoordinate = gameRef.size.x;
|
||||||
} else if (platform != null) {
|
} else if (platform != null) {
|
||||||
xCoordinate = platform.sprite.x;
|
xCoordinate = platform.sprite.x;
|
||||||
@ -47,7 +50,7 @@ class CoinHolder extends Holder {
|
|||||||
Coin coin = Coin(gameRef);
|
Coin coin = Coin(gameRef);
|
||||||
coin.setPosition(xCoordinate, gameRef.blockSize * level);
|
coin.setPosition(xCoordinate, gameRef.blockSize * level);
|
||||||
|
|
||||||
if (gameRef.isTooNearOtherObstacles(coin.sprite.toRect())) {
|
if (gameRef.isTooNearOtherObstacles(coin.sprite.toRect()) && !force) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,8 @@ class DebrisHolder extends Holder {
|
|||||||
return debris;
|
return debris;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool generateDebris(MyGame gameRef, int level, bool force) {
|
bool generateDebris(MyGame gameRef, int level,
|
||||||
|
{bool force = false, double xPosition = 0}) {
|
||||||
if (objects[level].isNotEmpty) {
|
if (objects[level].isNotEmpty) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -142,27 +142,27 @@ class MyGame extends BaseGame with PanDetector, TapDetector, KeyboardEvents {
|
|||||||
if (wireChosenRegion % 3 != 2 &&
|
if (wireChosenRegion % 3 != 2 &&
|
||||||
wireChosenRegion != 6 &&
|
wireChosenRegion != 6 &&
|
||||||
wireChosenRegion != 7) {
|
wireChosenRegion != 7) {
|
||||||
wireHolder.generateWire(this, wireChosenRegion, false);
|
wireHolder.generateWire(this, wireChosenRegion);
|
||||||
}
|
}
|
||||||
|
|
||||||
int bugChosenRegion = random.nextInt(9);
|
int bugChosenRegion = random.nextInt(9);
|
||||||
if (bugChosenRegion % 3 != 2 && bugChosenRegion % 3 != 0) {
|
if (bugChosenRegion % 3 != 2 && bugChosenRegion % 3 != 0) {
|
||||||
bugHolder.generateBug(this, bugChosenRegion, false);
|
bugHolder.generateBug(this, bugChosenRegion);
|
||||||
}
|
}
|
||||||
|
|
||||||
int debrisChosenRegion = random.nextInt(9);
|
int debrisChosenRegion = random.nextInt(9);
|
||||||
if (debrisChosenRegion % 3 == 0 && debrisChosenRegion != 6) {
|
if (debrisChosenRegion % 3 == 0 && debrisChosenRegion != 6) {
|
||||||
debrisHolder.generateDebris(this, debrisChosenRegion, false);
|
debrisHolder.generateDebris(this, debrisChosenRegion);
|
||||||
}
|
}
|
||||||
|
|
||||||
int choseCoinLevel = random.nextInt(9);
|
int choseCoinLevel = random.nextInt(9);
|
||||||
if (choseCoinLevel % 3 != 2 && choseCoinLevel != 6) {
|
if (choseCoinLevel % 3 != 2 && choseCoinLevel != 6) {
|
||||||
coinHolder.generateCoin(this, choseCoinLevel, false);
|
coinHolder.generateCoin(this, choseCoinLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
int wallChosenRegion = random.nextInt(9);
|
int wallChosenRegion = random.nextInt(9);
|
||||||
if (wallChosenRegion % 3 == 1 && wallChosenRegion != 7) {
|
if (wallChosenRegion % 3 == 1 && wallChosenRegion != 7) {
|
||||||
wallHolder.generateWall(this, wallChosenRegion, false);
|
wallHolder.generateWall(this, wallChosenRegion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,6 +395,8 @@ class Runner extends Component with HasGameRef<MyGame> {
|
|||||||
}
|
}
|
||||||
} else if (intersectState == "left" && runnerState == "kick") {
|
} else if (intersectState == "left" && runnerState == "kick") {
|
||||||
bugLevel[i].sprite.current = BugState.breaking;
|
bugLevel[i].sprite.current = BugState.breaking;
|
||||||
|
gameRef.coinHolder.generateCoin(gameRef, level,
|
||||||
|
force: true, xPosition: bugLevel[i].sprite.x + gameRef.blockSize);
|
||||||
} else {
|
} else {
|
||||||
event("glitch");
|
event("glitch");
|
||||||
return;
|
return;
|
||||||
|
@ -18,7 +18,8 @@ class WallHolder extends Holder {
|
|||||||
return wall;
|
return wall;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool generateWall(MyGame gameRef, int level, bool force) {
|
bool generateWall(MyGame gameRef, int level,
|
||||||
|
{bool force = false, double xPosition = 0}) {
|
||||||
if (objects[level].isNotEmpty) {
|
if (objects[level].isNotEmpty) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,8 @@ class WireHolder extends Holder {
|
|||||||
return wire;
|
return wire;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool generateWire(MyGame gameRef, int level, bool force) {
|
bool generateWire(MyGame gameRef, int level,
|
||||||
|
{bool force = false, double xPosition = 0}) {
|
||||||
if (objects[level].isNotEmpty) {
|
if (objects[level].isNotEmpty) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user