Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Engine;
- import java.util.ArrayList;
- import org.lwjgl.opengl.GL11;
- /**
- *
- * @author Jocke
- */
- public class Scene {
- private ArrayList<Object> objects;
- public void render() {
- for (int i = 0; i < objects.size(); i++) {
- objects.get(i).draw();
- }
- }
- public void addObject(Object o) {
- this.objects.add(o);
- }
- public void delObject(int index) {
- this.objects.remove(index);
- }
- public void delObject(Object o) {
- this.objects.remove(o);
- }
- public class Object {
- protected boolean visible;
- protected int x;
- protected int y;
- protected int z;
- protected int w;
- protected int h;
- Object(String filename) {
- if (filename.isEmpty()) {
- this.w = 32;
- this.h = 32;
- }
- this.x = 0;
- this.y = 0;
- this.visible = true;
- objects.add(this);
- }
- public void draw() {
- GL11.glColor3f(1.0f, 1.0f, 1.0f);
- GL11.glBegin(GL11.GL_QUADS);
- GL11.glVertex3d(x, y, z);
- GL11.glVertex3d(x+w, y, z);
- GL11.glVertex3d(x+w, y+h, z);
- GL11.glVertex3d(x, y+h, z);
- GL11.glEnd();
- }
- public void setPos(int x, int y) {
- this.x = x;
- this.y = y;
- }
- public void setVisible(boolean b) {
- this.visible = b;
- }
- }
- }
Add Comment
Please, Sign In to add comment