import java.io.*; import javax.microedition.lcdui.*; import javax.microedition.lcdui.game.*; public class PCanvas extends GameCanvas implements Runnable { private PSprite spr, knp, stb; private Image im, img, knopka, stolb; /* public PSound psn; */ private TiledLayer mapL; private LayerManager lm; int CX = 0; int CY = 0; int gW; int gH; static int GW; static int GH; boolean z; public PCanvas() throws IOException { super(true); setFullScreenMode(true); gW = getWidth(); gH = getHeight(); im = Image.createImage("/pics/spriteImage.png"); spr = new PSprite(im, 20, 40); spr.setFrame(18); spr.setPosition(getWidth()/2, getHeight()/2); knopka = Image.createImage("/pics/knopka.png"); knp = new PSprite(knopka, 30, 30); knp.setPosition(320, 240); stolb = Image.createImage("/pics/stolb.png"); stb = new PSprite(stolb, 20, 40); stb.setPosition(500, 70); mapL = Map(); lm = new LayerManager(); lm.append(spr); lm.append(knp); lm.append(stb); lm.append(mapL); /* psn = new PSound(); */ } public void start() { z = true; Thread t = new Thread(this); t.start(); } /* метод для обработки столкновений public void bomBom() { if (spr.collidesWith(stb, true)) { psn.playS(2); } else { psn.stopPlay(2); } if (spr.collidesWith(knp, true)) { psn.playS(1); } else { psn.stopPlay(1); } }*/ public TiledLayer Map() throws IOException { img = Image.createImage("/pics/background.png"); mapL = new TiledLayer(10, 10, img, 64, 64); int[] pole = { 1, 1, 1, 1, 1, 2, 1, 1, 1, 4, 1, 1, 1, 1, 2, 1, 1, 1, 4, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 2, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 2, 1, 1, 1, 4, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 2, 3, 3, 3 }; for (int i = 0; i