Package tetris.model
Class Game.FigureController
java.lang.Object
java.lang.Thread
tetris.model.Game.FigureController
- All Implemented Interfaces:
Runnable
,ActionHandler
- Enclosing class:
Game
The class FigureController is used to control the figure of the Tetris game.
- Version:
- 2.1
- Author:
- Stephan Fischli
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
drop()
Drops the figure.private void
Performs a movement with the figure and undoes it, if the resulting figure collides with the field.void
Rotates the figure to the left.void
Rotates the figure to the right.void
run()
Shifts the figure down with a speed that depends on the game level.void
Shifts the figure down.void
Shifts the figure left.void
Shifts the figure right.Methods inherited from class java.lang.Thread
activeCount, clone, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, threadId, toString, yield
-
Constructor Details
-
FigureController
private FigureController()
-
-
Method Details
-
shiftDown
public void shiftDown()Shifts the figure down.- Specified by:
shiftDown
in interfaceActionHandler
-
shiftLeft
Shifts the figure left.- Specified by:
shiftLeft
in interfaceActionHandler
- Throws:
CollisionException
-
shiftRight
Shifts the figure right.- Specified by:
shiftRight
in interfaceActionHandler
- Throws:
CollisionException
-
rotateLeft
Rotates the figure to the left.- Specified by:
rotateLeft
in interfaceActionHandler
- Throws:
CollisionException
-
rotateRight
Rotates the figure to the right.- Specified by:
rotateRight
in interfaceActionHandler
- Throws:
CollisionException
-
drop
public void drop()Drops the figure.- Specified by:
drop
in interfaceActionHandler
-
execute
Performs a movement with the figure and undoes it, if the resulting figure collides with the field.- Parameters:
movement
- the movement to makereverseMovement
- the reverse movement- Throws:
CollisionException
- if the resulting figure collides with the field
-
run
public void run()Shifts the figure down with a speed that depends on the game level.
-