slick2d hello world
import java.util.logging.Level;
import java.util.logging.Logger;
import org.newdawn.slick.*;
public class SimpleSlickGame extends BasicGame
{
Image img;
int x=100;
int y=100;
public SimpleSlickGame(String gamename)
{
super(gamename);
}
@Override
public void init(GameContainer gc) throws SlickException {
img = new Image("assets/pacmanSprite.png");
}
@Override
public void update(GameContainer gc, int i) throws SlickException {
if (x < 500)
{
x++;
}
if (x == 500)
x=0;
}
@Override
public void render(GameContainer gc, Graphics g) throws SlickException
{
g.drawString("Howdy!", 10, 50);
img.draw(x, y);
}
public static void main(String[] args)
{
try
{
AppGameContainer appgc;
appgc = new AppGameContainer(new SimpleSlickGame("Simple Slick Game"));
appgc.setDisplayMode(640, 480, false);
appgc.start();
}
catch (SlickException ex)
{
Logger.getLogger(SimpleSlickGame.class.getName()).log(Level.SEVERE, null, ex);
}
}
}