- Adjusted difficulty formula for bowling challenge.
- Added difficulty-weighted maze monsters. - Note: this build has a hard-coded difficulty of 10.
This commit is contained in:
@@ -121,6 +121,8 @@ public class PCGLevel extends Level {
|
||||
int length = 0;
|
||||
|
||||
if (TESTING) {
|
||||
difficulty = 10;
|
||||
|
||||
length = buildStraight(0, width - 64, true);
|
||||
length += buildFreebie(length, width - 64 - length);
|
||||
|
||||
@@ -228,6 +230,11 @@ public class PCGLevel extends Level {
|
||||
if (maxLength >= 26
|
||||
&& (enemyType == SpriteTemplate.ARMORED_TURTLE || enemyType == SpriteTemplate.GREEN_TURTLE)) {
|
||||
|
||||
int numEnemies = 0;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
numEnemies += shouldAddChallenge() ? 1 : 0;
|
||||
}
|
||||
|
||||
// Create the pit.
|
||||
setBlock(xo, this.height - 2, Level.GROUND);
|
||||
setBlock(xo, this.height - 1, Level.GROUND);
|
||||
@@ -247,7 +254,7 @@ public class PCGLevel extends Level {
|
||||
setBlock(xo + x, this.height - 2, Level.GROUND);
|
||||
setBlock(xo + x, this.height - 3, Level.GROUND);
|
||||
|
||||
if (x >= 26 - difficulty) {
|
||||
if (x >= 26 - numEnemies) {
|
||||
setSpriteTemplate(xo + x, this.height - 4,
|
||||
new SpriteTemplate(enemyType, false));
|
||||
}
|
||||
@@ -426,6 +433,12 @@ public class PCGLevel extends Level {
|
||||
}
|
||||
}
|
||||
|
||||
// This is basically just a randomizer function to call whenever I need to
|
||||
// randomly add difficulty based on the user's skill level.
|
||||
private boolean shouldAddChallenge() {
|
||||
return random.nextInt(11) + 1 <= difficulty;
|
||||
}
|
||||
|
||||
private int buildMaze(int xo, int maxLength) {
|
||||
if (maxLength >= 19) {
|
||||
|
||||
@@ -483,6 +496,9 @@ public class PCGLevel extends Level {
|
||||
// Stretch nxt;
|
||||
boolean stretchEnd;
|
||||
boolean midLine;
|
||||
boolean addEnemy;
|
||||
int heightMod;
|
||||
int enemyType;
|
||||
for (int i = 0; i < maze.size(); i++) {
|
||||
|
||||
str = maze.get(i);
|
||||
@@ -496,6 +512,7 @@ public class PCGLevel extends Level {
|
||||
// skipDown = (skipDown && (x == str.len - 2))
|
||||
// || (str.len >= 5 && x == (str.len / 2));
|
||||
midLine = (str.len >= 5 && x == (str.len / 2) - 1);
|
||||
addEnemy = (str.len >= 5 && x == (str.len / 2));
|
||||
stretchEnd = (x == str.len - 1);
|
||||
|
||||
if // ((stretchEnd && nxt != null && nxt.lvl !=
|
||||
@@ -536,6 +553,29 @@ public class PCGLevel extends Level {
|
||||
if (!stretchEnd) {
|
||||
setBlock(xo + soFar + x, this.height - 4, Level.ROCK);
|
||||
}
|
||||
|
||||
if (addEnemy && shouldAddChallenge()) {
|
||||
|
||||
enemyType = shouldAddChallenge() ? (shouldAddChallenge() ? (shouldAddChallenge() ? SpriteTemplate.ARMORED_TURTLE
|
||||
: SpriteTemplate.RED_TURTLE)
|
||||
: SpriteTemplate.GREEN_TURTLE)
|
||||
: SpriteTemplate.GOOMPA;
|
||||
|
||||
switch (str.lvl) {
|
||||
case TOP:
|
||||
heightMod = 8;
|
||||
break;
|
||||
case MID:
|
||||
heightMod = 5;
|
||||
break;
|
||||
default:
|
||||
heightMod = 2;
|
||||
}
|
||||
|
||||
setSpriteTemplate(xo + soFar + x, this.height
|
||||
- heightMod, new SpriteTemplate(enemyType,
|
||||
shouldAddChallenge()));
|
||||
}
|
||||
}
|
||||
|
||||
soFar += str.len;
|
||||
|
||||
Reference in New Issue
Block a user