好的,我正在开发一个游戏,我正在尝试找出为什么光滑的更新方法不起作用,基本上在教程中我正在观看它,但在我的它没有。我在你管教程视频上问过,没有人知道为什么会这样。所以任何帮助将不胜感激。这是我的代码:
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>50 && posx<150)&&(posy>5 && posy<100))
{
System.out.println("in area");
if(Mouse.isButtonDown(0))
{
Display.destroy();
}
}
}
@Override
public int getID() {
return 0;
}
}