Package com.codename1.gaming.level
The saved-level / map model behind the Codename One game builder.
This package is the bridge between a visual level editor and the runtime
com.codename1.gaming engine: a GameLevel is a mode-aware, JSON-serializable
description of a scene that the editor writes and a game loads, decoupled from how
it is drawn.
A level has a mode -- GameLevel.Mode#TWO_D (tile + sprite), GameLevel.Mode#THREE_D
(meshes, TerrainGrid and LevelLights in a perspective world) or
GameLevel.Mode#BOARD (an IsoProjection grid) -- ordered Layers (a tile layer
paints an assetId-per-cell grid; entity / model layers group freely placed
things), a list of GameElements (pure data: an asset id, a transform and a typed
property bag, not a com.codename1.gaming.Sprite) and an AssetCatalog of
AssetPacks / AssetDefs resolving asset ids to artwork.
Realization -- turning the data into live objects -- depends on the mode: a
GameLevel realizes its own 2D / board sprites, while GameSceneView is a turnkey
com.codename1.gaming.GameView that plays a level end to end, including the 3D
camera, lights and models (which need the GPU device).
-
ClassDescriptionThe registry that turns an
GameElement#getAssetId()into something aLevelRealizercan draw.The definition of one placeable asset in anAssetPack: the template a placedGameElementreferences through itsGameElement#getAssetId().How an asset is placed: painted into a grid cell, or freely positioned.The art format of an asset, which decides what it is realized into.A themed collection ofAssetDefs -- the editor's "Platformer", "Top-Down RPG" or "Board & Card" pack.Supplies and persistsTerrainChunks for aStreamingTerrain.A single placed thing in aGameLevel-- pure authoring data, deliberately not acom.codename1.gaming.Sprite.A saved, mode-aware game level or map: the data the visual editor writes and the runtime loads, deliberately decoupled from how it is drawn.The kind of a level, which decides how its elements are realized and rendered.A turnkeyGameViewthat plays aGameLevel: it wires the whole lifecycle so a generated game scene can be a thin subclass that only adds behavior.A large game space made of linkedRegions, streamed in and out around the player so the world can exceed memory while transitions stay seamless.Maps between board cells (row, column) and screen pixels for the 2:1 isometric "diamond" layout used by board / strategy games.A named drawing band in aGameLevel: the editor's "Background / Terrain / Items / Actors" rows, and the rendering order behind them.What a layer holds, which decides how its content is realized.A serializable directional light authored in a 3DGameLevel: a direction, a diffuse#getColor()and an#getAmbientColor().A pluggable surface material used by terrain cells andTerrainFeatures.Process-wide registry of pluggableMaterials, keyed by id.A loadable area of a large world: its own streamingTerrain, placedGameElements and a world-space origin (#getOriginX(),#getOriginZ()in tile units). Regions are linked to neighbours by named edges (#link(String,String), e.g. "east" -> "desert-2"), so aGameWorldcan stream the adjacent regions in and out for seamless transitions as the player crosses a boundary.Loads and persistsRegions by id for aGameWorld, so a world larger than memory can page whole areas in and out as the player roams.An unboundedTerrainthat pagesTerrainChunks in and out through aChunkProvider, keeping at most#getCacheSize()chunks resident (LRU).A trivial in-memory provider: remembers chunks it has seen, generates empty flat-grass chunks otherwise.Abstraction over a heightfield + per-cell material + placedTerrainFeatures addressed by world cell coordinates.A#SIZEx#SIZEsquare block of terrain -- the unit of streaming.A placed, variable-size terrain element such as a wall, ramp or platform.A height grid for a 3DGameLevel: a#getCols()x#getRows()array of vertex heights spaced#getCellSize()world units apart.An efficient, single-tileset tile grid: a#getCols()x#getRows()array of frame indices into oneSpriteSheet(-1 means "empty cell").