Package breitband.GUI
The GUI is written using Simple APP Graphics. Its state is managed
by its own board, as well as a GameState
enum that gets updated whenever the
next step in a player's move occurs.
Assets
The game's assets use a lot of linear gradients, and other SVG features that SAG sadly does not have the best
support for. Also, many of them are rather large and not human-readable due to the many details in them. As a
solution, and to keep more of the code clean, GAsset
, takes care of asset
importing. The built JAR file includes all game assets.
For more information, see the Asset
and
GAsset
docs.
Event Handling
Event handling is done in a functional style using Java's functional interfaces. This means that UI elements such
as Buttons
expose functions that take in lambdas which will be called when
an event occurs, like onClick
. More
complex UI components such as the CableStore
are more specialized - they have
specific events like onPurchase
.
This functional solution leads to a lot of encapsulation, as the logic behind interactions inside a
component does not concern outer components and is thus hidden away from them. In the case of the aforementioned
CableStore, when the user clicks a button within the component to increase the number of cables of a certain
cable type, the rest of the GUI does not have to react to that change. The rest of the GUI is only concerned
about whether a purchase is made. So, as to prevent the GameWindow
from managing
more state than it has to, the UI components keep most of the details encapsulated and expose high-level event
handler functions.
Polygon Simplification
As the polygons supplied through the config can get quite complex, the
PolygonOptimizer
has been designed to cut down on details where they
don't matter. It also prevents jagged or "fuzzy" looking lines from appearing in the game. The optimizer runs
through multiple passes on each polygon and uses frequency analysis to simplify polygons.
The simplified polygons get used to store various levels of detail
(LOD)
which get switched out dynamically based on the zoom level. This way, low quality polygons get shown when zoomed
out, which improves performance.
For more information, see the PolygonOptimizer
docs.
- See Also:
GameWindow
-
Class Summary Class Description GameWindow The GUI for the game -
Enum Summary Enum Description GameState States for managing in which phase of a turn the player is