Note that there are some explanatory texts on larger screens.

plurals
  1. POSlick Java Library - update method
    primarykey
    data
    text
    <p>Ok I am developing a game and I am trying to work out why the slick update method isn't working, basically in the tutorial I was watching it worked but on mine it doesn't. I asked on the you tube tutorials video and no one knew why this happened. So any help would be appreciated. here is my code:</p> <p><pre></p> <code>package phex.launcher; import static org.lwjgl.opengl.GL11.*; import org.lwjgl.opengl.*; import org.lwjgl.*; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.newdawn.slick.GameContainer; import org.newdawn.slick.Graphics; import org.newdawn.slick.Image; import org.newdawn.slick.SlickException; import org.newdawn.slick.state.BasicGameState; import org.newdawn.slick.state.StateBasedGame; public class Phex extends BasicGameState{ public static int screen; private Image tweet; private Image logo; private Image base; private Graphics g; private GameContainer gc; public Phex() throws SlickException { new LoginButton(); try { Display.setDisplayMode(new DisplayMode(800, 650)); Display.setTitle("Phex Launcher"); Display.setResizable(true); Display.create(); } catch (LWJGLException e) { e.printStackTrace(); Display.destroy(); System.exit(1); } init(gc, null); //Initialisation code(OpenGL) glMatrixMode(GL_PROJECTION); glLoadIdentity(); // Resets any previous projection matrices glOrtho(0, 800, 650, 0, 1, -1); glMatrixMode(GL_MODELVIEW); glEnable(GL_TEXTURE_2D); while(!Display.isCloseRequested()) { //render render(gc, null, g); update(gc, null, 0); } Display.destroy(); } public static void main(String args[]) throws SlickException { new Phex(); } public void init(GameContainer container, StateBasedGame game) throws SlickException { tweet = new Image("img/twitter-logo.png"); logo = new Image("img/logo.png"); base = new Image("img/base-for-login.png"); } public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException { if(Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { Display.destroy(); System.exit(0); } base.draw(0,0); logo.draw(50, 5); tweet.draw(200, 5); //screen renderer screen = 0; if(screen == 0) { } if(screen == 1) { } Display.update(); Display.sync(60); } public void update(GameContainer container, StateBasedGame game, int delta)throws SlickException { int posx = Mouse.getX(); int posy = Mouse.getY(); if((posx&gt;50 &amp;&amp; posx&lt;150)&amp;&amp;(posy&gt;5 &amp;&amp; posy&lt;100)) { System.out.println("in area"); if(Mouse.isButtonDown(0)) { Display.destroy(); } } } @Override public int getID() { return 0; } } </code></pre> <p></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload