Exemple #1
0
 public void render(Canvas canvas) {
   canvas.save();
   canvas.translate(position.x(), position.y());
   canvas.rotate((float) Math.toDegrees(rotation));
   canvas.drawBitmap(bmp, -bmp.getWidth() / 2, -bmp.getHeight() / 2, paint);
   canvas.restore();
 }
Exemple #2
0
  public void update(float seconds, PlayerShip ship, float boxSize) {
    position.add(velocity.mul(temp, seconds));
    rotation += angularMomentum * seconds;

    while (position.x() < ship.position.x() - boxSize) position.add(boxSize * 2, 0);
    while (position.x() > ship.position.x() + boxSize) position.sub(boxSize * 2, 0);

    while (position.y() < ship.position.y() - boxSize) position.add(0, boxSize * 2);
    while (position.y() > ship.position.y() + boxSize) position.sub(0, boxSize * 2);
  }