I got it right.
I think the problem was the color depth parameter, it cannot be set to 16 or 32, but have to be set with “-1” for Linux …weird…
So, since i’m speaking about linux related problem, there’s also the annoying X11 key repeat problem,
that drove me mad, i was wondering why my animation routines were all shaky…
i looked at the code for hours wondering WhY O whY iT DoeSn’t siMpLY WORK O_O ?!
… well the answer was: 'cause x11key repeat is messing up, there’s nothing wrong with the code itself 
so you can see i take care to test if OS is Linux to disable X11 key repeat… (Runtime.getRuntime().exec(“xset r off”)
here’s a working sample, as of today using ubuntu feisty and java6:
(you can find the rest of the sourcesHere)
import java.awt.Canvas;
import java.awt.Graphics2D;
import java.awt.event.*;
import java.awt.image.BufferStrategy;
import javax.swing.JFrame;
import java.awt.Color;
import java.io.IOException;
import java.awt.GraphicsEnvironment;
import java.awt.GraphicsDevice;
import java.awt.DisplayMode;
public class Game extends Canvas {
public MapLoader maper;
public static Keyb board;
public static boolean up,down,left,right,space;
private static int gameWidth=800;
private static int gameHeight=600;
//private static DisplayMode BDM = new DisplayMode(800, 600, 16, 0);
private BufferStrategy bufferStrategy;
public Game() {
if (System.getProperty("os.name").equals("Linux")) {
try{
// suppress the X11 key repeat problem
Runtime.getRuntime().exec("xset r off");
}
catch(IOException ex){
ex.printStackTrace();
}
}
System.out.printf("System is [%s]\n",System.getProperty("os.name"));
JFrame mainFrame;
mainFrame = new JFrame("bleh");
board = new Keyb();
DisplayMode displayMode = new DisplayMode(gameWidth, gameHeight, -1,
DisplayMode.REFRESH_RATE_UNKNOWN);
GraphicsDevice device = GraphicsEnvironment.
getLocalGraphicsEnvironment().getDefaultScreenDevice();
device.getDefaultConfiguration();
mainFrame.setResizable(false);
mainFrame.setUndecorated(true);
mainFrame.setVisible(true);
mainFrame.createBufferStrategy(2);
bufferStrategy = mainFrame.getBufferStrategy();
device.setFullScreenWindow(mainFrame);
if(device.isDisplayChangeSupported()) {
try {device.setDisplayMode(displayMode);}
catch(IllegalArgumentException exception) {}
mainFrame.setSize(gameWidth, gameHeight);
} else {shutdown();}
validate();
mainFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
shutdown();
}
});
mainFrame.addKeyListener(board);
requestFocus();
maper= new MapLoader(this);
init();
}
public void init(){
maper.loadResources();
maper.setBackground(maper.loadImage("coalescence1280.jpg"));
maper.loader(1);
board.up=false;
board.down=false;
board.left=false;
board.right=false;
dashboard();
}
public void gameLoop() {
long startTime = System.nanoTime();
boolean gameRunning = true;
while (gameRunning) {
long elapsedTime = (System.nanoTime() - startTime) / 1000000;
startTime = System.nanoTime();
Graphics2D g = (Graphics2D) bufferStrategy.getDrawGraphics();
try { Thread.sleep(10); } catch (Exception e) {}
for (int i=0;i<elapsedTime / 5;i++) {
logic();
maper.update((long)i);
maper.draw(g,MapLoader.newx2Map,gameWidth,536,elapsedTime);
//dashboard();
g.dispose();
bufferStrategy.show();
}
/*
if ((elapsedTime % 5) != 0) {
logic();
maper.update(elapsedTime % 5);
maper.draw(g,MapLoader.newx2Map,wwidth,wheight,elapsedTime);
//dashboard();
g.dispose();
strategy.show();
}
*/
}
}
public void dashboard(){
Player zontrox = maper.zontrox;
Graphics2D g = (Graphics2D) bufferStrategy.getDrawGraphics();
g.setColor(Color.black);
g.fillRect(0,536,800,600);
g.setColor(Color.white);
g.drawString("Health",230,563);
g.drawString("Laser",230,575);
g.drawString("Booster",230,587);
g.setPaint(Color.red);
g.fillRect(290,556,Player.MAX_SHIELDS,5);
g.setPaint(Color.blue);
g.fillRect(290+Player.MAX_SHIELDS-zontrox.getShields(),556,zontrox.getShields(),5);
g.drawImage(maper.loadImage("dashboard.png"),0,536,null);
//g.dispose();
//strategy.show();
}
public void logic(){
playerMover();
creatureMover();
}
public void playerMover(){
//Creature player = (Creature)MapLoader.newx2Map.getPlayer();
Player zontrox = maper.zontrox;
float velocityX = 0;
float velocityY = 0;
if (board.left) {
velocityX-=zontrox.getMaxSpeed();
}
if (board.right){
velocityX+=zontrox.getMaxSpeed();
}
if (board.up){
velocityY-=zontrox.getMaxSpeed()*2;
}
if (board.down){
velocityY+=zontrox.getMaxSpeed();
}
if (board.space){
maper.lazer();
}
if (board.exit){
shutdown();
}
zontrox.setVelocityX(velocityX);
zontrox.setVelocityY(velocityY);
}
public void creatureMover(){
Creature gule = (Creature)maper.guleSprite;
if (gule!=null){
if (maper.bump){
//make creature to go the opposite direction on *BUMP*
gule.setVelocityX(gule.getVelocityX()*-1);
}
}
}
public static void shutdown(){
if (System.getProperty("os.name").equals("Linux")) {
try{Runtime.getRuntime().exec("xset r on");}
catch(IOException ex){ex.printStackTrace();}
System.exit(0);
}
}
public static void main(String argv[]) {
Game g =new Game();
g.gameLoop();
}
}