Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package src;
- import static org.lwjgl.opengl.GL11.*;
- import java.awt.GraphicsDevice;
- import java.awt.GraphicsEnvironment;
- import java.awt.Toolkit;
- import java.awt.event.KeyEvent;
- import java.awt.event.MouseEvent;
- import java.awt.event.WindowEvent;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- import org.lwjgl.LWJGLException;
- import org.lwjgl.input.Keyboard;
- import org.lwjgl.input.Mouse;
- import org.lwjgl.opengl.Display;
- import org.lwjgl.opengl.DisplayMode;
- public class Metamorph
- {
- public static Metamorph instance;
- public static Art art;
- public static SoundEngine sound;
- public static Renderer renderer;
- public EnumScreens currentScreen;
- public static Game game;
- public Metamorph()
- {
- super();
- initMM();
- initGL();
- mainLoop();
- cleanUp();
- }
- public void initMM()
- {
- art = new Art();
- sound = new SoundEngine();
- renderer = new Renderer(art);
- instance = this;
- try
- {
- Display.setDisplayMode(new DisplayMode(1280,720));
- Display.create();
- Mouse.create();
- Keyboard.create();
- Display.setTitle("Metamorph");
- Display.setVSyncEnabled(true);
- } catch (LWJGLException e)
- {
- e.printStackTrace();
- }
- currentScreen = EnumScreens.MAIN;
- }
- public static void initGL()
- {
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0, Display.getWidth(), 0, Display.getHeight(), 1, -1);
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glMatrixMode(GL_MODELVIEW);
- glClearColor(0, 0, 0, 1);
- glDisable(GL_DEPTH_TEST);
- }
- public void mainLoop()
- {
- while(!Display.isCloseRequested())
- {
- handleInput();
- tick();
- render();
- }
- }
- public void render()
- {
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glLoadIdentity();
- glScalef(1.0f, -1.0f, 1.0f);
- glTranslatef(0f, -720f, 0f);
- //glScalef(1280f/800, 720f/500, 1f);
- renderer.render();
- Display.update();
- Display.sync(60);
- }
- public void tick()
- {
- if(game != null)
- game.world.tick();
- }
- public static void cleanUp()
- {
- Display.destroy();
- }
- public static void main(String[] args)
- {
- instance = new Metamorph();
- }
- public void initGame()
- {
- game = new Game();
- game.init();
- }
- public void handleInput()
- {
- if(Mouse.isButtonDown(0))
- {
- System.out.println(Mouse.getX() + " " + Mouse.getY());
- int sel = -1;
- if(Mouse.getX() > 1000 && Mouse.getX() < 1240 && Mouse.getY() > 320 && Mouse.getY() < 700)
- sel = Math.round((Mouse.getY() - 357.5F)/75F);
- if(sel == 0)
- {
- currentScreen = EnumScreens.GAME;
- initGame();
- }
- if(sel == 4)
- {
- cleanUp();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement