示例#1
0
  /** Move the snake by one field. */
  public void move() {
    currentDirection = nextDirection;

    Field newHead = grid.getFromDirection(head, currentDirection);

    if (newHead.getState().equals(State.TAIL)) {
      collision.set(true);
      return;
    }

    boolean grow = false;
    if (newHead.getState().equals(State.FOOD)) {
      grow = true;
    }

    Field lastField = head;

    for (int i = 0; i < tail.size(); i++) {
      Field f = tail.get(i);

      lastField.changeState(State.TAIL);
      tail.set(i, lastField);

      lastField = f;
    }

    if (grow) {
      grow(lastField);
      addPoints();
    } else {
      lastField.changeState(State.EMPTY);
    }

    setHead(newHead);
  }
示例#2
0
 /** Creates a new {@link FXViewer}. */
 public FXViewer() {
   super();
   // add binding to viewer focused property to have its value computed
   // based on the values of:
   // - window focused
   // - focusOwner
   // - focusOwner focused
   viewerFocusedProperty.bind(viewerFocusedPropertyBinding);
 }
示例#3
0
  /** Initalizes the fields of the snake. */
  public void init() {
    setHead(grid.getXY(x, y));

    collision.set(false);

    points.set(0);

    currentDirection = Direction.UP;
    nextDirection = Direction.UP;
  }
示例#4
0
 public final boolean isArmed() {
   return armed.get();
 }
示例#5
0
 public final ReadOnlyBooleanProperty armedProperty() {
   return armed.getReadOnlyProperty();
 }
 public ReadOnlyBooleanProperty indeterminateProperty() {
   return indeterminate.getReadOnlyProperty();
 }
 public boolean isIndeterminate() {
   return indeterminate.get();
 }
 /**
  * Set the value for the progress, it cannot be more then 100 (meaning 100%). A negative value
  * means indeterminate progress.
  *
  * @param progressValue
  * @see ProgressCircleIndicator#makeIndeterminate()
  */
 public void setProgress(int progressValue) {
   progress.set(defaultToHundred(progressValue));
   indeterminate.set(progressValue < 0);
 }
示例#9
0
 public ReadOnlyBooleanProperty collisionProperty() {
   return collision.getReadOnlyProperty();
 }
示例#10
0
 @Override
 public ReadOnlyBooleanProperty viewerFocusedProperty() {
   return viewerFocusedProperty.getReadOnlyProperty();
 }
示例#11
0
 @Override
 public boolean isViewerFocused() {
   return viewerFocusedProperty.get();
 }
示例#12
0
 public ReadOnlyBooleanProperty hasErrorsProperty() {
   return hasErrors.getReadOnlyProperty();
 }
示例#13
0
 public boolean getHasErrors() {
   return hasErrors.get();
 }
示例#14
0
 @Override
 public ReadOnlyBooleanProperty disabledProperty() {
   return disabled.getReadOnlyProperty();
 }
示例#15
0
 public AbstractDisableable() {
   disabled.bind(disablers.emptyProperty().not());
 }