protected void paint(Graphics g) // Background g.setColor(0, 0, 0); g.fillRect(0, 0, width, height);
// Score g.setColor(255, 255, 255); g.drawString("Score: " + score, 10, 10, Graphics.TOP symbian games 240x320
public void run() { while (running) { repaint(); updateGame(); try Thread.sleep(30); catch (Exception e) {} } } protected void paint(Graphics g) // Background g
public void pauseApp() {} public void destroyApp(boolean unconditional) {} // Score g.setColor(255
Below is a for 240x320 screens. Game: “Catch the Light” (240x320, MIDP 2.0) import javax.microedition.lcdui.*; import javax.microedition.midlet.*; public class CatchGame extends MIDlet implements CommandListener, Runnable { private Display display; private GameCanvas gameCanvas; private Command exitCommand;
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;
// Draw catcher g.setColor(0, 255, 0); g.fillRect(catcherX, catcherY, CATCHER_W, CATCHER_H);