title: Creating a loop so this animation repeats
body: <p>I made code to draw points (to look like stars) and i made it move but how do i have this animation repeat and not just stop after a few seconds? What's the best way to do this because i don'T want to waste resources on this animation (if it does not erase the points that have lost the screen);</p>
  
  <pre><code>package game;
  
  import static org.lwjgl.opengl.GL11.*;
  import static org.lwjgl.util.glu.GLU.gluPerspective;
  
  import java.util.Random;
  
  import org.lwjgl.input.Keyboard;
  import org.lwjgl.opengl.*;
  import org.lwjgl.*;
  
  public class Main {
  
      public Main() {
          try {
              Display.setDisplayMode(Display.getDesktopDisplayMode());
              Display.setFullscreen(true);
              Display.create();
          } catch(LWJGLException e) {
              e.printStackTrace();
          }
  
          glMatrixMode(GL_PROJECTION);
          glLoadIdentity();
  
          int width = Display.getWidth();
          int height = Display.getHeight();
  
          System.out.println("" + width);
          System.out.println("" + height);
  
          gluPerspective((float) 30, 1280f / 800f, 0.001f, 100);
          glMatrixMode(GL_MODELVIEW);
  
          Point[] points = new Point[10000];
          Random random = new Random();
  
          for(int i=0;i&lt;points.length;i++) {
              points[i] = new Point((random.nextFloat() - 0.5f) * 100f, (random.nextFloat() - 0.5f) * 100f, random.nextInt(200) - 200);
          }
  
          float speed = 0.25f;
  
          while(!Display.isCloseRequested()) {
              glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  
              glTranslatef(0, 0, speed);
  
              glBegin(GL_POINTS);
              for(Point p : points) {
                  glVertex3f(p.x, p.y, p.z);
              }
              glEnd();
  
              System.out.println("" + speed);
  
              Display.update();
  
              Display.sync(60);
          }
      }
  
      public static class Point {
          float x, y, z;
  
          public Point(float x, float y, float z) {
              this.x = x;
              this.y = y;
              this.z = z;
          }
      }
  }
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>now i have this code but the loop is very obvios, does anyone know how i can fix this?</p>
  
  <pre><code>package game;
  
  import static org.lwjgl.opengl.GL11.*;
  import static org.lwjgl.util.glu.GLU.gluPerspective;
  
  import java.util.Random;
  
  import org.lwjgl.opengl.*;
  import org.lwjgl.*;
  
  public class Main {
  
      public Main() {
          try {
              Display.setDisplayMode(Display.getDesktopDisplayMode());
              Display.setFullscreen(true);
              Display.create();
          } catch(LWJGLException e) {
              e.printStackTrace();
          }
  
          glMatrixMode(GL_PROJECTION);
          glLoadIdentity();
  
          int width = Display.getWidth();
          int height = Display.getHeight();
  
          System.out.println("" + width);
          System.out.println("" + height);
  
          gluPerspective((float) 30, 1280f / 800f, 0.001f, 100);
          glMatrixMode(GL_MODELVIEW);
  
          Point[] points = new Point[10000];
          Random random = new Random();
  
          for(int i=0;i&lt;points.length;i++) {
              points[i] = new Point((random.nextFloat() - 0.5f) * 100f, (random.nextFloat() - 0.5f) * 100f, random.nextInt(200) - 200);
          }
  
          float speed = 0.25f;
  
          int count = 0;
  
          while(!Display.isCloseRequested()) {
              glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  
              count++;
              if(count &lt; 100)
                  glTranslatef(0, 0, speed);
                else
                {
                  glTranslatef(0, 0, -100 * speed);
                  count = 0;
                }
  
              glBegin(GL_POINTS);
              for(Point p : points) {
                  glVertex3f(p.x, p.y, p.z);
              }
  
              glTranslatef(0, 0, width);
  
              glBegin(GL_POINTS);
                for(Point p : points) {
                  glVertex3f(p.x, p.y, p.z);
                }
  
              glEnd();
  
              Display.update();
  
              Display.sync(60);
          }
      }
  
      public static class Point {
          float x, y, z;
  
          public Point(float x, float y, float z) {
              this.x = x;
              this.y = y;
              this.z = z;
          }
      }
  }
  </code></pre>