-
Notifications
You must be signed in to change notification settings - Fork 2
Random Map Generation System
Jantoom edited this page Oct 6, 2021
·
2 revisions
On creation of a new world, random map assets are loaded to compose a home. These map assets can describe floor plans or room interiors by mapping symbols to individual objects and placing these symbols onto a grid.
The random generation has support for rectangular room interiors, but protrusions can be added in the floor plan.
-
FileLoader
: API for reading JSON files and reading basic Java classes. Has been extended to read two-dimension grids and object maps. -
GameArea
: Legacy code for spawning and registered entities into the world. -
MainGameScreen
: Responsible for instantiating aHome
. Minor dependency injection is expected before callingcreate()
on the instance.
-
Home
: Defines the main directory for map files. May hold one or more floors to constitute a home. Has functionality to randomize floor plans. -
Floor
: ExtendsGameArea
. Responsible for object instantiation and placement into the world. Constitutes rooms and non-room-related objects relevant to the floor plan. -
Room
: Holds spatial data relevant to the floor it is on. Each room has a type (e.g. Bathroom, Bedroom). Has functionality to randomize room interiors. -
Interior
: Constitutes room-related objects relevant to the room interior. These classes are read by the JSON parser, then its values are injected into the room it belongs to. It is subsequently released in memory. -
GridObject
: Describes a method and parameters related to the creation of an object (either aTerrainTile
or anEntity
). These methods are independent of grid placement, so methods employing randomization may be used.
-
GridPoint2Utils
: Has been extended to support custom JSON deserialization. GridPoint2 objects can now be defined in map files as an int array. -
MatrixUtils
: Allows for non-square matrices to be manipulated. Supports transposing and vertical/horizontal reversing, which in turn allows anti/clockwise rotations. -
RandomUtils
: Allows for pseudo-random generation using seeds. The purpose is to guarantee consistent saving and loading of random maps. This functionality is yet to be expanded upon.
The random generation system is mostly in place so that prefabs are plug and play. If the intention is created prefabs, simply follow the format found in existing files, or refer to the custom serialization below.
{
class: // Class that declares the method used for creation
method: // Method inside the class. This method should not be overloaded
assets: [
// String array. Typical creation methods will use the first asset to
// create a Texture or Animation RenderComponent, but complex methods
// can define their own argument parsing. Make sure to apply this here
// Brackets can be in-lined
]
}
{
tileMap: {
?: {
// Custom GridObject serialization
}
...
}
entityMap: {
?: {
// Custom GridObject serialization
}
...
}
tileGrid: [
// Default JSON Character grid serialization
]
entityGrid: [
// Default JSON Character grid serialization
]
}
{
type: // One valid room type as a String. Defined in Room.Java
offset: [y, x] // Offset describes the bottom left corner of the room,
// relative to 0,0 in the top left corner of the floor
// If you skin your JSON file as a libGDX JSON, then you
// can find these numbers in the bottom right of the tab.
// Internally converted to x, y when matrix is later
// manipulated so that generation is in the same orientation
// as the file
dimensions: [x, y] // Dimensions of the room. Used for matching interiors
// Note that these are x, y instead of y, x
interior: {
// Optional parameter. If declared, then use custom Interior serialization
}
}
{
defaultInteriorTile: {
// Custom GridObject serialization
}
defaultInteriorWall: {
// Custom GridObject serialization
}
tileMap: {
?: {
// Custom GridObject serialization
}
...
}
entityMap: {
?: {
// Custom GridObject serialization
}
...
}
roomMap: {
?: {
// Custom Room serialization
}
...
}
floorGrid: {
// Default JSON Character grid serialization. Note that special tile/entity
// symbols overriding room symbols will not override tile ownership,
// only entity ownership. This is to ensure that the correct tile texture
// is placed in the room, and the floor plan can decide to place a door
// instead of a room wall
}
}
Entities and Components
Interaction System
Unit Testing
Input Handling
UI
Game Screens and Areas
Map Generation
Basic Interactable Objects Design