Symbian Games 240x320 -
// Draw ball g.setColor(255, 255, 0); g.fillArc(ballX, ballY, BALL_SIZE, BALL_SIZE, 0, 360);
protected void keyPressed(int keyCode) int action = getGameAction(keyCode); if (action == LEFT) catcherX -= 20; if (catcherX < 0) catcherX = 0; else if (action == RIGHT) catcherX += 20; if (catcherX + CATCHER_W > width) catcherX = width - CATCHER_W; symbian games 240x320
public void commandAction(Command c, Displayable d) if (c == exitCommand) destroyApp(true); notifyDestroyed(); // Draw ball g
}
private void updateGame() // Move ball down ballY += 6; if (ballY + BALL_SIZE >= catcherY && ballX + BALL_SIZE > catcherX && ballX < catcherX + CATCHER_W) // Caught! score++; ballX = (int)(Math.random() * (width - BALL_SIZE)); ballY = 20; // Missed if (ballY > height) ballX = (int)(Math.random() * (width - BALL_SIZE)); ballY = 20; score = Math.max(0, score - 1); // Draw ball g.setColor(255
protected void paint(Graphics g) // Background g.setColor(0, 0, 0); g.fillRect(0, 0, width, height);