alguem pode me dizer como fazer com que a nave se colida com o meteoro ?
preciso usar sprites mesmo ?
[code]import java.io.IOException;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.GameCanvas;
class Tela extends GameCanvas implements Runnable {
public Image nave, fundo, meteoro;
Graphics g;
Thread t;
public Tela() {
super(true);
g = getGraphics();
try {
fundo = Image.createImage("/fundo.png");
meteoro = Image.createImage("/meteoro.png");
nave = Image.createImage("/nave.png");
} catch (IOException e) {}
t = new Thread(this);
t.start();
}
public void run() {
int xM = 0; //coordenada X do meteoro
int yM = 0; //coordenada Y do meteoro
int xNave = 100; //coordenada X da nave
int yNave = 200; //coordenada Y da nave
int velx = 5; // velocidade horizontal
int vely = 2; // velocidade vertical
int velNaveX = 3;
int velNaveY = 3;
int altura = getHeight();
int largura = getWidth();
int tecla;
while (true) {
g.drawImage(fundo, 0, 0, Graphics.TOP | Graphics.LEFT);
g.drawImage(meteoro, xM, yM, Graphics.TOP | Graphics.LEFT);
g.drawImage(nave, xNave, yNave, Graphics.TOP | Graphics.LEFT);
try {
t.sleep(1);
} catch (InterruptedException e) {}
//-------------------------------------------------
tecla = getKeyStates();
if((tecla & UP_PRESSED) != 0)
yNave = Math.max(0, yNave - velNaveY);
if((tecla & DOWN_PRESSED) != 0){
if((yNave + nave.getHeight()) < altura)
yNave = yNave + velNaveY;
}
if ((tecla & LEFT_PRESSED) != 0) {
if (!(xNave <= 0)) {
xNave -= 4;
}
} else if ((tecla & RIGHT_PRESSED) != 0) {
if (!(xNave + nave.getWidth() >= getWidth())) {
xNave += 4;
}
}
//-------------------------------------------------
xM = xM + velx;
yM = yM + vely;
if ((xM + meteoro.getWidth()) > largura || (xM < 0))
velx = -velx;
if ((yM + meteoro.getHeight()) > altura || (yM < 0))
vely = -vely;
//------------------------------------------------
flushGraphics();
}
}
}[/code]