/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author turing */ import javax.microedition.lcdui.*; public class RuuduJoonistaja extends Canvas { int x = 100, y = 150; String eesnimi="nimetu"; protected void paint(Graphics g) { g.setColor(255, 255, 255); g.fillRect(0, 0, getWidth(), getHeight()); g.setColor(0, 0, 0); g.drawRect(x, y, 10, 10); //g.drawString("Test", 50, 100, Graphics.RIGHT | Graphics.TOP); g.drawString(eesnimi, x, y, Graphics.RIGHT | Graphics.TOP); } protected void keyPressed(int kood){ if(getGameAction(kood)==Canvas.LEFT){x--;} if(getGameAction(kood)==Canvas.RIGHT){x++;} repaint(); } public String kysiEesnimi(){return eesnimi;} public int kysiX(){return x;} public int kysiY(){return y;} public void uusAsukoht(int ux, int uy, String unimi) { x = ux; y = uy; eesnimi=unimi; repaint(); } }