- Changed platforms/mazes to rocks.
- Fixed impossible platform jump bug. - Implemented difficulty adjustment for bowling. - Implemented short-form freebies.
This commit is contained in:
@@ -122,14 +122,24 @@ public class PCGLevel extends Level {
|
|||||||
|
|
||||||
if (TESTING) {
|
if (TESTING) {
|
||||||
length = buildStraight(0, width - 64, true);
|
length = buildStraight(0, width - 64, true);
|
||||||
|
length += buildFreebie(length, width - 64 - length);
|
||||||
|
|
||||||
length += buildBowlingAlley(length, width - 64 - length,
|
length += buildBowlingAlley(length, width - 64 - length,
|
||||||
SpriteTemplate.ARMORED_TURTLE);
|
SpriteTemplate.ARMORED_TURTLE);
|
||||||
|
length += buildFreebie(length, width - 64 - length);
|
||||||
|
|
||||||
length += buildLemmingTrap(length, width - 64 - length,
|
length += buildLemmingTrap(length, width - 64 - length,
|
||||||
random.nextInt(3) + 1);
|
random.nextInt(3) + 1);
|
||||||
|
length += buildFreebie(length, width - 64 - length);
|
||||||
|
|
||||||
length += buildPlatformJump(length, width - 64 - length);
|
length += buildPlatformJump(length, width - 64 - length);
|
||||||
|
length += buildFreebie(length, width - 64 - length);
|
||||||
|
|
||||||
length += buildMaze(length, width - 64 - length);
|
length += buildMaze(length, width - 64 - length);
|
||||||
|
length += buildFreebie(length, width - 64 - length);
|
||||||
|
|
||||||
length += buildPipeJump(length, width - 64 - length);
|
length += buildPipeJump(length, width - 64 - length);
|
||||||
|
length += buildFreebie(length, width - 64 - length);
|
||||||
|
|
||||||
// create all of the medium sections
|
// create all of the medium sections
|
||||||
while (length < width - 64) {
|
while (length < width - 64) {
|
||||||
@@ -185,6 +195,35 @@ public class PCGLevel extends Level {
|
|||||||
fillEndPiece(length, floor);
|
fillEndPiece(length, floor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int buildFreebie(int xo, int maxLength) {
|
||||||
|
if (maxLength >= 5) {
|
||||||
|
|
||||||
|
int floor = height - 1 - random.nextInt(4);
|
||||||
|
for (int x = 0; x < 5; x++) {
|
||||||
|
for (int y = 0; y < height; y++) {
|
||||||
|
if (y >= floor) {
|
||||||
|
setBlock(xo + x, y, GROUND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (random.nextBoolean()) {
|
||||||
|
setBlock(xo, floor - 1, Level.BLOCK_EMPTY);
|
||||||
|
setBlock(xo + 4, floor - 1, Level.BLOCK_POWERUP);
|
||||||
|
|
||||||
|
setSpriteTemplate(xo + 3, floor - 1, new SpriteTemplate(
|
||||||
|
SpriteTemplate.GREEN_TURTLE, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
setBlock(xo + 2, floor - 3, Level.BLOCK_POWERUP);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
private int buildBowlingAlley(int xo, int maxLength, int enemyType) {
|
private int buildBowlingAlley(int xo, int maxLength, int enemyType) {
|
||||||
if (maxLength >= 26
|
if (maxLength >= 26
|
||||||
&& (enemyType == SpriteTemplate.ARMORED_TURTLE || enemyType == SpriteTemplate.GREEN_TURTLE)) {
|
&& (enemyType == SpriteTemplate.ARMORED_TURTLE || enemyType == SpriteTemplate.GREEN_TURTLE)) {
|
||||||
@@ -208,7 +247,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 > 16) {
|
if (x >= 26 - difficulty) {
|
||||||
setSpriteTemplate(xo + x, this.height - 4,
|
setSpriteTemplate(xo + x, this.height - 4,
|
||||||
new SpriteTemplate(enemyType, false));
|
new SpriteTemplate(enemyType, false));
|
||||||
}
|
}
|
||||||
@@ -388,6 +427,8 @@ public class PCGLevel extends Level {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int buildMaze(int xo, int maxLength) {
|
private int buildMaze(int xo, int maxLength) {
|
||||||
|
if (maxLength >= 19) {
|
||||||
|
|
||||||
int length = random.nextInt(maxLength - 19) + 20;
|
int length = random.nextInt(maxLength - 19) + 20;
|
||||||
int soFar = 6;
|
int soFar = 6;
|
||||||
int next;
|
int next;
|
||||||
@@ -446,27 +487,6 @@ public class PCGLevel extends Level {
|
|||||||
|
|
||||||
str = maze.get(i);
|
str = maze.get(i);
|
||||||
|
|
||||||
// if (i < maze.size() - 1) {
|
|
||||||
// nxt = maze.get(i + 1);
|
|
||||||
// } else {
|
|
||||||
// nxt = null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (nxt != null) {
|
|
||||||
// skipUp = ((nxt.lvl != MazeLevel.TOP) && (str.lvl ==
|
|
||||||
// MazeLevel.TOP))
|
|
||||||
// || ((nxt.lvl == MazeLevel.TOP) && (str.lvl != MazeLevel.TOP));
|
|
||||||
//
|
|
||||||
// skipDown = ((nxt.lvl != MazeLevel.BOT) && (str.lvl ==
|
|
||||||
// MazeLevel.BOT))
|
|
||||||
// || ((str.lvl != MazeLevel.BOT) && (nxt.lvl == MazeLevel.BOT));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// else {
|
|
||||||
// skipUp = false;
|
|
||||||
// skipDown = false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
for (int x = 0; x < str.len; x++) {
|
for (int x = 0; x < str.len; x++) {
|
||||||
|
|
||||||
setBlock(xo + soFar + x, this.height - 1, Level.GROUND);
|
setBlock(xo + soFar + x, this.height - 1, Level.GROUND);
|
||||||
@@ -478,46 +498,43 @@ public class PCGLevel extends Level {
|
|||||||
midLine = (str.len >= 5 && x == (str.len / 2) - 1);
|
midLine = (str.len >= 5 && x == (str.len / 2) - 1);
|
||||||
stretchEnd = (x == str.len - 1);
|
stretchEnd = (x == str.len - 1);
|
||||||
|
|
||||||
if // ((stretchEnd && nxt != null && nxt.lvl != MazeLevel.BOT)
|
if // ((stretchEnd && nxt != null && nxt.lvl !=
|
||||||
|
// MazeLevel.BOT)
|
||||||
// ||
|
// ||
|
||||||
(midLine && str.lvl != LevelComponent.MazeLevel.BOT) // )
|
(midLine && str.lvl != LevelComponent.MazeLevel.BOT) // )
|
||||||
{
|
{
|
||||||
setBlock(xo + soFar + x, this.height - 2, Level.BLOCK_EMPTY);
|
setBlock(xo + soFar + x, this.height - 2, Level.ROCK);
|
||||||
setBlock(xo + soFar + x, this.height - 3, Level.BLOCK_EMPTY);
|
setBlock(xo + soFar + x, this.height - 3, Level.ROCK);
|
||||||
}
|
}
|
||||||
if // ((stretchEnd && nxt != null && nxt.lvl != MazeLevel.MID)
|
if // ((stretchEnd && nxt != null && nxt.lvl !=
|
||||||
|
// MazeLevel.MID)
|
||||||
// ||
|
// ||
|
||||||
(midLine && str.lvl != LevelComponent.MazeLevel.MID)// )
|
(midLine && str.lvl != LevelComponent.MazeLevel.MID)// )
|
||||||
{
|
{
|
||||||
setBlock(xo + soFar + x, this.height - 5, Level.BLOCK_EMPTY);
|
setBlock(xo + soFar + x, this.height - 5, Level.ROCK);
|
||||||
setBlock(xo + soFar + x, this.height - 6, Level.BLOCK_EMPTY);
|
setBlock(xo + soFar + x, this.height - 6, Level.ROCK);
|
||||||
}
|
}
|
||||||
if // ((stretchEnd && nxt != null && nxt.lvl != MazeLevel.TOP)
|
if // ((stretchEnd && nxt != null && nxt.lvl !=
|
||||||
|
// MazeLevel.TOP)
|
||||||
// ||
|
// ||
|
||||||
(midLine && str.lvl != LevelComponent.MazeLevel.TOP)// )
|
(midLine && str.lvl != LevelComponent.MazeLevel.TOP)// )
|
||||||
{
|
{
|
||||||
setBlock(xo + soFar + x, this.height - 8, Level.BLOCK_EMPTY);
|
setBlock(xo + soFar + x, this.height - 8, Level.ROCK);
|
||||||
setBlock(xo + soFar + x, this.height - 9, Level.BLOCK_EMPTY);
|
setBlock(xo + soFar + x, this.height - 9, Level.ROCK);
|
||||||
setBlock(xo + soFar + x, this.height - 10,
|
setBlock(xo + soFar + x, this.height - 10, Level.ROCK);
|
||||||
Level.BLOCK_EMPTY);
|
setBlock(xo + soFar + x, this.height - 11, Level.ROCK);
|
||||||
setBlock(xo + soFar + x, this.height - 11,
|
setBlock(xo + soFar + x, this.height - 12, Level.ROCK);
|
||||||
Level.BLOCK_EMPTY);
|
setBlock(xo + soFar + x, this.height - 13, Level.ROCK);
|
||||||
setBlock(xo + soFar + x, this.height - 12,
|
setBlock(xo + soFar + x, this.height - 14, Level.ROCK);
|
||||||
Level.BLOCK_EMPTY);
|
setBlock(xo + soFar + x, this.height - 15, Level.ROCK);
|
||||||
setBlock(xo + soFar + x, this.height - 13,
|
|
||||||
Level.BLOCK_EMPTY);
|
|
||||||
setBlock(xo + soFar + x, this.height - 14,
|
|
||||||
Level.BLOCK_EMPTY);
|
|
||||||
setBlock(xo + soFar + x, this.height - 15,
|
|
||||||
Level.BLOCK_EMPTY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stretchEnd) {
|
if (!stretchEnd) {
|
||||||
setBlock(xo + soFar + x, this.height - 7, Level.BLOCK_EMPTY);
|
setBlock(xo + soFar + x, this.height - 7, Level.ROCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stretchEnd) {
|
if (!stretchEnd) {
|
||||||
setBlock(xo + soFar + x, this.height - 4, Level.BLOCK_EMPTY);
|
setBlock(xo + soFar + x, this.height - 4, Level.ROCK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -530,6 +547,8 @@ public class PCGLevel extends Level {
|
|||||||
|
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
private int buildPipeJump(int xo, int maxLength) {
|
private int buildPipeJump(int xo, int maxLength) {
|
||||||
int numPipes = 4;
|
int numPipes = 4;
|
||||||
@@ -606,7 +625,8 @@ public class PCGLevel extends Level {
|
|||||||
LevelComponent.PlatformLevel last;
|
LevelComponent.PlatformLevel last;
|
||||||
LevelComponent.PlatformLevel next;
|
LevelComponent.PlatformLevel next;
|
||||||
ArrayList<LevelComponent.PlatformLevel> jumps = new ArrayList<LevelComponent.PlatformLevel>();
|
ArrayList<LevelComponent.PlatformLevel> jumps = new ArrayList<LevelComponent.PlatformLevel>();
|
||||||
int heightMod;
|
int heightMod = 0;
|
||||||
|
int lastHeightMod = 0;
|
||||||
|
|
||||||
jumps.add(random.nextBoolean() ? LevelComponent.PlatformLevel.BOT
|
jumps.add(random.nextBoolean() ? LevelComponent.PlatformLevel.BOT
|
||||||
: LevelComponent.PlatformLevel.MID_D);
|
: LevelComponent.PlatformLevel.MID_D);
|
||||||
@@ -666,6 +686,10 @@ public class PCGLevel extends Level {
|
|||||||
length = 3;
|
length = 3;
|
||||||
|
|
||||||
for (int x = 0; x < jumps.size(); x++) {
|
for (int x = 0; x < jumps.size(); x++) {
|
||||||
|
if (x > 0) {
|
||||||
|
lastHeightMod = heightMod;
|
||||||
|
}
|
||||||
|
|
||||||
switch (jumps.get(x)) {
|
switch (jumps.get(x)) {
|
||||||
case TOP:
|
case TOP:
|
||||||
heightMod = 12;
|
heightMod = 12;
|
||||||
@@ -680,17 +704,17 @@ public class PCGLevel extends Level {
|
|||||||
heightMod = 3;
|
heightMod = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
heightMod += (random.nextBoolean() ? random.nextInt(2) : -1
|
heightMod += (x > 0 && random.nextBoolean() ? random.nextInt(2)
|
||||||
* random.nextInt(2));
|
: -1 * random.nextInt(2));
|
||||||
|
|
||||||
setBlock(xo + length, this.height - heightMod,
|
while (x > 0 && heightMod - lastHeightMod >= 5) {
|
||||||
Level.BLOCK_EMPTY);
|
heightMod--;
|
||||||
setBlock(xo + length + 1, this.height - heightMod,
|
}
|
||||||
Level.BLOCK_EMPTY);
|
|
||||||
setBlock(xo + length + 2, this.height - heightMod,
|
setBlock(xo + length, this.height - heightMod, Level.ROCK);
|
||||||
Level.BLOCK_EMPTY);
|
setBlock(xo + length + 1, this.height - heightMod, Level.ROCK);
|
||||||
setBlock(xo + length + 3, this.height - heightMod,
|
setBlock(xo + length + 2, this.height - heightMod, Level.ROCK);
|
||||||
Level.BLOCK_EMPTY);
|
setBlock(xo + length + 3, this.height - heightMod, Level.ROCK);
|
||||||
|
|
||||||
length += 8;
|
length += 8;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user