Skip to content

Instantly share code, notes, and snippets.

@EbbeVang
Created February 20, 2018 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EbbeVang/aadf28b2d1706c10e5cb31659c929166 to your computer and use it in GitHub Desktop.
Save EbbeVang/aadf28b2d1706c10e5cb31659c929166 to your computer and use it in GitHub Desktop.
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);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment