nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
nanommo::Terrain Class Reference

#include <terrain.h>

Public Member Functions

 Terrain ()
 The board we had: flat, twelve metres across, for the tests.
 Terrain (uint32_t seed, float wading=kWading)
float Height (float x, float z) const
 On the triangles between the grid's corners, as the client draws them.
bool Walkable (float x, float z) const
const std::vector< Tree > & trees () const
float Corner (int i, int j) const
 The height at a corner of the grid, from 0 to cells() along each side.
uint32_t seed () const
int cells () const
 Along each side.
float half_size () const
 From the middle to each side of the grid.
float edge () const
 Half a metre short of each side, so that players stay on the grid.

Static Public Attributes

static constexpr float kCell = 2.0f
 In metres. Each cell of the grid is two triangles.
static constexpr float kSeaLevel = 0.0f
static constexpr float kWading = 0.4f
 Players wade into the sea up to their knees.
static constexpr float kTreeSpacing = 4.0f
 The trees grow on a grid of squares this size, at most one in each.
static constexpr float kTrunk = 0.5f
 How close to the middle of a trunk a player can stand.

Detailed Description

The ground everyone walks on. The server and the clients each make it from the same seed, so only the seed goes over the network.

Definition at line 45 of file terrain.h.

Constructor & Destructor Documentation

◆ Terrain() [1/2]

nanommo::Terrain::Terrain ( )

The board we had: flat, twelve metres across, for the tests.

Definition at line 51 of file terrain.cc.

◆ Terrain() [2/2]

nanommo::Terrain::Terrain ( uint32_t seed,
float wading = kWading )
explicit

An island, 512 metres across, with the sea all around it, which players can wade into as deep as wading, in metres.

Definition at line 54 of file terrain.cc.

Member Function Documentation

◆ cells()

int nanommo::Terrain::cells ( ) const
inline

Along each side.

Definition at line 85 of file terrain.h.

◆ Corner()

float nanommo::Terrain::Corner ( int i,
int j ) const
inline

The height at a corner of the grid, from 0 to cells() along each side.

Definition at line 78 of file terrain.h.

◆ edge()

float nanommo::Terrain::edge ( ) const
inline

Half a metre short of each side, so that players stay on the grid.

Definition at line 91 of file terrain.h.

◆ half_size()

float nanommo::Terrain::half_size ( ) const
inline

From the middle to each side of the grid.

Definition at line 88 of file terrain.h.

◆ Height()

float nanommo::Terrain::Height ( float x,
float z ) const

On the triangles between the grid's corners, as the client draws them.

Definition at line 102 of file terrain.cc.

◆ seed()

uint32_t nanommo::Terrain::seed ( ) const
inline

Definition at line 82 of file terrain.h.

◆ trees()

const std::vector< Tree > & nanommo::Terrain::trees ( ) const
inline

Definition at line 75 of file terrain.h.

◆ Walkable()

bool nanommo::Terrain::Walkable ( float x,
float z ) const

Whether a player can stand there: on the grid, out of the sea, and not in a tree.

Definition at line 123 of file terrain.cc.

Member Data Documentation

◆ kCell

float nanommo::Terrain::kCell = 2.0f
staticconstexpr

In metres. Each cell of the grid is two triangles.

Definition at line 48 of file terrain.h.

◆ kSeaLevel

float nanommo::Terrain::kSeaLevel = 0.0f
staticconstexpr

Definition at line 50 of file terrain.h.

◆ kTreeSpacing

float nanommo::Terrain::kTreeSpacing = 4.0f
staticconstexpr

The trees grow on a grid of squares this size, at most one in each.

Definition at line 56 of file terrain.h.

◆ kTrunk

float nanommo::Terrain::kTrunk = 0.5f
staticconstexpr

How close to the middle of a trunk a player can stand.

Definition at line 59 of file terrain.h.

◆ kWading

float nanommo::Terrain::kWading = 0.4f
staticconstexpr

Players wade into the sea up to their knees.

Definition at line 53 of file terrain.h.


The documentation for this class was generated from the following files: