Class ProceduralArt
- All Implemented Interfaces:
PlatformArt
Art drawn from code: flat tiles with a lit top edge, rounded characters with eyes and stepping feet, coins, keys, doors and springs. Every image is made once and cached.
It makes a level playable and readable before any art exists, and it is the
fallback a game keeps for whatever it has not drawn yet: extend it and
override #tile, #sheet or #entity for the kinds you have art for. The
palette is set with #setPalette.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intFrames in a generated actor sheet: 0-1 idle, 2-5 walk, 6 jump, 7 fall, 8 crouch, 9 climb, 10 hurt, 11 dash. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThe animator for an actor.protected intThe body color for an actor: the hero is the accent, others are derived from the kind name.entity(LevelEntity e, int tick) The image for an entity this tick.protected intThe tile size.goal(int width, int height, int tick) The image for the level's goal this tick, drawn centered on the goal rectangle (PlatformWorld#getGoal()).The image for a moving platform.voidsetPalette(int ground, int groundTop, int accent) Sets the colors.The sprite sheet for an actor; frames are chosen by#animator(Actor).The image for one cell.
-
Field Details
-
FRAMES
public static final int FRAMESFrames in a generated actor sheet: 0-1 idle, 2-5 walk, 6 jump, 7 fall, 8 crouch, 9 climb, 10 hurt, 11 dash.- See Also:
-
-
Constructor Details
-
ProceduralArt
public ProceduralArt(int tileSize) Creates the art for a tile size.
Parameters
tileSize: pixels per tile
-
-
Method Details
-
setPalette
public void setPalette(int ground, int groundTop, int accent) Sets the colors.
Parameters
ground: solid tilesgroundTop: the lit top edge of solid tilesaccent: coins and highlights
-
getTileSize
protected int getTileSize()The tile size.
Returns
pixels
-
tile
Description copied from interface:PlatformArtThe image for one cell. Called when the view first draws a cell and again whenever the cell changes (a door opening, a block crumbling).
Parameters
grid: the grid, to look at neighbors for auto-tilingcol: the columnrow: the row
Returns
an image the size of a tile in pixels, or null to draw nothing
- Specified by:
tilein interfacePlatformArt
-
sheet
Description copied from interface:PlatformArtThe sprite sheet for an actor; frames are chosen by
#animator(Actor). The frame is drawn centered on the body horizontally and standing on its bottom edge, so a sheet may be larger than the body.Parameters
actor: the actor;Actor#getKind()names its art
Returns
the sheet
- Specified by:
sheetin interfacePlatformArt
-
colorFor
The body color for an actor: the hero is the accent, others are derived from the kind name.
Parameters
actor: the actor
Returns
RGB
-
animator
Description copied from interface:PlatformArtThe animator for an actor.
Parameters
actor: the actor
Returns
the animator, typically shared by every actor of a kind
- Specified by:
animatorin interfacePlatformArt
-
entity
Description copied from interface:PlatformArtThe image for an entity this tick. Called every tick, so return cached images.
Parameters
entity: the entity;LevelEntity#getType()andLevelEntity#getPhase()select the imagetick: the world tick, for animating
Returns
the image, drawn centered on the entity, or null to draw nothing
- Specified by:
entityin interfacePlatformArt
-
platform
Description copied from interface:PlatformArtThe image for a moving platform.
Parameters
platform: the platform
Returns
an image the platform's size in pixels
- Specified by:
platformin interfacePlatformArt
-
goal
Description copied from interface:PlatformArtThe image for the level's goal this tick, drawn centered on the goal rectangle (
PlatformWorld#getGoal()).Parameters
width: the goal's width in pixelsheight: the goal's height in pixelstick: the world tick, for animating
Returns
the image, or null to draw nothing
- Specified by:
goalin interfacePlatformArt
-