public class StarterKit
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
FilterBatch |
batch
Used to draw lots of things, but mostly handled internally by the Stage.
|
int |
cellHeight
The height of a cell that holds one char, in "relative pixels," where the screen is expected to stretch
so one relative pixel does not generally refer to one actual screen pixel (since high-DPI phones and
laptops may make a single pixel virtually impossible to see with the naked eye).
|
int |
cellWidth
The width of a cell that holds one char, in "relative pixels," where the screen is expected to stretch so
one relative pixel does not generally refer to one actual screen pixel (since high-DPI phones and
laptops may make a single pixel virtually impossible to see with the naked eye).
|
int |
gridHeight
The number of grid spaces on the y axis.
|
int |
gridWidth
The number of grid spaces on the x axis.
|
SparseLayers |
layers
The main way to interact with a text-based grid as for roguelikes.
|
squidpony.squidmath.GWTRNG |
rng
Almost all of SquidLib comes into contact with randomness at some point, so this is a good place to show one
way of handling that randomness.
|
com.badlogic.gdx.scenes.scene2d.Stage |
stage
All visible parts of this class are in the Stage, and if you add additional widget or scene2d.ui Actor
values to your game, they should probably be added to this Stage.
|
TextCellFactory |
textFactory
One of the more critical parts of rendering text is what font to use, and textFactory should usually
not be reassigned during a game because so many things depend on this value or a copy of it (so the
change might not affect what it was expected to, and might break other things).
|
com.badlogic.gdx.utils.viewport.Viewport |
viewport
An important part of how this will be displayed; the viewport defaults to a displayed width of
cellWidth * gridWidth and a displayed height of cellHeight * gridHeight , after cellWidth
and cellHeight were doubled by default, and will be stretched or shrunk to fit the actual screen size. |
Constructor and Description |
---|
StarterKit(int gridWidth,
int gridHeight,
int cellWidth,
int cellHeight)
Constructs a StarterKit with the given width and height in cells (gridWidth and gridHeight) and the given width
and height for each letter (cellWidth and cellHeight), using a default font that is about half as wide as it is
tall but can stretch to other aspect ratios.
|
StarterKit(TextCellFactory textFactory,
int gridWidth,
int gridHeight,
int cellWidth,
int cellHeight)
Constructs a StarterKit with the given width and height in cells (gridWidth and gridHeight) and the given width
and height for each letter (cellWidth and cellHeight), using the given TextCellFactory for the font.
|
StarterKit(TextCellFactory textFactory,
int gridWidth,
int gridHeight,
int cellWidth,
int cellHeight,
int additionalWidth,
int additionalHeight)
Constructs a StarterKit with the given width and height in cells (gridWidth and gridHeight) and the given width
and height for each letter (cellWidth and cellHeight), using the given TextCellFactory for the font; this
overload also allows specifying additional space in pixels to be added to the right or bottom sides of the area
with the grid of chars.
|
Modifier and Type | Method and Description |
---|---|
void |
draw()
Not a complete drawing solution; so much of the logic related to drawing is specific to each game, like
FOV being used to make certain things not render if they are out of sight, that this doesn't even try to
guess at what a particular game needs for its rendering code.
|
void |
resize(int width,
int height)
Not a complete resize method; this is meant to handle the resizing of this StarterKit only and should be
called inside your main Game, ApplicationListener, etc.
|
public TextCellFactory textFactory
public SparseLayers layers
public int gridWidth
public int gridHeight
public int cellWidth
public int cellHeight
public com.badlogic.gdx.scenes.scene2d.Stage stage
public FilterBatch batch
batch.begin()
and batch.end()
in some cases where you want to
render something that isn't a child of stage but is an Actor or similar render-able object.
This can apply a filter from FloatFilters
(or a custom FloatFilter
) to all drawn colors.public com.badlogic.gdx.utils.viewport.Viewport viewport
cellWidth * gridWidth
and a displayed height of cellHeight * gridHeight
, after cellWidth
and cellHeight were doubled by default, and will be stretched or shrunk to fit the actual screen size.public squidpony.squidmath.GWTRNG rng
IRNG
,
can be "seeded" at the start to set the initial state, like any other RNG, but it can also have the current state
acquired later with GWTRNG.getState()
or have the current state set in-place with
GWTRNG.setState(long)
(note, this doesn't create a new RNG, like you would have to do to re-seed with
java.util.Random). This can be useful to get a snapshot of the random sequence where you might want to take an
action, undo it back to the snapshot, and try again. It can also be useful for saving the game and reloading it
exactly, though the optional serialization in squidlib-extra also does this. You can pass a GWTRNG to anything
that expects an IRNG, and you'll encounter a lot of methods that employ IRNG (and some that specifically require
or prefer IStatefulRNG
, which includes GWTRNG) throughout squidlib-util.
public StarterKit(int gridWidth, int gridHeight, int cellWidth, int cellHeight)
gridWidth
- the width of the display area in cellsgridHeight
- the height of the display area in cellscellWidth
- the width of a single cell in pixels, before any stretching is appliedcellHeight
- the height of a single cell in pixels, before any stretching is appliedpublic StarterKit(TextCellFactory textFactory, int gridWidth, int gridHeight, int cellWidth, int cellHeight)
DefaultResources
, such as
DefaultResources.getCrispLeanFamily()
, DefaultResources.getCrispDejaVuFont()
,
DefaultResources.getCrispSlabFamily()
, or DefaultResources.getStretchableTypewriterFont()
, as
long as you have the right assets available (their documentation says the exact files you need). While you can
construct your own TextCellFactory given a BitmapFont, that won't work well as a distance field font unless you
used some very unusual configuration making the font, so the font would only look good at one size or possibly a
multiple of that size. The defaults are recommended for now; a separate project is used to make the distance
field monospace fonts (tommyettinger/Glamer on GitHub)
That project also serves as storage for fonts that were made with Glamer, and appropriately-licensed fonts are
added to the "premade" folder once they are converted.
DefaultResources.getCrispLeanFamily()
and
DefaultResources.getCrispSlabFamily()
have the same (very large) character coverage, and have bold and
italic modes that can be accessed with GDXMarkup
if you decide to use that later.textFactory
- the TextCellFactory to use for the fontgridWidth
- the width of the display area in cellsgridHeight
- the height of the display area in cellscellWidth
- the width of a single cell in pixels, before any stretching is appliedcellHeight
- the height of a single cell in pixels, before any stretching is appliedpublic StarterKit(TextCellFactory textFactory, int gridWidth, int gridHeight, int cellWidth, int cellHeight, int additionalWidth, int additionalHeight)
DefaultResources
, such as DefaultResources.getCrispLeanFamily()
DefaultResources.getCrispDejaVuFont()
, DefaultResources.getCrispSlabFamily()
, or
DefaultResources.getStretchableTypewriterFont()
, as long as you have the right assets available (their
documentation says the exact files you need). While you can construct your own TextCellFactory given a
BitmapFont, that won't work well as a distance field font unless you used some very unusual configuration making
the font, so the font would only look good at one size or possibly a multiple of that size. The defaults are
recommended for now; a separate project is used to make the distance field monospace fonts
(tommyettinger/Glamer on GitHub). That project also serves
as storage for fonts that were made with Glamer, and appropriately-licensed fonts are added to the "premade"
folder once they are converted.
DefaultResources.getCrispLeanFamily()
and
DefaultResources.getCrispSlabFamily()
have the same (very large) character coverage, and have bold and
italic modes that can be accessed with GDXMarkup
if you decide to use that later.textFactory
- the TextCellFactory to use for the fontgridWidth
- the width of the display area in cellsgridHeight
- the height of the display area in cellscellWidth
- the width of a single cell in pixels, before any stretching is appliedcellHeight
- the height of a single cell in pixels, before any stretching is appliedadditionalWidth
- the width in pixels to add to the stretched area, before any stretching is appliedadditionalHeight
- the height in pixels to add to the stretched area, before any stretching is appliedpublic void draw()
TextCellFactory.Glyph
objects in
layers
will be rendered by that SparseLayers, but any that aren't stored in layers must be drawn
separately (Glyph has a TextCellFactory.Glyph.draw(Batch, float)
method that must be called between
Batch.begin()
and Batch.end()
, typically with begin() called before all Glyphs are drawn in
a loop and then with end() called after).
FilterBatch.begin()
block,
since this calls it itself by drawing the stage, and also calls FilterBatch.end()
afterwards.public void resize(int width, int height)
width
- the new width of the screen; should be a parameter from the other resize() methodheight
- the new height of the screen; should be a parameter from the other resize() methodCopyright © Eben Howard 2012–2022. All rights reserved.