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;
public DiamondRush() display = Display.getDisplay(this); canvas = new GameCanvas(); exitCommand = new Command("Exit", Command.EXIT, 1); canvas.addCommand(exitCommand); canvas.setCommandListener(this); diamond rush game for nokia x2-01 320x240
// 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++; private void drawGame(Graphics g) // Draw map for
private Random random = new Random();