Hi guys, i have a little problem. I program a game like Sokoban. When I make a move with a "man" display flashes. I know that I must use doubleBuffer but i dont know hot to make it in my code. Please can you help me ?
public void initWorld() { int x = OFFSET; int y = OFFSET; Wall wall; Place place; Box box; for (int i = 0; i < level.length(); i++) { char item = level.charAt(i); if (item == '\n') { y += SPACE; x = OFFSET; } else if (item == '#') { wall = new Wall(x, y); walls.add(wall); x += SPACE; } else if (item == '@') { soko = new Player(x, y); x += SPACE; } else if (item == 'o') { box = new Box(x, y); boxes.add(box); x += SPACE; } else if (item == '.') { place = new Place(x, y); areas.add(place); x += SPACE; } else if (item == ' ') { x += SPACE; } h = y; } } public void buildWorld(Graphics g) { g.setColor(new Color(250, 240, 170)); g.fillRect(0, 0, this.getWidth(), this.getHeight()); ArrayList world = new ArrayList(); world.addAll(walls); world.addAll(areas); world.addAll(boxes); world.add(soko); for (int i = 0; i < world.size(); i++) { Actor item = (Actor) world.get(i); g.drawImage(item.getImage(), item.x(), item.y(), this); } } @Override public void paint(Graphics g) { super.paint(g); buildWorld(g); }