Beispiel #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);
  }
Beispiel #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);
 }
Beispiel #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;
  }
 public final boolean isArmed() {
   return armed.get();
 }
 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);
 }
Beispiel #9
0
 public ReadOnlyBooleanProperty collisionProperty() {
   return collision.getReadOnlyProperty();
 }
Beispiel #10
0
 @Override
 public ReadOnlyBooleanProperty viewerFocusedProperty() {
   return viewerFocusedProperty.getReadOnlyProperty();
 }
Beispiel #11
0
 @Override
 public boolean isViewerFocused() {
   return viewerFocusedProperty.get();
 }
Beispiel #12
0
 public ReadOnlyBooleanProperty hasErrorsProperty() {
   return hasErrors.getReadOnlyProperty();
 }
Beispiel #13
0
 public boolean getHasErrors() {
   return hasErrors.get();
 }
 @Override
 public ReadOnlyBooleanProperty disabledProperty() {
   return disabled.getReadOnlyProperty();
 }
 public AbstractDisableable() {
   disabled.bind(disablers.emptyProperty().not());
 }