📄 level.java
字号:
/*******************************************************************************
**
** Class: Level (Level.java)
**
** The "Level" class encapsulates startsoundall the data and functionality associated
** a single level of the game, be it a tutorial level, puzzle mode level,
** regular adventure level or any other possible modes.
**
******************************************************************************/
// Level header.
import javax.microedition.lcdui.Graphics;
import javax.microedition.media.Player;
//#if SCREEN_PRINTOUTS
//# import javax.microedition.lcdui.Font;
//#endif
// the Level class itself.
public class Level {
/****************************************************************************
** Constants
***************************************************************************/
public static String strr = "";
public static final int TYPE_MAINMENU = 14; // main menu level.
public static final int TYPE_TUTORIAL = 15; // tutorial level.
public static final int TYPE_PUZZLE = 16; // puzzle level.
public static final int TYPE_TIMETRIAL = 17; // puzzle level.
public static final int TYPE_SURVIVAL = 18; // puzzle level.
public static final int TYPE_EXTRAMODE_1 = 19; // puzzle level.
public static final int TYPE_ADVENTURE = 20; // adventure level.
public static final int STATE_INTRO = 0; // level intro.
public static final int STATE_BIGGS_FALL = 1; // Biggs' entry.
public static final int STATE_BOARD_FALL = 2; // board's entry.
public static final int STATE_ACTIVE = 3; // in-level.
public static final int STATE_JEWELS_INTRO = 4; // level-end jewel shower intro.
public static final int STATE_JEWELS_ACTIVE = 5; // leven-end jewel shower active.
public static final int STATE_OUTRO = 6; // level exit.
public static final int STATE_BIGGS_FLY = 7; // Biggs' level exit jump.
public static final int STATE_SCORE = 8; // score summary.
public static final int STATE_GAME_OVER = 9; // player has lost the level.
public static final int STATE_PRESS_OK = 10; // wait for player input to start the level
public static final int BOARD_DESCEND = 0x00000001; // make Critters move down the vines.
public static final int BOARD_ASCEND = 0x00000002; // make Critters move up the vines.
public static final int BOARD_EAT_CLIMBERS = 0x00000004; // recheck Critters that finished climbing for whether they should be eaten.
public static final int BOARD_EXPLODE_FULL = 0x00000008; // make Critters that are full and part of a combo explode.
public static final int BOARD_EXPLODE_TNT = 0x00000010; // explode Critters around a TNT guy.
public static final int BOARD_EXPLODE_CHILIS = 0x00000020; // explode Critters that ate chili peppers.
public static final int BOARD_POISON = 0x00000040; // explode toxic guy and toxicFlash adjacents.
public static final int BOARD_REMAP = 0x00000080; // alter (if necessary) all the board x and y positions of the entities on the board.
public static final int BOARD_REFRESH = 0x00000100; // map all entities to the board according to their board x and y positions.
public static final int BOARD_ONION = 0x00000200; // make Critters ascend due to Biggs' bad onion breath.
public static final int BOARD_SCARE = 0x00000400; // scare all the creatures on the board.
public static final int BOARD_IDLE = 0x00000800; // check for idle-toxics/set all creatures on the board back to idle.
public static final int BOARD_BLOCKERS = 0x00001000; // check for blockers.
public static final int BOARD_REMOVE_BONUS = 0x00002000; // remove bonus status from any bonus Critters.
public static final int BOARD_CLIMB = 0x00004000; // set all creatures on the board to climb.
public static final int BOARD_NOSPACES = 0x00008000; // check for spaces between Critters.
public static final int BOARD_LEVEL_COMPLETE = 0x40000000; // make Critters explode passing the level.
public static final int BOARD_GAME_OVER = 0x80000000; // make Critters fall and kill Biggs.
public static final int BOARD_ALL_STATES = 0x7fffffff; // all possible states of the board.
public static short DESCENT_OFFSET; // amount of pixels the board travels during every descent tick.
public static short ONION_ASCENT_OFFSET; // amount of pixels the board travels during every onion ascent tick.
public static final int DATA_NULL_ENTRY = 100; // emptry entry for any level data.
public static final int NEXT_LEVEL_TYPE = 0; // type of the next level following this one.
public static final int NEXT_LEVEL_NUMBER = 1; // number of the next level following this one.
public static final int COMMON_HEADER = 2; // header common to all levels.
public static final int LEVEL_BOARD_TIMER = 2; // index in byte array of the level's board timer speed.
public static final int LEVEL_FOOD_BAR = 3; // index of the food-bar goal for the level.
public static final int LEVEL_ROWS = 4; // index of amount of rows a level starts off with.
public static final int LEVEL_BONUS = 5; // index of frequency of bonus creatures for the level.
public static final int LEVEL_ORANGES = 6; // index of frequency of orange creatures appearing.
public static final int LEVEL_PURPLES = 7; // index of frequency of purple creatures appearing.
public static final int LEVEL_HEADER = 6; // indeces taken up by level header info.
public static final int LEVEL_SIZE = COMMON_HEADER +
LEVEL_HEADER +
Critter.ALL_CREATURES +
Critter.ALL_ITEMS; // number of indeces in a whole level structure.
public static final int LEVEL_COUNT = 40; // number of levels in the game.
public static byte [] LEVELS = new byte[LEVEL_COUNT *
LEVEL_SIZE]; // byte array storing all data for all levels.
public static final int PUZZLE_MOVES = 2; // index for a puzzle level's number of moves required to complete it.
public static final int PUZZLE_CREATURES = 36; // amount of Critters stored in each puzzle level.
public static final int PUZZLE_NULL = 100; // id of a null Critter spot in a puzzle level.
public static final int PUZZLE_SIZE = COMMON_HEADER +
1 +
PUZZLE_CREATURES; // size of each puzzle level.
public static final int PUZZLE_COUNT = 60; // amount of puzzle levels in the game.
public static byte [] PUZZLES = new byte[PUZZLE_COUNT *
PUZZLE_SIZE]; // byte array storing all data for all puzzle levels.
public static final int TIMETRIAL_TIME = 2; // index for a puzzle level's number of moves required to complete it.
public static final int TIMETRIAL_CREATURES = 36; // amount of Critters stored in each puzzle level.
public static final int TIMETRIAL_SIZE = COMMON_HEADER +
1 +
TIMETRIAL_CREATURES; // size of each puzzle level.
public static final int TIMETRIAL_COUNT = 20; // amount of puzzle levels in the game.
public static byte [] TIMETRIALS = new byte[TIMETRIAL_COUNT *
TIMETRIAL_SIZE]; // byte array storing all data for all puzzle levels.
public static final int SURVIVAL_DROP_TIMER = TOTFC.FRAMES_PER_SECOND * 10; // starting timer of survival mode.
public static final int SURVIVAL_DROP_OFFSET = TOTFC.FRAMES_PER_SECOND; // amount to decrement the survival timer at each checkpoint.
public static final int SURVIVAL_MIN_DROP = TOTFC.FRAMES_PER_SECOND * 2; // minimum drop speed in survival.
public static final int SURVIVAL_TIMER = TOTFC.FRAMES_PER_SECOND * 30; // speedup interval.
//#if DefaultConfiguration || Nokia_6600 || Nokia_6600_Unobfuscated || Razr
public static final int SURVIVAL_START_ROWS = 5; // starting number of rows in survival mode.
//#else
//# public static final int SURVIVAL_START_ROWS = 4; // starting number of rows in survival mode.
//#endif
public static final int SURVIVAL_MIN_ROWS = 2; // minimum amount of rows on screen during survival.
public static final int SURVIVAL_GREENS = 4; // chance of getting a green creatures in survival mode.
public static final int SURVIVAL_REDS = 10; // chance of getting a red creatures in survival mode.
public static final int SURVIVAL_BLUES = 15; // chance of getting a blue creatures in survival mode.
public static final int SURVIVAL_BASICS = 15; // total size of all basic creatures array in survival mode.
public static final int SURVIVAL_REST = 4; // chance of getting special creatures in survival mode.
public static final int SURVIVAL_ITEMS = 3; // total size of all survival items.
public static final int SURVIVAL_INTERVAL_1 = 0; // survival upscale #1.
public static final int SURVIVAL_INTERVAL_2 = 1; // survival upscale #2.
public static final int SURVIVAL_INTERVAL_3 = 2; // survival upscale #3.
public static final int SURVIVAL_INTERVAL_4 = 3; // survival upscale #4.
public static final int SURVIVAL_INTERVAL_5 = 4; // survival upscale #5.
public static final int SURVIVAL_BONUS_1 = 300; // first survival bonus creature interval.
public static final int SURVIVAL_BONUS_2 = 250; // second survival bonus creature interval.
public static final int SURVIVAL_BONUS_3 = 200; // third survival bonus creature interval.
public static final int SURVIVAL_ORANGES = 5; // chance of getting an orange creature in survival.
public static final int SURVIVAL_PURPLES = 4; // chance of getting a purple creature in survival.
public static final int TUTORIAL_SIZE = PUZZLE_SIZE; // size of each tutorial level
public static final int TUTORIAL_COUNT = 14; // amount of tutorial levels in the game.
public static byte [] TUTORIALS = new byte[TUTORIAL_COUNT *
TUTORIAL_SIZE]; // byte array storing all data for all tutorial levels.
public static final int PUZZLE_TUTORIAL = 8; // level of puzzle tutorial.
public static final int TIMETRIAL_TUTORIAL = 9; // level of time trial tutorial.
public static short BOARD_TOP_PADDING; // padding of the board's top.
public static final int BOARD_BOTTOM_PADDING = 4; // padding of the board's bottom (in rows).
public static short GAME_BOARD_W; // width of 2D Critters array.
public static short GAME_BOARD_H; // height of 2D Critters array.
public static short GAME_SQUARE_W; // width of standard board rectangle.
public static short GAME_SQUARE_H; // height of standard board rectangle.
public static final int MAX_SPECIALS = 3; // maximum number of special creatures allowed on screen at any one point.
public static final int MIN_SPECIAL_INTERVAL = 3; // minimum "distance" between special creatures.
public static final int MAX_SPECIAL_INTERVAL = 12; // maximum "distance" between special creatures.
public static final int MAX_DISCREPANCY = 5; // maximum discrepancy between green, red and blue creatures on the game board.
public static final int CREATURES_SLOWDOWN = 30; // amount of Critters necessary to initiate a slowdown of descent.
public static final int CREATURES_SPEEDUP = 23; // amount of Critters necessary to initiate a speedup of descent.
public static final int SLOWDOWN_TIMER = 232; // timer when the level is slowed down.
public static final int SPEEDUP_TIMER = 6; // timer when level is sped up.
public static short GAME_BOARD_ANCHOR; // amount of pixels by which the board is offset from the edge of the screen.
public static short LEFT_X = 2; // x offset of left HUD pieces.
public static short RIGHT_X; // x offset of right HUD pieces.
public static short TOP_Y = 2; // y offset of top HUD pieces.
public static short BOTTOM_Y; // y offset of bottom HUD pieces.
public static short POWERUP_Y; // y offset of powerup location.
public static short PADDING = 3; // standard padding for HUD elements.
public static final int POWERUP_AMMO_X = 7; // x offset of powerup count.
public static final int CHANCE_POWERUP = 4; // chance that a powerup instead of a gem is dropped.
public static final int CHANCE_RANDOMS = 15; // amount of times we can try to get a random creature before giving up.
public static final int CHANCE_BONUS = 5; // amount of times we can try to get a bonus creature selection.
public static final int CHANCE_SIZE_MUTATE = 10; // chance that a red will turn into orange or blue will turn into purple.
public static short SQUARE_W; // width of the current board's rectangle.
public static short SQUARE_H; // height of the current board's rectangle.
public static short SQUARE_HALF_W; // half-width of the current board's rectangle.
public static short SQUARE_HALF_H; // half-height of the current board's rectangle.
public static final int MAX_EXTRAS = 15; // maximum number of Entities not attached to the board, boss or player.
public static final int TIME_MAKE_BONUS = 180; // time at which a random Critter is chosen to become a bonus.
public static final int TIME_LEVEL_OFFSET = 5; // multiplier of level timer data.
public static final int TIME_DROP_PAUSE = 12; // pause after dropping down one row.
public static final int TIME_ONION_PAUSE = 60; // board descent pause after an onion powerup.
public static final int TIME_JEWELS_INTRO = 24; // pause for jewels intro.
public static final int TIME_LEVEL_OUTRO = 10; // pause at the end level celebration.
public static final int TIME_BIGGS_EXIT = 44; // pause at the end of the level after Biggs flies off the screen.
public static final int TIME_GAMEOVER_INPUT = 24; // pause before input is registered at level end.
public static final int TIME_FAILED = 50; // pause before game over automatically finishes playing.
public static short FOOD_BAR_WIDTH; // width of the food bar fill.
public static short FOOD_BAR_HEIGHT; // height of the food bar fill.
public static short FOOD_BAR_X; // x anchor of food bar fill.
public static short FOOD_BAR_Y; // y anchor of food bar fill.
public static final int FOOD_BAR_MAX_SQUARES = 18; // maximum amount of squares of puzzle food bars.
public static int FOOD_BAR_SQUARE_SIZE; // size (height) of a food bar square for puzzles.
public static int FOOD_BAR_MULTIPLYER; // multiplier of food bar height.
public static final int BASE_POINTS = 50; // lowest possible value for a jewel.
public static final int COMBO_POINTS = 10; // multiplier for points each Critter in a combo is worth.
public static final int COIN_POINTS = 15; // mupliplier for points when collecting a coin.
public static final int TOXIC_POINTS = 2000; // amount of toxic points to subtract when grabbing a toxic gem.
public static final int TOXIC_MOUTH_POINTS = 250; // amount of points to subtract when holding a toxic.
public static final int TOXIC_HUNGER = 4; // amount of hunger bar to subtract when grabbing a toxic gem.
public static short GROUND; // ground anchor for falling entities.
public static short MIN_JEWEL_OFFSET; // minimum off-screen offset for the bonus jewels spawed off-screen.
public static short MAX_JEWEL_OFFSET; // maximum off-screen offset for the bonus jewels spawed off-screen.
public static final int MAX_SEED_CHANCE = 30; // maximum amount of chances to spawn a creature.
public static final int JEWEL_LEVEL_DIVISOR = 5; // divisor of how many extra jewels show up in the bonus round based on the current level number.
public static final int INTRO_TIME = 10; // time takes for level intro wipe in
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -