From ac7b0c5b1969caaa8f3096c7b51409babfb1e8f5 Mon Sep 17 00:00:00 2001 From: Marshall Date: Sun, 18 Mar 2012 16:22:25 -0400 Subject: [PATCH] -Fixed some problems with the pipe jumping challenge. --- src/dk/itu/mario/level/PCGLevel.java | 49 ++++++++++++++-------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/src/dk/itu/mario/level/PCGLevel.java b/src/dk/itu/mario/level/PCGLevel.java index 368763d..48511bf 100644 --- a/src/dk/itu/mario/level/PCGLevel.java +++ b/src/dk/itu/mario/level/PCGLevel.java @@ -619,53 +619,54 @@ public class PCGLevel extends Level { : PlayerProfile.ChallengeRewardType.JUMP); numPipes++) { } - localHeight = random.nextInt(2) + 1; + localHeight = 4; loop: for (int i = 0; i < numPipes; i++) { space = (length + 2) <= maxLength; if (space) { - while (Math.abs(localHeight - lastHeight) > 3) { - localHeight += localHeight > lastHeight ? -1 : 1; - } lastHeight = localHeight; pipeHeight = localHeight > 5 ? 4 + random .nextInt(localHeight - 4) : 4; - for (int y = 0; y < localHeight; y++) { - setBlock(xo + length, this.height - 1 - y, Level.GROUND); - setBlock(xo + length + 1, this.height - 1 - y, Level.GROUND); + for (int y = height - localHeight; y < height; y++) { - if (y == localHeight - 1) { - setBlock(xo + length, this.height - 1 - y, - Level.TUBE_TOP_LEFT); - setBlock(xo + length + 1, this.height - 1 - y, - Level.TUBE_TOP_RIGHT); - - if (shouldAddChallenge(PlayerProfile.ChallengeRewardType.ENEMY)) { - setSpriteTemplate(xo + length, this.height - y, - new SpriteTemplate( - SpriteTemplate.JUMP_FLOWER, false)); - } - } else if (y > localHeight - pipeHeight) { - setBlock(xo + length, this.height - 1 - y, - Level.TUBE_SIDE_LEFT); - setBlock(xo + length + 1, this.height - 1 - y, - Level.TUBE_SIDE_RIGHT); + if (y == height - localHeight) { + setBlock(xo + length, y, Level.TUBE_TOP_LEFT); + setBlock(xo + length + 1, y, Level.TUBE_TOP_RIGHT); } + + else if (y - height - localHeight < pipeHeight) { + setBlock(xo + length, y, Level.TUBE_SIDE_LEFT); + setBlock(xo + length + 1, y, Level.TUBE_SIDE_RIGHT); + } + + else { + setBlock(xo + length, y, Level.GROUND); + setBlock(xo + length + 1, y, Level.GROUND); + } + } + + if (shouldAddChallenge(PlayerProfile.ChallengeRewardType.ENEMY)) { + setSpriteTemplate(xo + length, height - localHeight, + new SpriteTemplate(SpriteTemplate.JUMP_FLOWER, + false)); } length += 2; localHeight = random.nextInt(7) + 4; + while (Math.abs(localHeight - lastHeight) > 3) { + localHeight += localHeight > lastHeight ? -1 : 1; + } midFloor = localHeight - (random.nextInt(4) + 1); if (midFloor <= 0) { midFloor = 1; } - for (gap = 0; gap < 4 + for (gap = 0; gap <= 4 && length + gap <= maxLength && shouldAddChallenge(PlayerProfile.ChallengeRewardType.JUMP); gap++) {