Class Terrain2D
Represents a 2D terrain element.
Inherited Members
Namespace: Genesis.Core.GameElements
Assembly: Genesis.dll
Syntax
public class Terrain2D : GameElement
Constructors
Terrain2D(string, Vec3, float, float, float, Texture)
Initializes a new instance of the Terrain2D class with specified name, location, cell counts, cell size, and texture.
Declaration
public Terrain2D(string name, Vec3 location, float cellsX, float cellsY, float cellSize, Texture texture)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the terrain. |
| Vec3 | location | The initial location of the terrain. |
| float | cellsX | The number of cells in the X direction. |
| float | cellsY | The number of cells in the Y direction. |
| float | cellSize | The size of each cell. |
| Texture | texture | The texture for the terrain. |
Properties
CellSize
Gets or sets the size of each cell.
Declaration
public float CellSize { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
CellsX
Gets or sets the number of cells in the X direction.
Declaration
public float CellsX { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
CellsY
Gets or sets the number of cells in the Y direction.
Declaration
public float CellsY { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Texture
Gets or sets the texture of the terrain.
Declaration
public Texture Texture { get; set; }
Property Value
| Type | Description |
|---|---|
| Texture |
Methods
GetBounds()
Gets the 2D bounds of the terrain.
Declaration
public Rect GetBounds()
Returns
| Type | Description |
|---|---|
| Rect | A rectangular region representing the 2D bounds of the terrain. |
Init(Game, IRenderDevice)
Initializes the terrain element.
Declaration
public override void Init(Game game, IRenderDevice renderDevice)
Parameters
| Type | Name | Description |
|---|---|---|
| Game | game | The game instance. |
| IRenderDevice | renderDevice | The render device used for rendering. |
Overrides
OnDestroy(Game)
Handles cleanup and resource disposal when the terrain is destroyed.
Declaration
public override void OnDestroy(Game game)
Parameters
| Type | Name | Description |
|---|---|---|
| Game | game | The game instance. |
Overrides
OnRender(Game, IRenderDevice)
Renders the terrain element.
Declaration
public override void OnRender(Game game, IRenderDevice renderDevice)
Parameters
| Type | Name | Description |
|---|---|---|
| Game | game | The game instance. |
| IRenderDevice | renderDevice | The render device used for rendering. |