コード例 #1
0
  public void turnLeft(int degrees) {
    Vector oldVelocity = model.getVelocity();
    double angle = oldVelocity.getAngle();

    Vector newVelocity = Vector.getUnitVector((int) (angle - degrees));
    model.setVelocity(newVelocity.snapTo());
  }
コード例 #2
0
 public void forward(int pixels) {
   Vector oldVelocity = model.getVelocity();
   Vector newVelocity = oldVelocity.scale(pixels);
   model.setVelocity(newVelocity);
   model.step();
 }