Diamond Rush Game For Nokia X2-01 320x240 -
public DiamondRush() display = Display.getDisplay(this); canvas = new GameCanvas(); exitCommand = new Command("Exit", Command.EXIT, 1); canvas.addCommand(exitCommand); canvas.setCommandListener(this);
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 newGame() generateRandomLevel(); diamondsCollected = 0; exitOpen = false; gameState = STATE_PLAYING; diamond rush game for nokia x2-01 320x240
// 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;
public void handleInput() int key = getGameAction(getKeyStates()); public DiamondRush() display = Display
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;
protected void keyPressed(int keyCode)
private void drawHUD(Graphics g) g.setColor(0, 0, 0); g.fillRect(0, 0, getWidth(), 20); g.setColor(255, 255, 255); g.drawString("Diamonds: " + diamondsCollected + "/" + diamondsTotal, 5, 5, Graphics.TOP
// Place player at (1,1) map[1][1] = TILE_PLAYER; playerX = 1; playerY = 1; public DiamondRush() display = Display.getDisplay(this)