Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import static org.lwjgl.opengl.GL11.*;
- import java.util.Random;
- import org.lwjgl.opengl.*;
- import org.lwjgl.*;
- import org.lwjgl.input.Keyboard;
- public class Input {
- static int displayHeight = 480;
- static int displayWidth = 640;
- public Input() {
- try {
- Display.setDisplayMode(new DisplayMode(displayWidth, displayHeight));
- Display.setTitle("Input");
- Display.create();
- } catch (LWJGLException e) {
- e.printStackTrace();
- }
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0, displayWidth, displayHeight, 0, 1, -1);
- glMatrixMode(GL_MODELVIEW);
- Display.update();
- while (!Display.isCloseRequested()) {
- glClear(GL_COLOR_BUFFER_BIT);
- if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
- Display.destroy();
- }
- for(int i=1; i<=displayWidth; i+=10){
- Box.draw(i);
- }
- Display.update();
- Display.sync(60);
- }
- Display.destroy();
- }
- private static class Box {
- public static int height;
- public static void draw(int b) {
- Random randomHeight = new Random();
- height = randomHeight.nextInt(30) + 300;
- glBegin(GL_QUADS);
- glVertex2f(b, height); // Upper Left
- glVertex2f(b, displayHeight); // Bottom Left
- glVertex2f(b + 10, displayHeight); // Bottom Right
- glVertex2f(b + 10, height); // Upper Right
- glEnd();
- }
- }
- public static void main(String[] args) {
- new Input();
- }
- }
Add Comment
Please, Sign In to add comment