public static void main(String[] args) throws Exception { System.setProperty( "org.lwjgl.librarypath", new File(new File("lib\\native"), LWJGLUtil.getPlatformName()).getAbsolutePath()); System.setProperty( "net.java.games.input.librarypath", System.getProperty("org.lwjgl.librarypath")); try { AppGameContainer appgc = new AppGameContainer( new Game(GAME_TITLE)); // Makes a new game container with the specified title. appgc.setDisplayMode(640, 400, false); // Sets the screen size to 640x400. appgc.setTargetFrameRate(60); // Sets the frame rate to 60. appgc.start(); // Starts the game. } catch (SlickException e) { e.printStackTrace(); // Prints an error if it doesn't work. } }
public static void main(String[] args) { // TODO Auto-generated method stub // This is used to find out which OS is being used System.setProperty( "org.lwjgl.librarypath", new File(new File(System.getProperty("user.dir"), "native"), LWJGLUtil.getPlatformName()) .getAbsolutePath()); try { AppGameContainer app = new AppGameContainer(new Game("Game")); app.setDisplayMode(1050, 750, false); app.setTargetFrameRate(60); app.setShowFPS(false); app.start(); } catch (SlickException e) { e.printStackTrace(); } }
public Airport( /*int duration,*/ double newLandingProbability, double newTakeoffProbability, int simulationDelay) { super("Airport Simulator"); // -- AIRPORT SIMULATOR STUFF -- // this.duration = duration; this.currentUpdate = 0; this.newLandingProbability = newLandingProbability; this.newTakeoffProbability = newTakeoffProbability; this.simulationDelay = simulationDelay; this.lastUpdate = System.currentTimeMillis(); rand = new Random(); airQueue = new LinkedList<Airplane>(); groundQueue = new LinkedList<Airplane>(); runway = new Runway(2); // --SLICK STUFF-- System.setProperty( "org.lwjgl.librarypath", System.getProperty("user.dir") + "/lib/native/" + LWJGLUtil.getPlatformName()); System.setProperty( "net.java.games.input.librarypath", System.getProperty("org.lwjgl.librarypath")); try { app = new AppGameContainer(this); app.setDisplayMode(750, 370, false); app.setVSync(true); app.setTargetFrameRate(60); app.start(); } catch (SlickException e) { e.printStackTrace(); } }
private void init() throws LWJGLException { // create Window of size 800x600 Display.setDisplayMode(new DisplayMode(1024, 768)); Display.setLocation( (Display.getDisplayMode().getWidth() - 300) / 2, (Display.getDisplayMode().getHeight() - 300) / 2); Display.setTitle("Gears"); try { Display.create(); } catch (LWJGLException e) { // This COULD be because of a bug! A delay followed by a new attempt is supposed to fix it. e.printStackTrace(); try { Thread.sleep(1000); } catch (InterruptedException ignored) { } Display.create(); } // setup ogl FloatBuffer pos = BufferUtils.createFloatBuffer(4).put(new float[] {5.0f, 5.0f, 10.0f, 0.0f}); FloatBuffer red = BufferUtils.createFloatBuffer(4).put(new float[] {0.8f, 0.1f, 0.0f, 1.0f}); FloatBuffer green = BufferUtils.createFloatBuffer(4).put(new float[] {0.0f, 0.8f, 0.2f, 1.0f}); FloatBuffer blue = BufferUtils.createFloatBuffer(4).put(new float[] {0.2f, 0.2f, 1.0f, 1.0f}); pos.flip(); red.flip(); green.flip(); blue.flip(); glLight(GL_LIGHT0, GL_POSITION, pos); glEnable(GL_CULL_FACE); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); /* make the gears */ gear1 = glGenLists(1); glNewList(gear1, GL_COMPILE); glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red); gear(1.0f, 4.0f, 1.0f, 20, 0.7f); glEndList(); gear2 = glGenLists(1); glNewList(gear2, GL_COMPILE); glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green); gear(0.5f, 2.0f, 2.0f, 10, 0.7f); glEndList(); gear3 = glGenLists(1); glNewList(gear3, GL_COMPILE); glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue); gear(1.3f, 2.0f, 0.5f, 10, 0.7f); glEndList(); glEnable(GL_NORMALIZE); glMatrixMode(GL_PROJECTION); System.err.println("LWJGL: " + Sys.getVersion() + " / " + LWJGLUtil.getPlatformName()); System.err.println("GL_VENDOR: " + glGetString(GL_VENDOR)); System.err.println("GL_RENDERER: " + glGetString(GL_RENDERER)); System.err.println("GL_VERSION: " + glGetString(GL_VERSION)); System.err.println(); System.err.println( "glLoadTransposeMatrixfARB() supported: " + GLContext.getCapabilities().GL_ARB_transpose_matrix); if (!GLContext.getCapabilities().GL_ARB_transpose_matrix) { // --- not using extensions glLoadIdentity(); } else { // --- using extensions final FloatBuffer identityTranspose = BufferUtils.createFloatBuffer(16) .put(new float[] {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}); identityTranspose.flip(); glLoadTransposeMatrixARB(identityTranspose); } float h = (float) 300 / (float) 300; glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0.0f, 0.0f, -40.0f); }