/** 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); }
/** 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); }
/** 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); }
public ReadOnlyBooleanProperty collisionProperty() { return collision.getReadOnlyProperty(); }
@Override public ReadOnlyBooleanProperty viewerFocusedProperty() { return viewerFocusedProperty.getReadOnlyProperty(); }
@Override public boolean isViewerFocused() { return viewerFocusedProperty.get(); }
public ReadOnlyBooleanProperty hasErrorsProperty() { return hasErrors.getReadOnlyProperty(); }
public boolean getHasErrors() { return hasErrors.get(); }
@Override public ReadOnlyBooleanProperty disabledProperty() { return disabled.getReadOnlyProperty(); }
public AbstractDisableable() { disabled.bind(disablers.emptyProperty().not()); }