package main; import util.*; import javax.microedition.lcdui.*; import javax.microedition.lcdui.game.*; import javax.microedition.io.*; import java.util.*; import java.io.*; public class Board extends Layer { public Piece[] piece; Vector lines; int bgcolor; int screenW, screenH; int x, y; int w, h; Image[] blocks; int lineindex; public Board(int w, int h) { screenW = w; screenH = h; this.w = 16; this.h = 16; bgcolor = 0x7fff; lines = new Vector(); } public void addLine(int[] ai) { if(blocks == null) { Image im = null; try{ im = Image.createImage("/res/tile.png"); }catch(Exception e) {} blocks = UtilImg.getImages(im, 16, 16); w = ai[0]*16; h = ai[1]*16; return; } if(ai.length == 3) { bgcolor = (ai[0]<<16) | (ai[1]<<8) | ai[2]; return; } int x=0, y = lineindex*16; Piece[] p = new Piece[ai.length]; for(int i=0; i screenW || pie.y+y<0 || pie.y+y>screenH) { continue; } pie.paint(g, x, y); } } } public boolean is(int ix, int iy, int iw, int ih) { int ix1=ix+iw; int iy1=iy+ih; int size = lines.size(); for(int i=0; i ix21) && (((iy < iy21) && (iy1 > iy21)) || ((iy < iy22) && (iy1 > iy22)))) { return true; } if((ix < ix22) && (ix1 > ix22) && (((iy < iy21) && (iy1 > iy21)) || ((iy < iy22) && (iy1 > iy22)))) { return true; } } } return false; } public boolean is(Sprite s) { if(s==null) return false; return is(s.getX(), s.getY(), s.getWidth(), s.getHeight()); } public int getWidth() { return w; } public int getHeight() { return h; } }