Exemple #1
0
 Drawable createDrawable() {
   Drawable d = new Drawable();
   d.shape = createCurrentShape();
   d.color = color;
   d.filled = fillMode;
   return d;
 }
Exemple #2
0
 // DIRECT repaint method
 public void repaint2() {
   Canvas c = null;
   try {
     c = getHolder().lockCanvas();
     if (c != null) {
       // enable anti-aliasing
       c.setDrawFilter(new PaintFlagsDrawFilter(1, Paint.ANTI_ALIAS_FLAG));
       // clean background
       Paint paint = new Paint();
       paint.setColor(drawable.getBackground().getAndroidColor());
       c.drawRect(0, 0, c.getWidth(), c.getHeight(), paint);
       // set dimensions
       drawable.setWidth(getWidth());
       drawable.setHeight(getHeight());
       // do the drawing
       drawable.draw(new Graphics(c));
     }
   } catch (Exception e) {
     // ignore
   } finally {
     if (c != null) {
       getHolder().unlockCanvasAndPost(c);
     }
   }
 }
  public DrawableContainerConstantState(
      DrawableContainerConstantState state, DrawableContainer owner) {
    this.owner = owner;

    if (state != null) {
      List<Drawable> drawables = new ArrayList<>();

      for (Drawable drawable : state.getDrawables()) {
        Drawable copyDrawable = drawable.copy();
        copyDrawable.setDelegate(owner);

        drawables.add(copyDrawable);
      }

      this.drawables = drawables;
      this.constantIntrinsicSize = state.constantIntrinsicSize;
      this.constantMinimumSize = state.constantMinimumSize;
      this.constantSizeComputed = state.constantSizeComputed;
      this.haveStateful = state.haveStateful;
      this.stateful = state.stateful;
      this.paddingComputed = state.paddingComputed;
      this.padding = state.padding;
      this.hasPadding = state.hasPadding;
    } else {
      this.drawables = new ArrayList<>();
    }
  }
  public boolean isStateful() {
    if (haveStateful) {
      return stateful;
    }
    boolean stateful = false;
    for (Drawable drawable : drawables) {
      if (drawable.isStateful()) {
        stateful = true;
        break;
      }
    }
    this.stateful = stateful;
    haveStateful = true;

    return stateful;
  }
Exemple #5
0
  @Override
  protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    super.onLayout(changed, left, top, right, bottom);

    landscape = (right - left) > (bottom - top);
    if (changed) drawable.onLayout(landscape);
  }
Exemple #6
0
 @Override
 public void draw(Vec2 pos) {
   super.draw(pos);
   Graphics2D.fillRect(pos.add(new Vec2(-20, -20)), new Vec2(40, 6), BLACK);
   Graphics2D.fillRect(pos.add(new Vec2(-20, -20)), new Vec2(40. * health / maxHealth, 6), GREEN);
   Graphics2D.drawRect(pos.add(new Vec2(-20, -20)), new Vec2(40, 6), BLACK);
 }
 public void mouseClicked(MouseEvent e) {
   x = -1;
   y = -1;
   width = -1;
   height = -1;
   drawable.repaint();
 }
  public void addChildDrawable(Drawable drawable) {
    drawables.add(drawable);
    drawable.setDelegate(this.owner);

    this.haveStateful = false;
    this.constantSizeComputed = false;
    this.paddingComputed = false;
  }
 public void mouseDragged(MouseEvent e) {
   if (x == -1) {
     return;
   }
   width = e.getX() - x;
   height = e.getY() - y;
   drawable.repaint();
 }
 public void draw(RenderContext context) {
   context.beginTransformation();
   context.translate(offset.add(new Vector(isVerticallyMirrored ? 1 : 0, 0)));
   context.translate(rotationCenter);
   context.scale(scale.multiply(new Vector(isVerticallyMirrored ? -1 : 1, 1)));
   context.rotate(angle);
   context.translate(rotationCenter.negate());
   drawable.draw(context);
   context.endTransformation();
 }
  public void computePadding() {
    UIEdgeInsets padding = UIEdgeInsets.Zero();
    boolean hasPadding = false;

    for (Drawable drawable : drawables) {
      if (drawable.hasPadding()) {
        hasPadding = true;

        UIEdgeInsets childPadding = drawable.getPadding();
        padding.setLeft(Math.max(padding.getLeft(), childPadding.getLeft()));
        padding.setRight(Math.max(padding.getRight(), childPadding.getRight()));
        padding.setTop(Math.max(padding.getTop(), childPadding.getTop()));
        padding.setBottom(Math.max(padding.getBottom(), childPadding.getBottom()));
      }
    }

    this.padding = padding;
    this.hasPadding = hasPadding;
    this.paddingComputed = true;
  }
Exemple #12
0
  /*
     finalizeLatestTime() should be invoked BEFORE
     mergeVerticalShadowBufs() and shiftHorizontalShadowBuf() are called
  */
  public void finalizeLatestTime(final Drawable last_drawable_added) {
    if (childnode == null) // i.e. if ( super.isLeaf() )
    super.setLatestTime(last_drawable_added.getLatestTime());
    else // if ( childnode != null )
    super.setLatestTime(childnode.getLatestTime());

    if (shadowbuf != null) {
      // After setting the LatestTime, seal the shadows' category weights
      shadowbuf.setLatestTime(super.getLatestTime());
      shadowbuf.initializeMapOfCategoryWeights();
    }
  }
 public void drawsetup(Sprite.Drawer drawer, Coord dc, Coord sz) {
   Drawable d = getattr(Drawable.class);
   String resourceName = resname();
   hide = false;
   Coord dro = drawoff();
   for (Overlay ol : ols) {
     if (ol.spr != null) {
       ol.spr.setup(drawer, dc, dro);
     }
   }
   if (Config.hide) {
     for (String objectName : Config.hideObjectList) {
       if (resourceName.indexOf(objectName) != -1) {
         hide = true;
       }
     }
   }
   if (d != null && !hide) {
     d.setup(drawer, dc, dro);
   }
 }
  public void computeConstantSize() {
    CGSize minSize = CGSize.Zero();
    CGSize intrinsicSize = CGSize.Zero();

    for (Drawable drawable : drawables) {
      CGSize min = drawable.getMinimumSize();
      CGSize intrinsic = drawable.getIntrinsicSize();

      if (min.getWidth() > minSize.getWidth()) minSize.setWidth(min.getWidth());
      if (min.getHeight() > minSize.getHeight()) minSize.setHeight(min.getHeight());

      if (intrinsic.getWidth() > intrinsicSize.getWidth())
        intrinsicSize.setWidth(intrinsic.getWidth());
      if (intrinsic.getHeight() > intrinsicSize.getHeight())
        intrinsicSize.setHeight(intrinsic.getHeight());
    }

    this.constantIntrinsicSize = intrinsicSize;
    this.constantMinimumSize = minSize;
    this.constantSizeComputed = true;
  }
Exemple #15
0
 /**
  * Returns the minimal bounds which contains all data in the scene.
  *
  * @return the data bounds
  */
 public Bounds dataBounds() {
   Bounds bounds = new Bounds();
   for (Drawable<T> d : getAllDrawables()) bounds = (Bounds) bounds.union(d.getBounds());
   return bounds;
 }
 @Override
 public void setPosition(float x, float y, int horizontal, int vertical) {
   // Set position then scrol
   super.setPosition(x, y, horizontal, vertical);
   scroll(0, 0);
 }
Exemple #17
0
 public void setShowLabels(boolean showLabels) {
   if (drawable != null) drawable.setShowLabels(showLabels);
 }
Exemple #18
0
 public void setTitle(String title) {
   if (drawable != null) drawable.setTitle(title);
 }
Exemple #19
0
  public void init(final Context context, AttributeSet attrs) {
    // register our interest in hearing about changes to our surface
    SurfaceHolder holder = getHolder();
    holder.addCallback(this);
    // make sure we get key events
    setFocusable(true);

    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);

    // read attributes
    if (attrs != null) {
      try {
        // create configured widget
        String[] widgets = {
          "Tacho", "Kompass", "Bar", "BatteryBar", "Plotter", "Label", "Timeplot", "BarGraph"
        };
        TypedArray attributes =
            context.getTheme().obtainStyledAttributes(attrs, R.styleable.WidgetView, 0, 0);
        int widgetIndex = attributes.getInt(R.styleable.WidgetView_widget, 0);
        if (widgetIndex < widgets.length) {
          String widget = widgets[widgetIndex];
          // MainActivity.debug("WidgetView: I am a "+widget);
          Class clazz = Class.forName("lu.fisch.canze.widgets." + widget);
          Constructor<?> constructor = clazz.getConstructor(null);
          drawable = (Drawable) constructor.newInstance();
          drawable.setDrawSurface(this);
          // apply attributes
          setMin(attributes.getInt(R.styleable.WidgetView_min, 0));
          setMax(attributes.getInt(R.styleable.WidgetView_max, 0));
          setMajorTicks(attributes.getInt(R.styleable.WidgetView_majorTicks, 0));
          setMinorTicks(attributes.getInt(R.styleable.WidgetView_minorTicks, 0));
          setTitle(attributes.getString(R.styleable.WidgetView_text));
          setShowLabels(attributes.getBoolean(R.styleable.WidgetView_showLabels, true));
          setShowValue(attributes.getBoolean(R.styleable.WidgetView_showValue, true));
          setInverted(attributes.getBoolean(R.styleable.WidgetView_isInverted, false));
          fieldSID = attributes.getString(R.styleable.WidgetView_fieldSID);

          String colorRangesJson = attributes.getString(R.styleable.WidgetView_colorRanges);
          if (!colorRangesJson.trim().isEmpty())
            setColorRanges(new ColorRanges(colorRangesJson.replace("'", "\"")));

          // MainActivity.debug("WidgetView: My SID is "+fieldSID);

          if (MainActivity.milesMode) setTitle(drawable.getTitle().replace("km", "mi"));

          repaint();
        } else {
          MainActivity.debug(
              "WidgetIndex " + widgetIndex + " is wrong!? Not registered in <WidgetView>?");
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    // in case your application needs one or more timers,
    // you have to put them here
    /*Timer timer = new Timer();
          timer.schedule(new TimerTask() {
    	@Override
    	public void run() {
    		repaint();
    	}
    }, 100, 100);
    */
  }
Exemple #20
0
 public void execute() {
   drawable_.setStroke(stroke);
 }
Exemple #21
0
  public void init(final Context context, AttributeSet attrs) {
    // register our interest in hearing about changes to our surface
    SurfaceHolder holder = getHolder();
    holder.addCallback(this);
    // make sure we get key events
    setFocusable(true);

    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);

    // read attributes
    if (attrs != null) {
      try {
        // create configured widget
        String[] widgets = {
          "Tacho", "Kompass", "Bar", "BatteryBar", "Plotter", "Label", "Timeplot", "BarGraph"
        };
        TypedArray attributes =
            context.getTheme().obtainStyledAttributes(attrs, R.styleable.WidgetView, 0, 0);
        int widgetIndex = attributes.getInt(R.styleable.WidgetView_widget, 0);
        if (widgetIndex < widgets.length) {
          String widget = widgets[widgetIndex];
          // MainActivity.debug("WidgetView: I am a "+widget);
          Class clazz = Class.forName("lu.fisch.canze.widgets." + widget);
          Constructor<?> constructor = clazz.getConstructor(null);
          drawable = (Drawable) constructor.newInstance();
          drawable.setDrawSurface(WidgetView.this);
          // apply attributes
          drawable.setMin(
              Integer.valueOf(
                  extractCarValue(attributes.getString(R.styleable.WidgetView_min).split(","))));
          drawable.setMax(
              Integer.valueOf(
                  extractCarValue(attributes.getString(R.styleable.WidgetView_max).split(","))));
          // drawable.setMin(attributes.getInt(R.styleable.WidgetView_min, 0));
          // drawable.setMax(attributes.getInt(R.styleable.WidgetView_max, 0));
          drawable.setMajorTicks(
              Integer.valueOf(
                  extractCarValue(
                      attributes.getString(R.styleable.WidgetView_majorTicks).split(","))));
          drawable.setMinorTicks(
              Integer.valueOf(
                  extractCarValue(
                      attributes.getString(R.styleable.WidgetView_minorTicks).split(","))));
          // drawable.setMajorTicks(attributes.getInt(R.styleable.WidgetView_majorTicks, 0));
          // drawable.setMinorTicks(attributes.getInt(R.styleable.WidgetView_minorTicks, 0));
          drawable.setTitle(attributes.getString(R.styleable.WidgetView_text));
          drawable.setShowLabels(attributes.getBoolean(R.styleable.WidgetView_showLabels, true));
          drawable.setShowValue(attributes.getBoolean(R.styleable.WidgetView_showValue, true));
          drawable.setInverted(attributes.getBoolean(R.styleable.WidgetView_isInverted, false));

          String colorRangesJson = attributes.getString(R.styleable.WidgetView_colorRanges);
          if (colorRangesJson != null && !colorRangesJson.trim().isEmpty())
            drawable.setColorRanges(new ColorRanges(colorRangesJson.replace("'", "\"")));

          String foreground = attributes.getString(R.styleable.WidgetView_foregroundColor);
          if (foreground != null && !foreground.isEmpty())
            drawable.setForeground(Color.decode(foreground));

          String background = attributes.getString(R.styleable.WidgetView_backgroundColor);
          if (background != null && !background.isEmpty())
            drawable.setBackground(Color.decode(background));

          String intermediate = attributes.getString(R.styleable.WidgetView_intermediateColor);
          if (intermediate != null && !intermediate.isEmpty())
            drawable.setIntermediate(Color.decode(intermediate));

          String titleColor = attributes.getString(R.styleable.WidgetView_titleColor);
          if (titleColor != null && !titleColor.isEmpty())
            drawable.setTitleColor(Color.decode(titleColor));

          String intervalJson = attributes.getString(R.styleable.WidgetView_intervals);
          if (intervalJson != null && !intervalJson.trim().isEmpty())
            drawable.setIntervals(new Intervals(intervalJson.replace("'", "\"")));

          String optionsJson = attributes.getString(R.styleable.WidgetView_options);
          if (optionsJson != null && !optionsJson.trim().isEmpty())
            drawable.setOptions(new Options(optionsJson.replace("'", "\"")));

          // drawable.setMinAlt(attributes.getInt(R.styleable.WidgetView_minAlt, -1));
          // drawable.setMaxAlt(attributes.getInt(R.styleable.WidgetView_maxAlt, -1));

          String minAlt = attributes.getString(R.styleable.WidgetView_minAlt);
          if (minAlt != null && !minAlt.trim().isEmpty())
            drawable.setMinAlt(Integer.valueOf(extractCarValue(minAlt.split(","))));

          String maxAlt = attributes.getString(R.styleable.WidgetView_maxAlt);
          if (maxAlt != null && !maxAlt.trim().isEmpty())
            drawable.setMaxAlt(Integer.valueOf(extractCarValue(maxAlt.split(","))));

          drawable.setTimeScale(attributes.getInt(R.styleable.WidgetView_timeScale, 1));

          fieldSID = attributes.getString(R.styleable.WidgetView_fieldSID);
          if (fieldSID != null) {
            String[] sids = fieldSID.split(",");
            for (int s = 0; s < sids.length; s++) {
              Field field = MainActivity.fields.getBySID(sids[s]);
              if (field == null) {
                MainActivity.debug(
                    "WidgetView: init: Field with SID <"
                        + sids[s]
                        + "> (index <"
                        + s
                        + "> in <"
                        + R.styleable.WidgetView_text
                        + "> not found!");
              } else {
                // add field to list of registered sids for this widget
                drawable.addField(field.getSID());
                // add listener
                field.addListener(drawable);
                // add filter to reader
                int interval = drawable.getIntervals().getInterval(field.getSID());
                if (interval == -1) MainActivity.device.addActivityField(field);
                else MainActivity.device.addActivityField(field, interval);
              }
            }
          }
          // MainActivity.debug("WidgetView: My SID is "+fieldSID);

          if (MainActivity.milesMode) drawable.setTitle(drawable.getTitle().replace("km", "mi"));
        } else {
          MainActivity.debug(
              "WidgetView: init: WidgetIndex "
                  + widgetIndex
                  + " is wrong!? Not registered in <WidgetView>?");
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    // in case your application needs one or more timers,
    // you have to put them here
    /*Timer timer = new Timer();
          timer.schedule(new TimerTask() {
    	@Override
    	public void run() {
    		repaint();
    	}
    }, 100, 100);
    */
  }
Exemple #22
0
 public void reset() {
   drawable.reset();
   repaint();
 }
Exemple #23
0
 public void setInverted(boolean inverted) {
   drawable.setInverted(inverted);
 }
Exemple #24
0
 public void setColorRanges(ColorRanges colorRanges) {
   drawable.setColorRanges(colorRanges);
 }
  private void render() {
    ArrayList<NetworkMessage> messages = networkController.getMessages();

    for (NetworkMessage message : messages) {
      String messageType =
          message.getClass().getName().replace("NetworkMessages.", "").replace("Messages.", "");
      switch (messageType) {
        case "PelletPositionMessage":
          {
            PelletPositionMessage m = (PelletPositionMessage) message;
            Drawable drawable = getCachedDrawable(m.id);
            if (drawable != null) {
              drawable.node.relocate(m.x, m.y);
              drawable.cacheMisses = 0;
            } else {
              Random r = new Random();
              Node node =
                  drawCircle(
                      m.x, m.y, 5, new Color(r.nextFloat(), r.nextFloat(), r.nextFloat(), 1));
              drawableCache.add(new Drawable(m.id, node));
            }
          }
          break;
        case "BlobStateMessage":
          {
            BlobStateMessage m = (BlobStateMessage) message;
            Color color = Color.web(m.color);
            Node node;
            if (color.getBrightness() != 0) {
              node = drawCircle(m.x, m.y, m.size / 2, color);
            } else {
              node = drawCircle(m.x, m.y, m.size / 2, color.brighter().brighter());
            }
            Node nameText =
                drawText((m.x - m.username.length() * 5), (m.y - m.size / 2), m.username, color);
            Drawable drawable = getCachedDrawable(m.id);
            if (drawable != null) {
              node.setLayoutX((drawable.node.getTranslateX() - m.x) / 10000);
              node.setLayoutY((drawable.node.getTranslateY() - m.y) / 10000);
              drawable.node = node;
              drawable.cacheMisses = 0;
              Drawable nameTag = getCachedDrawable(m.id + 9000);
              nameTag.node = nameText;
              nameTag.cacheMisses = 0;
            } else {
              drawableCache.add(new Drawable(m.id, node));
              drawableCache.add(new Drawable(m.id + 9000, nameText));
            }
          }
          break;
        case "PingMessage":
          {
            renderPane.getChildren().clear();
            ArrayList<Drawable> drawables = new ArrayList<>(drawableCache);
            for (Drawable drawable : drawables) {
              if (drawable.cacheMisses > 1) {
                drawableCache.remove(drawable);
              }
              drawable.cacheMisses++;
              renderPane.getChildren().add(drawable.node);
            }
            renderPane.getChildren().addAll(chatBox, chatInput, lagLabel, scores);

            lag = System.currentTimeMillis() - lastReceivedTime;
            lastReceivedTime = System.currentTimeMillis();
            lagLabel.setText("Net Lag: " + Long.toString(lag));
          }
          break;
        case "HighScoreMessage":
          {
            HighScoreMessage m = (HighScoreMessage) message;
            highScores.setText("HIGH SCORES:" + m.text);
          }
          break;
        case "CurrentScoreMessage":
          {
            CurrentScoreMessage m = (CurrentScoreMessage) message;
            currentScores.setText("Current Scores:" + m.text);
          }
          break;
        case "ChatMessage":
          {
            ChatMessage m = (ChatMessage) message;
            chatBox.appendText(m.username + "> " + m.text + "\n");
          }
          break;
      }
    }
  }
 /** Demande l'affichage des statistiques. */
 @Override
 public void displayStatistics() {
   super.displayStatistics();
 }
  @Override
  public void onUpdate() {
    cur = now;
    now = getTimeSinceStartMillis();
    TIME_DELTA = (now - cur) / 100.0f;
    if (current_world != null && !isPaused()) {
      if (!dontUpdate) {
        Iterator<UpdatableDrawable> updates = current_world.getUpdatables();
        while (updates.hasNext()) {
          UpdatableDrawable s = updates.next();
          if (s == null) continue;
          try {
            s.update();
          } catch (Throwable t) {
            t.printStackTrace();
          }
        }
      }
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      glClearColor(0f, 0f, 0f, 1f);
      // ROBO //todo get this crap changed into proper ogl
      glMatrixMode(GL_MODELVIEW);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
      glLoadIdentity();
      glScalef(ZOOM_SCALE, ZOOM_SCALE, 1f);

      // ROBO //todo change this crap into proper postprocess and per material shaders
      ShaderFactory.executePreRender();

      if (isFading) {
        long time = getTime() - startTime;
        curAlpha = Camera.ease(startAlpha, newAlpha, speed, time);
        if (curAlpha == newAlpha) {
          isFading = false;
        }
      }
      if (isFadingBox) {
        long time = getTime() - startTime;
        float alpha = Camera.ease(0f, 1f, speed, time);
        if (alpha == 1f) {
          isFadingBox = false;
        }
        glColor4f(1f, 1f, 1f, alpha);
        renderBox();
      }

      glTranslatef(-Camera.getX(), -Camera.getY(), 0f);

      glColor4f(1f, 1f, 1f, curAlpha);
      // ROBO //todo get all these into proper batches

      if (curAlpha > 0f) {
        Iterator<Drawable> usprites = current_world.getUnsortedDrawables();
        while (usprites.hasNext()) {
          Drawable s = usprites.next();
          if (s == null) continue;
          try {
            if (!s.neverClip()
                && (!(s instanceof TileObject) || !((TileObject) s).isParallaxLayer())
                && Camera.isOffScreen(s.getX(), s.getY(), s.getWidth() / 2, s.getHeight() / 2))
              continue;
            s.render();
          } catch (Throwable t) {
            t.printStackTrace();
          }
        }

        Iterator<Drawable> sprites = current_world.getSortedDrawables();
        while (sprites.hasNext()) {
          Drawable s = sprites.next();
          if (s == null) continue;
          try {
            if (!s.neverClip()
                && (!(s instanceof TileObject) || !((TileObject) s).isParallaxLayer())
                && Camera.isOffScreen(s.getX(), s.getY(), s.getWidth() / 2, s.getHeight() / 2))
              continue;
            s.render();
          } catch (Throwable t) {
            t.printStackTrace();
          }
        }
      }

      ShaderFactory.executePostRender();

      glLoadIdentity();
      glScalef(ZOOM_SCALE, ZOOM_SCALE, 1f);

      if (show_ui) {
        for (UI e : current_world.getElements()) {
          if (e == null) return;
          try {
            e.render();
          } catch (Throwable t) {
            t.printStackTrace();
          }
        }
      }

      if (next_world != null) {
        long time = getTime() - fadeStartTime;
        float percent;
        if (time > fadeDuration) {
          percent = 1;
        } else {
          percent = time / fadeDuration;
        }
        float emu = curAlpha;
        curAlpha =
            percent; // Some drawables require the curAlpha to be set, so we save what it use to be
        // and set it
        glColor4f(1f, 1f, 1f, curAlpha);

        Iterator<Drawable> next_sprites = next_world.getSortedDrawables();
        while (next_sprites.hasNext()) {
          Drawable s = next_sprites.next();
          if (s == null) continue;
          try {
            if (!s.neverClip()
                && (!(s instanceof TileObject) || !((TileObject) s).isParallaxLayer())
                && Camera.isOffScreen(s.getX(), s.getY(), s.getWidth() / 2, s.getHeight() / 2))
              continue;
            s.render();
          } catch (Throwable t) {
            t.printStackTrace();
          }
        }

        glLoadIdentity();
        glScalef(ZOOM_SCALE, ZOOM_SCALE, 1f);

        for (UI e : next_world.getElements()) {
          if (e == null) return;
          try {
            e.render();
          } catch (Throwable t) {
            t.printStackTrace();
          }
        }

        curAlpha = emu;

        if (percent == 1) {
          current_world.onUnload();
          current_world = next_world;
          current_world.onDisplay();
          next_world = null;
        }
      }

      try {
        AnimationFactory.executeTick(); // Execute any animation
      } catch (IllegalAccessException e) {
        e.printStackTrace();
      }

      Camera.executeAnimation(); // Execute any interlop
      // exitOnGLError("RenderService.renderSprites");

      Display.update();

      fpsTime += TIME_DELTA;
      fpsCount++;
      if (fpsCount == 100) {
        fpsCount = 0;
        FPS = (1000f / fpsTime);
        Display.setTitle("FPS: " + FPS);
        fpsTime = 0;
      }
      if (Display.isCloseRequested()) {
        kill();
      }

      if (GameSettings.Graphics.FPSLimit != -1) {
        Display.sync(GameSettings.Graphics.FPSLimit);
      }
    } else {
      try {
        Thread.sleep(15); // Keep the thread busy
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
Exemple #28
0
 public void setShowValue(boolean showValue) {
   if (drawable != null) drawable.setShowValue(showValue);
 }
Exemple #29
0
 private void drawObjects() {
   for (Drawable d : drawableStorage.getAllElements()) d.draw(backBufferContext);
 }
Exemple #30
0
 public void setDrawable(Drawable drawable) {
   this.drawable = drawable;
   // if(drawable.getDrawSurface()==null)
   drawable.setDrawSurface(this);
   repaint();
 }