Diamond Rush Game For Nokia X2-01 320x240 Site

// Place exit door at bottom-right area int exitX = WIDTH-2, exitY = HEIGHT-2; while (map[exitY][exitX] != TILE_EMPTY && exitX > 1 && exitY > 1) exitX--; exitY--; map[exitY][exitX] = TILE_EXIT;

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;

private void drawGameOver(Graphics g) g.setColor(0, 0, 0); g.fillRect(0, 0, getWidth(), getHeight()); g.setColor(255, 0, 0); g.drawString("GAME OVER", getWidth()/2, 80, Graphics.HCENTER); g.setColor(255, 255, 255); g.drawString("Press * to restart", getWidth()/2, 150, Graphics.HCENTER); diamond rush game for nokia x2-01 320x240

private void restartGame() newGame();

switch (map[y][x]) Graphics.LEFT); break; case TILE_EXIT: g.setColor(100, 50, 0); g.fillRect(px, py, TILE_SIZE-1, TILE_SIZE-1); g.setColor(200, 100, 0); g.drawString("D", px+5, py+2, Graphics.TOP // Place exit door at bottom-right area int

// Dig pathways (simple maze-like open space) for (int y = 1; y < HEIGHT-1; y++) for (int x = 1; x < WIDTH-1; x++) if (random.nextInt(100) < 70) // 70% open space map[y][x] = TILE_EMPTY; else map[y][x] = TILE_WALL;

/* * Diamond Rush for Nokia X2-01 (320x240) * Controls: 2=Up, 8=Down, 4=Left, 6=Right, 5=Pick Diamond, * = Restart * Goal: Collect all diamonds to unlock the exit door. */ import javax.microedition.lcdui. ; import javax.microedition.midlet. ; import java.util.Random; ; import java

// Place diamonds (count = 15-25) diamondsTotal = 15 + random.nextInt(11); int placed = 0; while (placed < diamondsTotal) int x = 1 + random.nextInt(WIDTH-2); int y = 1 + random.nextInt(HEIGHT-2); if (map[y][x] == TILE_EMPTY && !(x == 1 && y == 1)) map[y][x] = TILE_DIAMOND; placed++;

// 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;