Exemplo n.º 1
0
 private Color getColor(Entity e) {
   // Lazy initialisation
   if (!colormap.containsKey(e.getId())) {
     colormap.put(
         e.getId(),
         new Color(
             100 + rand.nextInt() % 126, 60 + rand.nextInt() % 126, 100 + rand.nextInt() % 126));
   }
   return colormap.get(e.getId());
 }
Exemplo n.º 2
0
  private void render(Entity e) {
    Vector pos = e.getPosition();
    // System.out.println(e.getId() + ": ( " + pos.getVar(0) + ", " + pos.getVar(1) + " )");
    glLoadIdentity();

    double x = pos.getVar(0);
    double y = (pos.getDimensions() > 1) ? pos.getVar(1) : 0;
    glTranslated(x, y, 100.0f);

    Color c = getColor(e);
    glColor3b((byte) c.getRed(), (byte) c.getGreen(), (byte) c.getBlue());

    Sphere s = new Sphere();
    s.draw((float) e.getRadius(), 20, 16);
  }
Exemplo n.º 3
0
  /** @param args */
  public static void main(String[] args) {
    Visualiser2D vis = new Visualiser2D();

    EntityFactory.POS_MAGNITUDE_FACTOR = 10000;

    List<Entity> ens = EntityFactory.getEntities(100);

    for (int i = 0; i < 200; i++) {
      for (Entity e : ens) {
        e.Update();
      }
      vis.handleOutput(ens);
    }

    System.out.println("Waiting for close");
    vis.waitForInput();
  }