Skip to content

Instantly share code, notes, and snippets.

@massimomusante
Created April 25, 2013 14:18
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 massimomusante/5460043 to your computer and use it in GitHub Desktop.
Save massimomusante/5460043 to your computer and use it in GitHub Desktop.
Code fragments for Slick2d Blog post
...
g.drawString("Hello There!", 100, 100);
...
...
public static void main(String[] args) throws SlickException
{
AppGameContainer app = new AppGameContainer(new DemoHello());
app.setDisplayMode(300, 200, false);
app.start();
}
...
...
private int x = 100;
private int y = 100;
private int dx = 1;
private int dy = 1;
...
...
public void update(GameContainer gc, int delta) throws SlickException
{
if(x>gc.getWidth()) dx = -1;
if(x<0) dx = 1;
if(y>gc.getHeight()) dy = -1;
if(y<0) dy = 1;
x = x+dx;
y = y+dy;
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment