import java.io.*; import javax.microedition.lcdui.*; import javax.microedition.lcdui.Game.*; public class canvas extends GameCanvas implements Runnable{ public LayerManager manager; public TiledLayer fon; public canvas() { manager=new LayerManager(); fon=initFon(); manager.append(fon); } public void run(){ Graphics g=getGraphics(); while(true){ init(g); try{ t.sleep(20); } catch(Exception e){ Form f=new Form("Strange exception"); main.link.display.getDisplay(this).setCurrent(f); } } } public void init(Graphics g) { g.setColor(255,255,255); g.fillRect(0,0,128,160); manager.paint(g,0,0); flushGraphics(); } public TiledLayer initFon(){ try{ Image img=Image.createImage("/fon.png"); TiledLayer tl=new TiledLayer(20,10,img,16,16); } catch(Exception e){ Form f=new Form("Not Found"); main.link.display.getDisplay(this).setCurrent(f); } for(int i=0;i<9;i++){ for(int j=0;j<20;j++){ tl.setCell(j,i,0); } } for(int i=0;i<20;i++){ tl.setCell(i,10,1); } return tl; } public void start(){ Thread t=new Thread(this); t.start(); } }