- 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;
|
int length = 0;
|
||||||
|
|
||||||
if (TESTING) {
|
if (TESTING) {
|
||||||
|
difficulty = 10;
|
||||||
|
|
||||||
length = buildStraight(0, width - 64, true);
|
length = buildStraight(0, width - 64, true);
|
||||||
length += buildFreebie(length, width - 64 - length);
|
length += buildFreebie(length, width - 64 - length);
|
||||||
|
|
||||||
@@ -228,6 +230,11 @@ public class PCGLevel extends Level {
|
|||||||
if (maxLength >= 26
|
if (maxLength >= 26
|
||||||
&& (enemyType == SpriteTemplate.ARMORED_TURTLE || enemyType == SpriteTemplate.GREEN_TURTLE)) {
|
&& (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.
|
// Create the pit.
|
||||||
setBlock(xo, this.height - 2, Level.GROUND);
|
setBlock(xo, this.height - 2, Level.GROUND);
|
||||||
setBlock(xo, this.height - 1, 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 - 2, Level.GROUND);
|
||||||
setBlock(xo + x, this.height - 3, Level.GROUND);
|
setBlock(xo + x, this.height - 3, Level.GROUND);
|
||||||
|
|
||||||
if (x >= 26 - difficulty) {
|
if (x >= 26 - numEnemies) {
|
||||||
setSpriteTemplate(xo + x, this.height - 4,
|
setSpriteTemplate(xo + x, this.height - 4,
|
||||||
new SpriteTemplate(enemyType, false));
|
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) {
|
private int buildMaze(int xo, int maxLength) {
|
||||||
if (maxLength >= 19) {
|
if (maxLength >= 19) {
|
||||||
|
|
||||||
@@ -483,6 +496,9 @@ public class PCGLevel extends Level {
|
|||||||
// Stretch nxt;
|
// Stretch nxt;
|
||||||
boolean stretchEnd;
|
boolean stretchEnd;
|
||||||
boolean midLine;
|
boolean midLine;
|
||||||
|
boolean addEnemy;
|
||||||
|
int heightMod;
|
||||||
|
int enemyType;
|
||||||
for (int i = 0; i < maze.size(); i++) {
|
for (int i = 0; i < maze.size(); i++) {
|
||||||
|
|
||||||
str = maze.get(i);
|
str = maze.get(i);
|
||||||
@@ -496,6 +512,7 @@ public class PCGLevel extends Level {
|
|||||||
// skipDown = (skipDown && (x == str.len - 2))
|
// skipDown = (skipDown && (x == str.len - 2))
|
||||||
// || (str.len >= 5 && x == (str.len / 2));
|
// || (str.len >= 5 && x == (str.len / 2));
|
||||||
midLine = (str.len >= 5 && x == (str.len / 2) - 1);
|
midLine = (str.len >= 5 && x == (str.len / 2) - 1);
|
||||||
|
addEnemy = (str.len >= 5 && x == (str.len / 2));
|
||||||
stretchEnd = (x == str.len - 1);
|
stretchEnd = (x == str.len - 1);
|
||||||
|
|
||||||
if // ((stretchEnd && nxt != null && nxt.lvl !=
|
if // ((stretchEnd && nxt != null && nxt.lvl !=
|
||||||
@@ -536,6 +553,29 @@ public class PCGLevel extends Level {
|
|||||||
if (!stretchEnd) {
|
if (!stretchEnd) {
|
||||||
setBlock(xo + soFar + x, this.height - 4, Level.ROCK);
|
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;
|
soFar += str.len;
|
||||||
|
|||||||
Reference in New Issue
Block a user