- 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,147 +427,127 @@ public class PCGLevel extends Level {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int buildMaze(int xo, int maxLength) {
|
private int buildMaze(int xo, int maxLength) {
|
||||||
int length = random.nextInt(maxLength - 19) + 20;
|
if (maxLength >= 19) {
|
||||||
int soFar = 6;
|
|
||||||
int next;
|
|
||||||
// boolean skipUp = false;
|
|
||||||
// boolean skipDown = false;
|
|
||||||
|
|
||||||
class Stretch {
|
int length = random.nextInt(maxLength - 19) + 20;
|
||||||
public int len;
|
int soFar = 6;
|
||||||
public LevelComponent.MazeLevel lvl;
|
int next;
|
||||||
|
// boolean skipUp = false;
|
||||||
|
// boolean skipDown = false;
|
||||||
|
|
||||||
public Stretch(int lngth) {
|
class Stretch {
|
||||||
len = lngth;
|
public int len;
|
||||||
|
public LevelComponent.MazeLevel lvl;
|
||||||
|
|
||||||
switch (random.nextInt(3)) {
|
public Stretch(int lngth) {
|
||||||
case 0:
|
len = lngth;
|
||||||
lvl = LevelComponent.MazeLevel.TOP;
|
|
||||||
break;
|
switch (random.nextInt(3)) {
|
||||||
case 1:
|
case 0:
|
||||||
lvl = LevelComponent.MazeLevel.MID;
|
lvl = LevelComponent.MazeLevel.TOP;
|
||||||
break;
|
break;
|
||||||
default:
|
case 1:
|
||||||
lvl = LevelComponent.MazeLevel.BOT;
|
lvl = LevelComponent.MazeLevel.MID;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
lvl = LevelComponent.MazeLevel.BOT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ArrayList<Stretch> maze = new ArrayList<Stretch>();
|
||||||
|
|
||||||
|
loop: while (soFar < length) {
|
||||||
|
if (soFar + 3 > length) {
|
||||||
|
length = soFar;
|
||||||
|
break loop;
|
||||||
|
}
|
||||||
|
|
||||||
|
next = random.nextInt(18) + 5;
|
||||||
|
|
||||||
|
if (soFar + next > length) {
|
||||||
|
next = length - soFar;
|
||||||
|
}
|
||||||
|
|
||||||
|
maze.add(new Stretch(next));
|
||||||
|
|
||||||
|
soFar += next;
|
||||||
|
}
|
||||||
|
|
||||||
|
setBlock(xo, this.height - 1, Level.GROUND);
|
||||||
|
setBlock(xo + 1, this.height - 1, Level.GROUND);
|
||||||
|
setBlock(xo + 2, this.height - 1, Level.GROUND);
|
||||||
|
soFar = 3;
|
||||||
|
|
||||||
|
Stretch str;
|
||||||
|
// Stretch nxt;
|
||||||
|
boolean stretchEnd;
|
||||||
|
boolean midLine;
|
||||||
|
for (int i = 0; i < maze.size(); i++) {
|
||||||
|
|
||||||
|
str = maze.get(i);
|
||||||
|
|
||||||
|
for (int x = 0; x < str.len; x++) {
|
||||||
|
|
||||||
|
setBlock(xo + soFar + x, this.height - 1, Level.GROUND);
|
||||||
|
|
||||||
|
// skipUp = (skipUp && (x == str.len - 2))
|
||||||
|
// || (str.len >= 5 && x == (str.len / 2));
|
||||||
|
// skipDown = (skipDown && (x == str.len - 2))
|
||||||
|
// || (str.len >= 5 && x == (str.len / 2));
|
||||||
|
midLine = (str.len >= 5 && x == (str.len / 2) - 1);
|
||||||
|
stretchEnd = (x == str.len - 1);
|
||||||
|
|
||||||
|
if // ((stretchEnd && nxt != null && nxt.lvl !=
|
||||||
|
// MazeLevel.BOT)
|
||||||
|
// ||
|
||||||
|
(midLine && str.lvl != LevelComponent.MazeLevel.BOT) // )
|
||||||
|
{
|
||||||
|
setBlock(xo + soFar + x, this.height - 2, Level.ROCK);
|
||||||
|
setBlock(xo + soFar + x, this.height - 3, Level.ROCK);
|
||||||
|
}
|
||||||
|
if // ((stretchEnd && nxt != null && nxt.lvl !=
|
||||||
|
// MazeLevel.MID)
|
||||||
|
// ||
|
||||||
|
(midLine && str.lvl != LevelComponent.MazeLevel.MID)// )
|
||||||
|
{
|
||||||
|
setBlock(xo + soFar + x, this.height - 5, Level.ROCK);
|
||||||
|
setBlock(xo + soFar + x, this.height - 6, Level.ROCK);
|
||||||
|
}
|
||||||
|
if // ((stretchEnd && nxt != null && nxt.lvl !=
|
||||||
|
// MazeLevel.TOP)
|
||||||
|
// ||
|
||||||
|
(midLine && str.lvl != LevelComponent.MazeLevel.TOP)// )
|
||||||
|
{
|
||||||
|
setBlock(xo + soFar + x, this.height - 8, Level.ROCK);
|
||||||
|
setBlock(xo + soFar + x, this.height - 9, Level.ROCK);
|
||||||
|
setBlock(xo + soFar + x, this.height - 10, Level.ROCK);
|
||||||
|
setBlock(xo + soFar + x, this.height - 11, Level.ROCK);
|
||||||
|
setBlock(xo + soFar + x, this.height - 12, Level.ROCK);
|
||||||
|
setBlock(xo + soFar + x, this.height - 13, Level.ROCK);
|
||||||
|
setBlock(xo + soFar + x, this.height - 14, Level.ROCK);
|
||||||
|
setBlock(xo + soFar + x, this.height - 15, Level.ROCK);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!stretchEnd) {
|
||||||
|
setBlock(xo + soFar + x, this.height - 7, Level.ROCK);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!stretchEnd) {
|
||||||
|
setBlock(xo + soFar + x, this.height - 4, Level.ROCK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
soFar += str.len;
|
||||||
|
}
|
||||||
|
|
||||||
|
setBlock(xo + length - 1, this.height - 1, Level.GROUND);
|
||||||
|
setBlock(xo + length - 2, this.height - 1, Level.GROUND);
|
||||||
|
setBlock(xo + length - 3, this.height - 1, Level.GROUND);
|
||||||
|
|
||||||
|
return length;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
ArrayList<Stretch> maze = new ArrayList<Stretch>();
|
|
||||||
|
|
||||||
loop: while (soFar < length) {
|
|
||||||
if (soFar + 3 > length) {
|
|
||||||
length = soFar;
|
|
||||||
break loop;
|
|
||||||
}
|
|
||||||
|
|
||||||
next = random.nextInt(18) + 5;
|
|
||||||
|
|
||||||
if (soFar + next > length) {
|
|
||||||
next = length - soFar;
|
|
||||||
}
|
|
||||||
|
|
||||||
maze.add(new Stretch(next));
|
|
||||||
|
|
||||||
soFar += next;
|
|
||||||
}
|
|
||||||
|
|
||||||
setBlock(xo, this.height - 1, Level.GROUND);
|
|
||||||
setBlock(xo + 1, this.height - 1, Level.GROUND);
|
|
||||||
setBlock(xo + 2, this.height - 1, Level.GROUND);
|
|
||||||
soFar = 3;
|
|
||||||
|
|
||||||
Stretch str;
|
|
||||||
// Stretch nxt;
|
|
||||||
boolean stretchEnd;
|
|
||||||
boolean midLine;
|
|
||||||
for (int i = 0; i < maze.size(); 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++) {
|
|
||||||
|
|
||||||
setBlock(xo + soFar + x, this.height - 1, Level.GROUND);
|
|
||||||
|
|
||||||
// skipUp = (skipUp && (x == str.len - 2))
|
|
||||||
// || (str.len >= 5 && x == (str.len / 2));
|
|
||||||
// skipDown = (skipDown && (x == str.len - 2))
|
|
||||||
// || (str.len >= 5 && x == (str.len / 2));
|
|
||||||
midLine = (str.len >= 5 && x == (str.len / 2) - 1);
|
|
||||||
stretchEnd = (x == str.len - 1);
|
|
||||||
|
|
||||||
if // ((stretchEnd && nxt != null && nxt.lvl != MazeLevel.BOT)
|
|
||||||
// ||
|
|
||||||
(midLine && str.lvl != LevelComponent.MazeLevel.BOT) // )
|
|
||||||
{
|
|
||||||
setBlock(xo + soFar + x, this.height - 2, Level.BLOCK_EMPTY);
|
|
||||||
setBlock(xo + soFar + x, this.height - 3, Level.BLOCK_EMPTY);
|
|
||||||
}
|
|
||||||
if // ((stretchEnd && nxt != null && nxt.lvl != MazeLevel.MID)
|
|
||||||
// ||
|
|
||||||
(midLine && str.lvl != LevelComponent.MazeLevel.MID)// )
|
|
||||||
{
|
|
||||||
setBlock(xo + soFar + x, this.height - 5, Level.BLOCK_EMPTY);
|
|
||||||
setBlock(xo + soFar + x, this.height - 6, Level.BLOCK_EMPTY);
|
|
||||||
}
|
|
||||||
if // ((stretchEnd && nxt != null && nxt.lvl != MazeLevel.TOP)
|
|
||||||
// ||
|
|
||||||
(midLine && str.lvl != LevelComponent.MazeLevel.TOP)// )
|
|
||||||
{
|
|
||||||
setBlock(xo + soFar + x, this.height - 8, Level.BLOCK_EMPTY);
|
|
||||||
setBlock(xo + soFar + x, this.height - 9, Level.BLOCK_EMPTY);
|
|
||||||
setBlock(xo + soFar + x, this.height - 10,
|
|
||||||
Level.BLOCK_EMPTY);
|
|
||||||
setBlock(xo + soFar + x, this.height - 11,
|
|
||||||
Level.BLOCK_EMPTY);
|
|
||||||
setBlock(xo + soFar + x, this.height - 12,
|
|
||||||
Level.BLOCK_EMPTY);
|
|
||||||
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) {
|
|
||||||
setBlock(xo + soFar + x, this.height - 7, Level.BLOCK_EMPTY);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!stretchEnd) {
|
|
||||||
setBlock(xo + soFar + x, this.height - 4, Level.BLOCK_EMPTY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
soFar += str.len;
|
|
||||||
}
|
|
||||||
|
|
||||||
setBlock(xo + length - 1, this.height - 1, Level.GROUND);
|
|
||||||
setBlock(xo + length - 2, this.height - 1, Level.GROUND);
|
|
||||||
setBlock(xo + length - 3, this.height - 1, Level.GROUND);
|
|
||||||
|
|
||||||
return length;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int buildPipeJump(int xo, int maxLength) {
|
private int buildPipeJump(int xo, int maxLength) {
|
||||||
@@ -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