habe ein problem...
warum wird das bild nicht angezeigt?
hier der code:
vielen dank im vorraus, aragnatsch
warum wird das bild nicht angezeigt?
hier der code:
Code:
import java.applet.*;
import java.awt.*;
public class castleislands extends Applet implements Runnable {
private static final long serialVersionUID = 1L;
private Image dbImage;
private Graphics dbg;
Image grass;
int x_pos = 10;
int y_pos = 100;
int radius = 20;
boolean walknorth = false;
boolean walksouth = false;
boolean walkeast = false;
boolean walkwest = false;
int[][] map = { {1,1,1,1},
{1,1,1,1},
{1,1,1,1},
{1,1,1,1}};
public void init() {
setSize(800,600);
grass = getImage(getCodeBase(), "grass.gif");
}
public void start() {
Thread th = new Thread(this);
th.start();
}
public void run() {
Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
while (true) {
if (x_pos > 120)
{
x_pos = 10;
}
x_pos = x_pos + 5;
repaint();
try {
Thread.sleep(40);
} catch (InterruptedException ex) {
}
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
}
}
public void paint(Graphics g) {
g.drawImage(grass, 0, 0, this);
g.setColor(Color.red);
g.fillOval(x_pos - radius, y_pos - radius, 2 * radius, 2 * radius);
}
public void update(Graphics g) {
if (dbImage == null) {
dbImage = createImage(this.getSize().width, this.getSize().height);
dbg = dbImage.getGraphics();
}
dbg.setColor(getBackground());
dbg.fillRect(0, 0, this.getSize().width, this.getSize().height);
dbg.setColor(getForeground());
paint(dbg);
g.drawImage(dbImage, 0, 0, this);
}
public void stop() {
}
public void destroy() {
}
}
vielen dank im vorraus, aragnatsch