public void keyPressed() { if (menu.startPressed()) { int keyIndex = -1; if (key >= 'A' && key <= 'Z') { keyIndex = key - 'A'; } else if (key >= 'a' && key <= 'z') { keyIndex = key - 'a'; } // If it's not a letter key if (keyIndex == -1) { if (key == BACKSPACE) { levels.removeLastLetter(); } else if (key == ENTER && levels.tfs.getUserWord() != "") { levels.enterPressed(); } } // It's a letter key else { String temp = "" + key; levels.appendUserWord(temp); } } }
public static void main(String[] args) throws Exception { String print; boolean iterateGame; boolean iterateMain = true; char selection; GameBasics g = new GameBasics(); // sSystem.out.println("Welcome to the main menu.Press 1 for a new game or q for quit"); while (iterateMain == true) { System.out.println("Welcome to the main menu.Press 1 for a new game or q for quit"); selection = g.textSelection(); switch (selection) { case '1': iterateGame = true; Levels currentLevel = new Levels(); Character character = new Character(g.setName()); while (iterateGame == true) { if (currentLevel.nextLevel(currentLevel.levelNum, character) == false) { iterateGame = false; } } break; case 'q': iterateMain = false; break; default: System.out.println("Please select a valid option"); System.out.println("Welcome to the main menu.Press 1 for a new game or q for quit"); break; } } }
public Integer getAllAvailableSeatsInVenue() { int availableSeats = 0; for (Integer levelId : levels.getLevelIds()) { availableSeats += getLevel(levelId).availableSeats(); } return availableSeats; }
public void mousePressed() { if (!menu.startPressed()) { menu.mPressed(mouseX, mouseY); } else { levels.mPressed(mouseX, mouseY); } }
public Integer getAllAvailableSeatsStaringMinLevel(int minLevelId) { int availableSeats = 0; int totalLevels = levels.getLevelIds().size(); for (int i = minLevelId; i <= totalLevels; i++) { availableSeats += getLevel(i).availableSeats(); } return availableSeats; }
public void draw() { background(c.black); if (!menu.startPressed()) { menu.display(); } else { if (allowChoice) { if (menu.difficulty == 0) { // Base :) } else if (menu.difficulty == 1) { levels.level1.complete = true; } else if (menu.difficulty == 2) { levels.level1.complete = true; levels.level2.complete = true; } allowChoice = false; } levels.display(); if (levels.isQuitPressed()) { resetAllData(); } } }
/** * Loads a level. * * @param levelNumber Number of the wanted level. * @param resources Resource object for images * @return Level object * @throws ProtectedContentException * @throws IOException */ public static Level load(int levelNumber, Resources resources) throws ProtectedContentException, IOException { final Image image = Levels.getImage(levelNumber); final int w = image.getWidth(); final int h = image.getHeight(); final int[] raw = new int[w * h]; image.getRGB(raw, 0, w, 0, 0, w, h); byte[][] level = new byte[w][h]; Vector enemySpawnPointsVector = new Vector(); Point playerSpawnPoint = null; Point base = null; Vector treePointsVector = new Vector(); byte value; int x, y; Hashtable unknownColors = new Hashtable(); // add the level elements set in level image for (int i = 0; i < raw.length; i++) { value = 0; x = i % w; y = i / w; switch (raw[i] & 0x00F0F0F0) { case BRICK_COLOR: value = BRICK_WALL; break; case STEEL_COLOR: value = STEEL_WALL; break; case WATER_COLOR: value = WATER; break; case TREE_COLOR: treePointsVector.addElement(new Point(x, y)); break; case ENEMY_SPAWN_POINT_COLOR: enemySpawnPointsVector.addElement(new Point(x, y)); break; case PLAYER_SPAWN_POINT_COLOR: playerSpawnPoint = new Point(x, y); break; case BASE_COLOR: base = new Point(x, y); break; default: if ((raw[i] & 0x00FFFFFF) != 0x00FFFFFF) { Integer key = new Integer(raw[i] & 0x00FFFFFF); unknownColors.put(key, key); } } level[x][y] = value; } Point[] enemySpawnPoints = new Point[enemySpawnPointsVector.size()]; enemySpawnPointsVector.copyInto(enemySpawnPoints); Point[] trees = new Point[treePointsVector.size()]; treePointsVector.copyInto(trees); StringBuffer debug = new StringBuffer(); Enumeration e = unknownColors.keys(); while (e.hasMoreElements()) { debug.append(Integer.toHexString(((Integer) e.nextElement()).intValue())); debug.append(", "); } if (enemySpawnPoints.length == 0) { throw new IllegalArgumentException("no enemy spawn points " + debug.toString()); } if (playerSpawnPoint == null) { throw new IllegalArgumentException("no player spawn point " + debug.toString()); } if (base == null) { throw new IllegalArgumentException("no base " + debug.toString()); } return new Level(level, enemySpawnPoints, playerSpawnPoint, base, trees, resources); }
public static List<Level> getLevels() { return levelData.getLevels(); }
public void resetAllData() { menu.resetAllData(); levels.resetAllData(); allowChoice = true; }
public Level getLevel(Integer levelId) { return levels.getLevel(levelId); }
public int getLevelsCount() { return levels.getLevelIds().size(); }
public static boolean isActive(Levels level, String name) { return level.ordinal() >= _current.ordinal(); }