Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //A massive thank-you to Oskar Veerhoek for showing me how to make a side-scrolling display.
- package Window;
- import static org.lwjgl.opengl.GL11.*;
- import org.lwjgl.input.Keyboard;
- import org.lwjgl.opengl.Display;
- import org.lwjgl.opengl.DisplayMode;
- import org.lwjgl.LWJGLException;
- import Window.GridHandler;
- public class Main {
- static int[][] map = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
- };
- static GridHandler grid = new GridHandler(map);
- public static void main(String[] args) {
- try {
- Display.setDisplayMode(new DisplayMode(1600,832));
- Display.setTitle("Quest to save your house. DevStage 0");
- Display.create();
- } catch (LWJGLException e) {
- e.printStackTrace();
- Display.destroy();
- System.exit(1);
- }
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0, 1600, 832, 0, -1, 1);
- glMatrixMode(GL_MODELVIEW);
- float translate_x = 0;
- float translate_y = 0;
- int speed = 5;
- while(!Keyboard.isKeyDown(Keyboard.KEY_Q)) {
- glClear(GL_COLOR_BUFFER_BIT);
- glPushMatrix();
- glTranslatef(translate_x, translate_y, 0);
- if (Keyboard.isKeyDown(Keyboard.KEY_D)) {
- translate_x += speed;
- }
- if (Keyboard.isKeyDown(Keyboard.KEY_A)) {
- translate_x -= speed;
- }
- if (Keyboard.isKeyDown(Keyboard.KEY_S)) {
- translate_y += speed;
- }
- if (Keyboard.isKeyDown(Keyboard.KEY_W)) {
- translate_y -= speed;
- }
- glPopMatrix();
- Display.update();
- Display.sync(60);
- }
- Display.destroy();
- System.exit(0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement