Init project
This commit is contained in:
58
src/ru/dmitriymx/game/Main.java
Normal file
58
src/ru/dmitriymx/game/Main.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package ru.dmitriymx.game;
|
||||
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.opengl.Display;
|
||||
import org.lwjgl.opengl.DisplayMode;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class Main {
|
||||
private Foxy foxy;
|
||||
|
||||
private void init_display(int width, int height){
|
||||
try {
|
||||
Display.setDisplayMode(new DisplayMode(width, height));
|
||||
Display.setVSyncEnabled(true);
|
||||
Display.create();
|
||||
} catch (LWJGLException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
private void init_opengl(int width, int height) {
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glClearColor(0, 0, 0.3f, 0);
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
GL11.glMatrixMode(GL11.GL_PROJECTION);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glOrtho(0, width, height, 0, 1, -1);
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
}
|
||||
|
||||
private void render(){
|
||||
foxy.render();
|
||||
}
|
||||
|
||||
public void start(int width, int height){
|
||||
init_display(width, height);
|
||||
init_opengl(width, height);
|
||||
|
||||
foxy = new Foxy();
|
||||
|
||||
while(!Display.isCloseRequested()){
|
||||
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
|
||||
render();
|
||||
Display.update();
|
||||
Display.sync(12);
|
||||
}
|
||||
|
||||
Display.destroy();
|
||||
}
|
||||
|
||||
public static void main(String[] args){
|
||||
new Main().start(800,600);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user