Created
February 20, 2018 13:38
-
-
Save EbbeVang/aadf28b2d1706c10e5cb31659c929166 to your computer and use it in GitHub Desktop.
slick2d hello world
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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