Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.addictivescripts.bubbles;
- import com.addictivescripts.bubbles.objects.gameobjects.GameObjectsContainer;
- import com.addictivescripts.bubbles.objects.gameobjects.bubbles.RegularBubble;
- import com.addictivescripts.bubbles.objects.gameobjects.bubbles.Size;
- import com.addictivescripts.bubbles.util.api.Point;
- import com.addictivescripts.bubbles.util.data.Constants;
- import org.lwjgl.LWJGLException;
- import org.lwjgl.input.Keyboard;
- import org.lwjgl.input.Mouse;
- import org.lwjgl.opengl.Display;
- import org.lwjgl.opengl.DisplayMode;
- import org.lwjgl.opengl.GL11;
- /**
- * Created with IntelliJ IDEA.
- * User: Sharon
- * Date: 8/4/13
- * Time: 9:57 PM
- * To change this template use File | Settings | File Templates.
- */
- public class Game {
- private long lastFrame = getTime();
- public GameObjectsContainer objectsContainer;
- public static void main(String[] args) {
- new Game();
- }
- private Game() {
- objectsContainer = new GameObjectsContainer();
- objectsContainer.addObject(new RegularBubble(this, new Point(200, 200), Size.FOUR, 4, 0));
- try {
- Display.setDisplayMode(new DisplayMode(Constants.SIZE_WIDTH, Constants.SIZE_HEIGHT));
- Display.setTitle("Bubbles Popper - by KliK");
- Display.create();
- } catch (LWJGLException e) {
- e.printStackTrace();
- }
- initGL();
- while (!Display.isCloseRequested()) {
- int delta = getDelta();
- System.out.println(Mouse.getX() + " " + Mouse.getY());
- GL11.glClearColor(0.8f, 0.8f, 0.8f, 1.0f);
- GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
- if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
- break;
- }
- objectsContainer.update(delta);
- objectsContainer.draw();
- Display.update();
- Display.sync(60);
- }
- Display.destroy();
- }
- public void initGL() {
- GL11.glMatrixMode(GL11.GL_PROJECTION);
- GL11.glLoadIdentity();
- GL11.glOrtho(0, 800, 0, 600, 1, -1);
- GL11.glMatrixMode(GL11.GL_MODELVIEW);
- }
- public long getTime() {
- return System.nanoTime() / 1_000_000;
- }
- public int getDelta() {
- long time = getTime();
- int delta = (int) (time - lastFrame);
- lastFrame = time;
- return delta;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement