Documentation
¶
Index ¶
- Constants
- func BootServer()
- func ParseSpritesetDefinition(defFileName string) (spritesheetSpec, error)
- type Action
- type Game
- type GameTime
- func (t *GameTime) Current() int64
- func (t *GameTime) DateString() string
- func (t *GameTime) Day() int64
- func (t *GameTime) DayOfYear() string
- func (t *GameTime) Hour() int64
- func (t *GameTime) IsDaytime() bool
- func (t *GameTime) IsNighttime() bool
- func (t *GameTime) Minute() int64
- func (t *GameTime) Month() int64
- func (t *GameTime) PartOfDay() string
- func (t *GameTime) PassedSinceStart() string
- func (t *GameTime) Season() string
- func (t *GameTime) Set(i int64)
- func (t *GameTime) Tick()
- func (t *GameTime) TimeOfDay() string
- func (t *GameTime) Year() int64
- type Island
- type LocalSpawn
- type Obj
- type Player
- type Point
- type TexturePack
- type TiledMapJSON
- type TiledMapLayer
- type TiledTileSet
Constants ¶
const ( Minute = 1 Hour = Minute * 60 Day = Hour * 24 Month = Day * 30 Season = Month * 3 Year = Month * 12 )
time constants
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Game ¶
type Game struct {
Island *Island
// contains filtered or unexported fields
}
Game ...
func (*Game) ContinuePlayer ¶
ContinuePlayer resumes a game, given a valid token
type GameTime ¶
type GameTime struct {
Time int64
}
GameTime is the object representing game server time
Server ticks every 3 real-world seconds. A day has 24 hours. There are 4 seasons. Each season has 3 months (90 days).
Each tick progresses the in-game time by 1 minutes, giving 60 ticks for an hour
So 1 game year = 518400 * 3 = 1555200 real seconds, or 25920 real time minutes (432 real hours, 7.2 real days).
func (*GameTime) DateString ¶
DateString returns "evening 19:20\nspring feb 20"
func (*GameTime) PassedSinceStart ¶
PassedSinceStart describes distance of t.time to 0
type Island ¶
type Island struct {
Width int
Height int
Seed int64 `bson:"_id"`
Age GameTime
HeightMap [][]int
Spawns []*Obj
Players []*Player
// contains filtered or unexported fields
}
Island ...
func (*Island) ColoredHeightMapAsImage ¶
ColoredHeightMapAsImage ...
func (*Island) DescribeLocalArea ¶
func (i *Island) DescribeLocalArea(pos Point) []LocalSpawn
DescribeLocalArea returns all spawns near pos
func (*Island) HeightsAsFlatTilemap ¶
HeightsAsFlatTilemap ...
func (*Island) LoadSpecs ¶
func (i *Island) LoadSpecs()
LoadSpecs loads all possible world items, NPC:s and actions
func (*Island) RandomPointAboveWater ¶
RandomPointAboveWater ...
type LocalSpawn ¶
LocalSpawn exposes public info about the spawn to the player
type Obj ¶
type Obj struct {
ID int64
Level int
Age GameTime
Name string
Race string
Type string
Class string
Sprite string
Position Point
Energy int
Weight int
XP int
Island *Island
Home *Obj
CurrentAction *actionSpec
PlannedActions []actionSpec
Inventory []*Obj
// the lower value, the less hungry npc is
Hunger int
Thirst int
Tiredness int
Coldness int
// for objects
Activated bool
}
Obj is a in-game object, such as a npc or a item
type Player ¶
type Player struct {
Name string
Token string
Spawn *Obj // points to a npc in game
Socket *websocket.Conn
}
Player ...
type Point ¶
Point ...
type TexturePack ¶
type TexturePack struct {
Frames []textureFrame `json:"frames"`
Meta textureMeta `json:"meta"`
}
TexturePack ...
func GenerateTexturePacker ¶
func GenerateTexturePacker(spec spritesheetSpec) TexturePack
type TiledMapJSON ¶
type TiledMapJSON struct {
Version int `json:"version"`
Width int `json:"width"`
Height int `json:"height"`
TileWidth int `json:"tilewidth"`
TileHeight int `json:"tileheight"`
Orientation string `json:"orientation"`
Layers []TiledMapLayer `json:"layers"`
TileSets []TiledTileSet `json:"tilesets"`
}
TiledMapJSON represents the tiled json format, recognized by phaser.io
type TiledMapLayer ¶
type TiledMapLayer struct {
Name string `json:"name"`
Type string `json:"type"`
Data []int `json:"data"`
Width int `json:"width"`
Height int `json:"height"`
Opacity int `json:"opacity"`
Visible bool `json:"visible"`
X int `json:"x"`
Y int `json:"y"`
}
TiledMapLayer represents a map layer
type TiledTileSet ¶
type TiledTileSet struct {
FirstGid int `json:"firstgid"`
Image string `json:"image"`
Name string `json:"name"`
ImageHeight int `json:"imageheight"`
ImageWidth int `json:"imagewidth"`
Margin int `json:"margin"`
Spacing int `json:"spacing"`
TileHeight int `json:"tileheight"`
TileWidth int `json:"tilewidth"`
}
TiledTileSet represents a tile set in use on the map