Guest User

Untitled

a guest
Apr 26th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.64 KB | None | 0 0
  1. package Engine;
  2.  
  3. import java.util.ArrayList;
  4. import org.lwjgl.opengl.GL11;
  5.  
  6. /**
  7.  *
  8.  * @author Jocke
  9.  */
  10. public class Scene {
  11.     private ArrayList<Object> objects;
  12.    
  13.     public void render() {
  14.         for (int i = 0; i < objects.size(); i++) {
  15.             objects.get(i).draw();
  16.         }
  17.     }
  18.    
  19.     public void addObject(Object o) {
  20.         this.objects.add(o);
  21.     }
  22.    
  23.     public void delObject(int index) {
  24.         this.objects.remove(index);
  25.     }
  26.    
  27.     public void delObject(Object o) {
  28.         this.objects.remove(o);
  29.     }
  30.    
  31.     public class Object {
  32.         protected boolean visible;
  33.        
  34.         protected int x;
  35.         protected int y;
  36.         protected int z;
  37.         protected int w;
  38.         protected int h;
  39.        
  40.         Object(String filename) {
  41.             if (filename.isEmpty()) {
  42.                 this.w = 32;
  43.                 this.h = 32;
  44.             }
  45.            
  46.             this.x = 0;
  47.             this.y = 0;
  48.            
  49.             this.visible = true;
  50.             objects.add(this);
  51.         }
  52.        
  53.         public void draw() {
  54.             GL11.glColor3f(1.0f, 1.0f, 1.0f);
  55.             GL11.glBegin(GL11.GL_QUADS);
  56.                 GL11.glVertex3d(x, y, z);
  57.                 GL11.glVertex3d(x+w, y, z);
  58.                 GL11.glVertex3d(x+w, y+h, z);
  59.                 GL11.glVertex3d(x, y+h, z);
  60.             GL11.glEnd();          
  61.         }
  62.        
  63.         public void setPos(int x, int y) {
  64.             this.x = x;
  65.             this.y = y;
  66.         }
  67.        
  68.         public void setVisible(boolean b) {
  69.             this.visible = b;
  70.         }
  71.     }
  72. }
Add Comment
Please, Sign In to add comment