Diamond Rush Game For Nokia X2-01 320x240 Online
// Game states private static final int STATE_MENU = 0; private static final int STATE_PLAYING = 1; private static final int STATE_WIN = 2; private static final int STATE_GAME_OVER = 3; private int gameState = STATE_MENU;
private void movePlayer(int dx, int dy)
private void generateRandomLevel() // Fill with walls for (int y = 0; y < HEIGHT; y++) for (int x = 0; x < WIDTH; x++) map[y][x] = TILE_WALL; diamond rush game for nokia x2-01 320x240
// Tile types private static final byte TILE_EMPTY = 0; private static final byte TILE_WALL = 1; private static final byte TILE_DIAMOND = 2; private static final byte TILE_PLAYER = 3; private static final byte TILE_EXIT = 4; private static final byte TILE_EXIT_OPEN = 5;
private void drawGame(Graphics g) // Draw map for (int y = 0; y < HEIGHT; y++) for (int x = 0; x < WIDTH; x++) int px = x * TILE_SIZE; int py = y * TILE_SIZE; // Game states private static final int STATE_MENU
public void commandAction(Command c, Displayable d) if (c == exitCommand) destroyApp(true); notifyDestroyed();
// Map dimensions private static final int WIDTH = 15; // 15 tiles wide private static final int HEIGHT = 12; // 12 tiles high private static final int TILE_SIZE = 20; // 20x20 pixels (20*15=300, 20*12=240) private int gameState = STATE_MENU
public void handleInput() int key = getGameAction(getKeyStates());
// Create outer walls for (int x = 0; x < WIDTH; x++) map[0][x] = TILE_WALL; map[HEIGHT-1][x] = TILE_WALL; for (int y = 0; y < HEIGHT; y++) map[y][0] = TILE_WALL; map[y][WIDTH-1] = TILE_WALL;
private Random random = new Random();