diff --git a/res/levels/test.level b/res/levels/test.level index f0e66df..1d18609 100644 --- a/res/levels/test.level +++ b/res/levels/test.level @@ -3,13 +3,25 @@ name:Testlevel \o/ backgroundMusic:music/ScooterFriendsTurbo8Bit.wav background:CloudBackground - -[0-4] -spawn:EnemyOne,1,5 -spawn:StoneOne,4,5 +[0-2] +spawn:StoneOne,2,1,0 +spawn:StoneOne,2,1,10 +spawn:StoneOne,2,1,20 +spawn:StoneOne,2,1,30 +spawn:StoneOne,2,1,40 +spawn:EnemyOne,2,1,50 +spawn:StoneOne,2,1,60 +spawn:StoneOne,2,1,70 +spawn:StoneOne,2,1,80 +spawn:StoneOne,2,1,90 +spawn:StoneOne,2,1,100 +[2-4] +spawn:EnemyOne,1,5,20 +spawn:StoneOne,4,5,50 [4-10] -spawn:EnemyTwo,1,10 +spawn:EnemyTwo,1,10,60 [10-25] -spawn:EnemyThree,2,4 -spawn:EnemyTwo,5,6 +spawn:EnemyThree,2,4,33 +spawn:EnemyTwo,5,6,10 [25-30] -spawn:EnemyBoss,1,1 +spawn:EnemyBoss,1,1,100 diff --git a/src/de/teamteamteam/spacescooter/brain/GameConfig.java b/src/de/teamteamteam/spacescooter/brain/GameConfig.java index 1fd1761..1ff68fb 100644 --- a/src/de/teamteamteam/spacescooter/brain/GameConfig.java +++ b/src/de/teamteamteam/spacescooter/brain/GameConfig.java @@ -8,7 +8,7 @@ public class GameConfig { /** * Whether debug output (and more) is enabled or disabled. */ - public static boolean DEBUG = false; + public static final boolean DEBUG = false; /** * Width of GameWindow. diff --git a/src/de/teamteamteam/spacescooter/entity/enemy/EnemyOne.java b/src/de/teamteamteam/spacescooter/entity/enemy/EnemyOne.java index 978ec24..5520a0e 100644 --- a/src/de/teamteamteam/spacescooter/entity/enemy/EnemyOne.java +++ b/src/de/teamteamteam/spacescooter/entity/enemy/EnemyOne.java @@ -20,6 +20,7 @@ public class EnemyOne extends Enemy { @Override public void update() { super.update(); + this.transpose(-1, 0); } @Override diff --git a/src/de/teamteamteam/spacescooter/level/Level.java b/src/de/teamteamteam/spacescooter/level/Level.java index bb0ba42..a0ab0f5 100644 --- a/src/de/teamteamteam/spacescooter/level/Level.java +++ b/src/de/teamteamteam/spacescooter/level/Level.java @@ -14,7 +14,6 @@ import de.teamteamteam.spacescooter.entity.obstacle.StoneOne; import de.teamteamteam.spacescooter.screen.GameScreen; import de.teamteamteam.spacescooter.sound.SoundSystem; import de.teamteamteam.spacescooter.utility.Loader; -import de.teamteamteam.spacescooter.utility.Random; /** * Implementation of the actual level based gameplay logic. @@ -52,6 +51,26 @@ public final class Level { * that the game is over (meaning isGameOver() returning true). */ private int gameOverDelay; + + /** + * Offset for game screen 0 coordinate on X axis. + */ + private int gameScreenXOffset; + + /** + * Offset for game screen 0 coordinate on Y axis. + */ + private int gameScreenYOffset; + + /** + * Actual width of game screen. + */ + private int gameScreenWidth; + + /** + * Actual height of game screen. + */ + private int gameScreenHeight; /** * Constructor creating a LevelConfig based on a given config file. @@ -61,6 +80,12 @@ public final class Level { this.isGameOver = false; this.gameOverDelay = 3; this.config = Loader.getLevelConfigByFilename(levelConfig); + + //TODO: Put this into the GameConfig! + this.gameScreenXOffset = 0; + this.gameScreenYOffset = 50; + this.gameScreenWidth = GameConfig.windowWidth - 1; //This is fine. + this.gameScreenHeight = GameConfig.windowHeight - 51; //TODO: NOT HARDCODE THIS :/ } @@ -95,19 +120,20 @@ public final class Level { * - 1: EntityNumber - This helps to find out what Entity to actually spawn. * - 2: Amount - The amount of Entities to spawn at a time. * - 3: SpawnRate - The rate at which the Entities are supposed to be spawned. + * - 4: SpawnPosition - percentage of GameConfig.windowHeight - Where the Enemy shall spawn. */ - for(int[] spawnrule : this.config.spawnRuleList) { + for(int[] spawnRule : this.config.spawnRuleList) { //Skip spawn rules that are not in the current spawn interval. - if(spawnrule[0] != currentIntervalIndex) continue; + if(spawnRule[0] != currentIntervalIndex) continue; //Divide the current interval by spawnrate - int intervalModulus = intervalLength / spawnrule[3]; + int intervalModulus = intervalLength / spawnRule[3]; //Check whether the spawn rate strikes right now. if(relativeTimeWithinCurrentInterval % Math.max(1,intervalModulus) == 0) { //If the rule matches the current time, spawn the configured Entity in the configured amount: - for(int i=0; i spawnRuleList; @@ -119,13 +120,16 @@ public class LevelConfig { /** * Add a given EntitySpawnRule to the ruleList. */ - public void addEntitySpawnRule(int intervalStart, int intervalEnd, String entityName, int amount, int spawnRate) { + public void addEntitySpawnRule(int intervalStart, int intervalEnd, String entityName, int amount, int spawnRate, int spawnPositionPercentage) { int intervalIndex = this.getIntervalIndexByBorders(intervalStart, intervalEnd); if(intervalIndex == -1) { - throw new LevelConfigException("No Interval for rule found!\nRule: " + intervalStart + " to " + intervalEnd + ": " + entityName + ", " + amount + ", " + spawnRate); + throw new LevelConfigException("No Interval for rule found!\nRule: " + intervalStart + " to " + intervalEnd + ": " + entityName + ", " + amount + ", " + spawnRate + ", " + spawnPositionPercentage); } else { int enemyNumber = Entity.availableNames.valueOf(entityName).ordinal(); - int[] newRule = {intervalIndex, enemyNumber, amount, spawnRate}; + if(spawnPositionPercentage < 0 || spawnPositionPercentage > 100) { + throw new LevelConfigException("Invalid spawnPosition percentage!\nRule: " + intervalStart + " to " + intervalEnd + ": " + entityName + ", " + amount + ", " + spawnRate + ", " + spawnPositionPercentage); + } + int[] newRule = {intervalIndex, enemyNumber, amount, spawnRate, spawnPositionPercentage}; this.spawnRuleList.add(newRule); } } diff --git a/src/de/teamteamteam/spacescooter/level/LevelConfigParser.java b/src/de/teamteamteam/spacescooter/level/LevelConfigParser.java index e5f248d..8041ac9 100644 --- a/src/de/teamteamteam/spacescooter/level/LevelConfigParser.java +++ b/src/de/teamteamteam/spacescooter/level/LevelConfigParser.java @@ -86,8 +86,15 @@ public class LevelConfigParser { } else { String[] rule = line.split(":", 2); if(rule[0].equals("spawn")) { - String[] entitySpawnRule = rule[1].split(",", 3); - this.levelConfig.addEntitySpawnRule(this.currentIntervalStart, this.currentIntervalEnd, entitySpawnRule[0], Integer.parseInt(entitySpawnRule[1]), Integer.parseInt(entitySpawnRule[2])); + String[] entitySpawnRule = rule[1].split(",", 4); + this.levelConfig.addEntitySpawnRule( + this.currentIntervalStart, + this.currentIntervalEnd, + entitySpawnRule[0], + Integer.parseInt(entitySpawnRule[1]), + Integer.parseInt(entitySpawnRule[2]), + Integer.parseInt(entitySpawnRule[3]) + ); } else { throw new LevelConfigException("Unknown rule type: '"+rule[0]+"' : '"+line+"'"); }