Difference between revisions of "Hello World"
From Slick2D Wiki
(Fixed broken English and changed brace placement to make code easier to read) |
|||
| Line 47: | Line 47: | ||
If a window opens saying 'Howdy!', your setup is fully configured and ready for development. | If a window opens saying 'Howdy!', your setup is fully configured and ready for development. | ||
| + | |||
| + | [[Category:Tutorials]] | ||
Revision as of 15:41, 8 August 2013
To make sure your setup succeeded, create a main class like the following:
package simpleslickgame;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.BasicGame;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
public class SimpleSlickGame extends BasicGame
{
public SimpleSlickGame(String gamename)
{
super(gamename);
}
@Override
public void init(GameContainer gc) throws SlickException {}
@Override
public void update(GameContainer gc, int i) throws SlickException {}
@Override
public void render(GameContainer gc, Graphics g) throws SlickException
{
g.drawString("Howdy!", 10, 10);
}
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);
}
}
}
If a window opens saying 'Howdy!', your setup is fully configured and ready for development.