The following code creates a new Slick game. It is not much yet - just a black window. But this window is already an OpenGL frame.
package codebrocken.drones; 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 Drones extends BasicGame { public Drones(String title) { super(title); } @Override public void render(GameContainer arg0, Graphics arg1) throws SlickException { // TODO Auto-generated method stub } @Override public void init(GameContainer arg0) throws SlickException { // TODO Auto-generated method stub } @Override public void update(GameContainer arg0, int arg1) throws SlickException { // TODO Auto-generated method stub } public static void main(String[] args) { try { AppGameContainer appContainer = new AppGameContainer(new Drones("Drones")); appContainer.start(); } catch (SlickException e) { e.printStackTrace(); } } }
The class itself is derived from BasicGame, which does a lot of work for us. We just have to implement a few methods that will do our actual work later. The main method creates a new AppGameContainer and initializes it with our game.
Keine Kommentare:
Kommentar veröffentlichen