Exemplo n.º 1
0
  @Override
  public void handle(long now) {
    this.gc.setFill(Color.WHITE);
    this.gc.fillRect(0, 0, Game.SCENE_WIDTH, Game.SCENE_HEIGHT);

    this.gc.setFill(Color.BLACK);
    synchronized (this.entities) {
      for (Entity<?> entity : this.entities) {
        this.gc.fillRect(
            entity.getLocation().getX() * Game.SCALE - this.cameraPos.getX(),
            entity.getLocation().getY() * Game.SCALE - this.cameraPos.getY(),
            entity.getHitbox().getWidth() * Game.SCALE,
            entity.getHitbox().getHeight() * Game.SCALE);
      }
    }
  }
Exemplo n.º 2
0
 @Override
 public void update(WorldEvent e) {
   if (e.getType() == WorldEvent.Type.WORLD_UPDATE) {
     World w = e.getSource();
     synchronized (this.entities) {
       this.entities.clear();
       for (Entity<?> entity : w.getEntities()) {
         this.entities.add((Entity<?>) entity.clone());
         if (entity instanceof MarioBody) {
           this.cameraPos =
               new Point2D(
                   (int) (entity.getLocation().getX() * Game.SCALE - Game.SCENE_WIDTH / 2 + 0.5),
                   0);
         }
       }
     }
   }
 }