Documentation
¶
Index ¶
- type AIPlayer
- type AStarPathing
- type Acre
- type Archer
- type Armory
- type AutoNumber
- type BasePlayer
- type BaseUnit
- type Castle
- type Catapult
- type Cavalry
- type Farm
- type Fence
- type Game
- func (game *Game) AcceptNetConnections(host string, port int) error
- func (game *Game) AddUnit(player IPlayer, unit IUnit)
- func (game *Game) AddUnitCloseToPoint(player IPlayer, unit IUnit, central *image.Point, radius int) error
- func (game *Game) CommandChannelHandler()
- func (game *Game) FindPath(source *image.Point, destination *image.Point) (*list.List, error)
- func (game *Game) FreeList(l *list.List)
- func (game *Game) GenerateUnits(player IPlayer, spawnRect *image.Rectangle)
- func (game *Game) LoadTMX(filename string) (*tmx.Map, error)
- func (game *Game) ReadyToGo() bool
- func (game *Game) RenderTMX()
- func (game *Game) SituateHomeBases(noOfPlayers int) ([]*image.Rectangle, error)
- func (game *Game) Start()
- func (game *Game) Stop()
- type GameMaster
- type Goldmine
- type Grid
- func (grid *Grid) Add(unit IUnit, location *image.Point) error
- func (grid *Grid) Center() image.Point
- func (grid *Grid) Collision(locus *image.Point) bool
- func (grid *Grid) DirectLineBresenham(source *image.Point, destination *image.Point) []image.Point
- func (grid *Grid) Distance(source *image.Point, destination *image.Point) float64
- func (grid *Grid) DistanceDiagonelShortcut(source *image.Point, destination *image.Point) float64
- func (grid *Grid) DistanceInteger(source *image.Point, destination *image.Point) int
- func (grid *Grid) DistanceManhattan(source *image.Point, destination *image.Point) float64
- func (grid *Grid) GenerateGrid(worldLocation image.Point, width int, height int)
- func (grid *Grid) In(worldPoint *image.Point) bool
- func (grid *Grid) Overlaps(other *Grid) bool
- func (grid *Grid) Print()
- func (grid *Grid) RandomPointInGrid() *image.Point
- func (grid *Grid) Remove(unit IUnit)
- func (grid *Grid) RemoveAt(unit IUnit, location *image.Point)
- func (grid *Grid) Set(locus *image.Point, unit IUnit) error
- func (grid *Grid) SqrtHDU32(x uint32) uint32
- func (grid *Grid) ToGridPoint(worldPoint *image.Point) image.Point
- func (grid *Grid) ToWorldPoint(gridPoint *image.Point) image.Point
- type HealthAndAttack
- type HomeStead
- type HumanPlayer
- type IMechanic
- type IPlayer
- type IPoolable
- type IUnit
- type Infantry
- type Movement
- type MovementMechanic
- type Peasant
- type Pool
- func (pool *Pool) Archers(n int) []*Archer
- func (pool *Pool) Castles(n int) []*Castle
- func (pool *Pool) Catapults(n int) []*Catapult
- func (pool *Pool) Cavalry(n int) []*Cavalry
- func (pool *Pool) Farms(n int) []*Farm
- func (pool *Pool) Fences(n int) []*Fence
- func (pool *Pool) Free(object IPoolable)
- func (pool *Pool) Generate(items int)
- func (pool *Pool) Goldmines(n int) []*Goldmine
- func (pool *Pool) Infantry(n int) []*Infantry
- func (pool *Pool) Peasants(n int) []*Peasant
- func (pool *Pool) PrintAllocatedWaypoints()
- func (pool *Pool) Ships(n int) []*Ship
- func (pool *Pool) StoneQuarry(n int) []*StoneQuarry
- func (pool *Pool) Towers(n int) []*Tower
- func (pool *Pool) Walls(n int) []*Wall
- func (pool *Pool) Waypoints(n int) []*Waypoint
- func (pool *Pool) Woodpiles(n int) []*WoodPile
- type Poolable
- type Ship
- type StoneQuarry
- type TCPWire
- type Terrain
- type Tower
- type UDPWire
- type UnitMap
- type UnitType
- type View
- func (view *View) Center() image.Point
- func (view *View) CenterOfRect(rect *image.Rectangle) image.Point
- func (view *View) GenerateView(worldLocation image.Point, width int, height int)
- func (view *View) In(worldPoint *image.Point) bool
- func (view *View) Overlaps(other *View) bool
- func (view *View) RandomPointCloseToPoint(locus *image.Point, maxDistance int) *image.Point
- func (view *View) RandomPointInView() *image.Point
- func (view *View) ToViewPoint(worldPoint *image.Point) image.Point
- func (view *View) ToWorldPoint(viewPoint *image.Point) image.Point
- type Wall
- type Waypoint
- type WireCommand
- type WirePacket
- type WoodPile
- type World
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AIPlayer ¶
type AIPlayer struct { // Structures common to all players. BasePlayer }
AIPlayer will implement and Machine Intelligent Player
type AStarPathing ¶
type AStarPathing struct { }
AStarPathing will implement the A* pathing algorithm A simple description here: http://www.policyalmanac.org/games/aStarTutorial.htm Psuedocode here at the bottom of this: http://web.mit.edu/eranki/www/tutorials/search/ https://github.com/beefsack/go-astar/blob/master/astar.go Smoothing to avoid diagonals: http://www.gamasutra.com/view/feature/131505/toward_more_realistic_pathfinding.php?page=1 Basic line scan/ploting algorithm: https://en.wikipedia.org/wiki/Line_drawing_algorithm
func (*AStarPathing) FindPath ¶
func (path *AStarPathing) FindPath(pool *Pool, grid *Grid, source *image.Point, destination *image.Point) (*list.List, error)
FindPath will find a path between source and destination Points and returns a list of Waypoints of the proper path. All coordinates in world coordinates (absolute coordinates) please.
type Acre ¶
type Acre struct { AutoNumber // contains filtered or unexported fields }
Acre maintains the state for an acre of the World.
func (*Acre) Collision ¶
Collision returns true if the locus is already occupied by any other unit OR the terrain is inaccessible such as Mountains, Water and Trees.
func (*Acre) IsOccupiedOrNotGrass ¶
IsOccupiedOrNotGrass returns true if the terrains is occupied or at least not grass.
type Archer ¶
type Archer struct {
BaseUnit
}
Archer is an IUnit that maintains a range unit of some sort
type Armory ¶
type Armory struct {
BaseUnit
}
Armory is an IUnit that maintains an Armory that produces combat units
type AutoNumber ¶
type AutoNumber struct { ID int // contains filtered or unexported fields }
AutoNumber produces and maintains an autonumber
type BasePlayer ¶
type BasePlayer struct { // The world map that maintains the terrain and units. OurWorld *World // Our view (projection) onto that world View // Map of units for this player UnitMap // Our master pool for frequently used items ItemPool *Pool // The automated mechanics of this particular user Mechanics []IMechanic // Pathing systems Pathing *AStarPathing // Each player has a unique auto number. AutoNumber // contains filtered or unexported fields }
BasePlayer maintains all structures common to all kinds of players. Presently there are two players {HumanPlayer, AIPlayer}
func (*BasePlayer) DumpUnits ¶
func (player *BasePlayer) DumpUnits()
DumpUnits demonstrates how to do that precisely.
func (*BasePlayer) PlayerUnits ¶
func (player *BasePlayer) PlayerUnits() *UnitMap
PlayerUnits returns the player unit map for this player.
func (*BasePlayer) PlayerView ¶
func (player *BasePlayer) PlayerView() *View
PlayerView returns the view associated with this player
type BaseUnit ¶
type BaseUnit struct { Poolable AutoNumber HealthAndAttack Owner IPlayer Movement }
BaseUnit composes all the structures necessary for any unit.
func (*BaseUnit) Initialize ¶
func (unit *BaseUnit) Initialize()
Initialize will set the unit to the base state. Call only once per instantiation
type Castle ¶
type Castle struct {
BaseUnit
}
Castle is an IUnit that maintains a military fortification
type Farm ¶
type Farm struct {
BaseUnit
}
Farm is an IUnit that maintains a farm and adds food resources to an IPlayer
type Game ¶
type Game struct { // Description of game Description string // Our players for this game. // Once the game begins this array does not change. Players []IPlayer // The world map that maintains the terrain and units. OurWorld *World Mechanics []IMechanic // Our master pool for frequently used items ItemPool *Pool // Pathing systems Pathing *AStarPathing // Command channel CommandChannel chan *WirePacket // Our TMX map that describes the world. // We never load the images of course. TMXMap *tmx.Map // First and Last Global Tile Identifier for mountains MountainsFirstGID int MountainsLastGID int // First and Last Global Tile Identifier for grass GrassFirstGID int GrassLastGID int // First and Last Global Tile Identifier for trees TreesFirstGID int TreesLastGID int // First and Last Global Tile Identifier for water WaterFirstGID int WaterLastGID int // First and Last Global Tile Identifier for dirt DirtFirstGID int DirtLastGID int // First and Last Global Tile Identifier for sand SandFirstGID int SandLastGID int // First and Last Global Tile Identifier for snow SnowFirstGID int SnowLastGID int // Spawn locations. Suggested locations for Home bases. // They are called spawns or spawn-points in game lingo. SpawnLocations []tmx.Object }
Game is an actual game with UDP ports and IPlayers In theory the rtsengine can maintain N number of simultaneous running Games as long as UDP ports do not overlap.
func NewGame ¶
func NewGame( description string, filenameTMX string, poolItems int, noOfHumanPlayers int, noOfAIPlayers int, playerViewWidth int, playerViewHeight int, worldWidth int, worldHeight int) (*Game, error)
NewGame constructs a new game according to the parameters.
func (*Game) AcceptNetConnections ¶
AcceptNetConnections will accept connections from UI's (humans presumably) and assign them a player. Once all humanplayers are accepted this method returns WITHOUT starting the game. We are waiting at this point ready to go.
func (*Game) AddUnitCloseToPoint ¶
func (game *Game) AddUnitCloseToPoint(player IPlayer, unit IUnit, central *image.Point, radius int) error
AddUnitCloseToPoint will add unit to player no further than radius away from the central point. Will ensure no collisions. Central point is in VIEW coordinates.
func (*Game) CommandChannelHandler ¶
func (game *Game) CommandChannelHandler()
CommandChannelHandler will handle the command channel and dispatch the wire packets.
func (*Game) FindPath ¶
FindPath finds a path from source to destination within this game's world and return it as a list of Waypoints
func (*Game) GenerateUnits ¶
GenerateUnits will construct the starting units per player.
func (*Game) LoadTMX ¶
LoadTMX will load the TMX (XML) file from disk (filename) and returns a pointer ot the tmx MAP. http://doc.mapeditor.org/reference/tmx-map-format/
func (*Game) RenderTMX ¶
func (game *Game) RenderTMX()
RenderTMX will read the TMX file (presumably already loaded) and render the terrain items within to our world.
func (*Game) SituateHomeBases ¶
SituateHomeBases will construct home bases in the proper locations on the world. That is within the world but not overlapping one another. It's possible for large numbers of players on a too small grid this heuristic will not converge and an error will be returned.
type GameMaster ¶
GameMaster maintains an array of games. The rtsengine can run N number of simultaneous Games each with N number of players.
func (*GameMaster) Add ¶
func (gameMaster *GameMaster) Add(game *Game)
Add will add the game to the Games Master.
type Grid ¶
type Grid struct { // Actual data copy of a portion of the world grid Matrix [][]Acre // Width and Height of this Grid Span image.Rectangle // Where the upper left hand corner of this grid // is located in world coordinates. If it is 0,0 then // WorldOrigin == Grid WorldOrigin image.Point // Generator Random number generator for this view Generator *rand.Rand }
Grid maintains an acre grid and its span.
func (*Grid) Add ¶
Add will place the unit in the grid at location. Error is returned if the location is invalid. That is outside the known grid.
func (*Grid) Collision ¶
Collision returns true if the locus is already occupied by any other unit OR the terrain is inaccessible such as Mountains and Trees.
func (*Grid) DirectLineBresenham ¶
DirectLineBresenham returns a direct line between two points. This is an integer implemenation and works on all quadrants https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm Actual implementation https://rosettacode.org/wiki/Bitmap/Bresenham%27s_line_algorithm#Go
func (*Grid) DistanceDiagonelShortcut ¶
DistanceDiagonelShortcut is described here: http://www.policyalmanac.org/games/heuristics.htm
func (*Grid) DistanceInteger ¶
DistanceInteger is the distance algorithm using integer arithmetic. Don't use intermediate variables.
func (*Grid) DistanceManhattan ¶
DistanceManhattan is described here: http://www.policyalmanac.org/games/heuristics.htm
func (*Grid) GenerateGrid ¶
GenerateGrid will initialize all internal structures. It will set the grid widith and height and situate the grid onto the world at worldLocation
func (*Grid) RandomPointInGrid ¶
RandomPointInGrid returns a pointer to a point randomly selected within the grid.
func (*Grid) Remove ¶
Remove will eliminate a unit from the grid where-ever it is found. The algorithm presently is brute force.
func (*Grid) ToGridPoint ¶
ToGridPoint Converts world coordinates to grid coordinates
type HealthAndAttack ¶
type HealthAndAttack struct { // Init at Life == Hitpoints. Life reduces as hits are absorbed Life int // Default hit points for a particular unit. The more hit points // the more abuse a unit can maintain. HitPoints int // The number of points a single clash deducts from some other // units health AttackPoints int // The number of acres away a unit can attack. // 1 means only adjacent acres. 2 means anything two acres away // etc AttackRange int }
HealthAndAttack maintains the health statistics of a unit.
func (*HealthAndAttack) IncreaseHealth ¶
func (health *HealthAndAttack) IncreaseHealth(otherUnit *HealthAndAttack)
IncreaseHealth will increase health using the AttackPoints Presumably this would be used by a medic or repair unit. Maxes out at HitPoints obviously.
func (*HealthAndAttack) IsDead ¶
func (health *HealthAndAttack) IsDead() bool
IsDead returns TRUE if this unit has expired.
func (*HealthAndAttack) IsHealthy ¶
func (health *HealthAndAttack) IsHealthy() bool
IsHealthy returns TRUE if this unit has >=40% of its Hitpoints
func (*HealthAndAttack) IsPerfectlyHealthy ¶
func (health *HealthAndAttack) IsPerfectlyHealthy() bool
IsPerfectlyHealthy returns TRUE if this unit has no damage at all.
func (*HealthAndAttack) ReduceHealth ¶
func (health *HealthAndAttack) ReduceHealth(otherUnit *HealthAndAttack)
ReduceHealth reduces the health of this unit by the AttackPoints held within otherUnit. The argument otherUnit presumably is the Health of some other attacking unit.
type HomeStead ¶
type HomeStead struct {
BaseUnit
}
HomeStead is an IUnit that maintains a homestead that generates peasants
type HumanPlayer ¶
type HumanPlayer struct { // Structures common to all players. BasePlayer // Live TCPWire to communicate with UI Wire *TCPWire }
HumanPlayer implements the IPlayer interface for a human player
func NewHumanPlayer ¶
func NewHumanPlayer(description string, worldLocation image.Point, width int, height int, pool *Pool, pathing *AStarPathing, world *World) *HumanPlayer
NewHumanPlayer constructs a HumanPlayer
type IMechanic ¶
type IMechanic interface {
// contains filtered or unexported methods
}
IMechanic encapsulates are particular mechanic managed by the game.
type IPlayer ¶
type IPlayer interface { // Returns this player's view PlayerView() *View // Returns this player's view PlayerUnits() *UnitMap // contains filtered or unexported methods }
IPlayer encapsulates are particular mechanic managed by the game.
type IPoolable ¶
type IPoolable interface { IsAllocated() bool Allocate() Deallocate() }
IPoolable objects can be pooled obviously
type IUnit ¶
type IUnit interface { IPoolable // contains filtered or unexported methods }
IUnit is an interface to all unit within the World and can reside within an Acre.
type Infantry ¶
type Infantry struct {
BaseUnit
}
Infantry is an IUnit that maintains a foot soldier unit. Like a century or company
type Movement ¶
type Movement struct { // Last actual movement of this unit LastMovement time.Time // Movement delta in milliseconds. // Thus if this was 500 that would be 2 movements potentially per second. // 1000 would be one movement per second etcetera. DeltaInMillis int64 // Destination in world coordinates if a move is in progress. MovementDestination *image.Point // Current location in world coordinates CurrentLocation *image.Point }
Movement maintains state of the movement capabilities of a unit Stationary only units like a Home or Fence lack this structure.
func (*Movement) CanMove ¶
CanMove returns true if this unit may move now given the current time. If the elapsed time Sinc Lastmovement is greater than the DeltaInMillis return true.
func (*Movement) UpdateLastMovement ¶
func (move *Movement) UpdateLastMovement()
UpdateLastMovement will update the LastMovement of this unit to the current instant in time.
type MovementMechanic ¶
type MovementMechanic struct { // The world map that maintains the terrain and units. OurWorld *World // Command channel CommandChannel chan *WirePacket // All players in the game Players []IPlayer // Pathing systems Pathing *AStarPathing OurGame *Game // contains filtered or unexported fields }
MovementMechanic handles the global movement of units
func NewMovementMechanic ¶
func NewMovementMechanic(world *World, cc chan *WirePacket, players []IPlayer, pathing *AStarPathing, ourgame *Game) *MovementMechanic
NewMovementMechanic factory
type Peasant ¶
type Peasant struct {
BaseUnit
}
Peasant is an IUnit. Basic non-combatant that produces resources.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool will pool several types of structures.
func (*Pool) PrintAllocatedWaypoints ¶
func (pool *Pool) PrintAllocatedWaypoints()
PrintAllocatedWaypoints prints the number of still allocated waypoints in the pool
func (*Pool) StoneQuarry ¶
func (pool *Pool) StoneQuarry(n int) []*StoneQuarry
StoneQuarry allocated n at a time.
type Poolable ¶
type Poolable struct {
// contains filtered or unexported fields
}
Poolable objects can be pooled obviously
func (*Poolable) Deallocate ¶
func (poolable *Poolable) Deallocate()
Deallocate this object from the pool
func (*Poolable) IsAllocated ¶
IsAllocated is true if this object was previously allocated and thus not available.
type Ship ¶
type Ship struct {
BaseUnit
}
Ship is an IUnit that maintains a military vessel of some sort.
type StoneQuarry ¶
type StoneQuarry struct {
BaseUnit
}
StoneQuarry is an IUnit that maintains a stone quarry
type TCPWire ¶
TCPWire encapsulates our TCP wire connection.
func (*TCPWire) Receive ¶
func (wire *TCPWire) Receive(packet *WirePacket) error
Receive wire packet over the wire and returns any error
func (*TCPWire) ReceiveCheckEOF ¶
func (wire *TCPWire) ReceiveCheckEOF(packet *WirePacket) bool
ReceiveCheckEOF accepts packet over the wire and returns TRUE if EOF encountered
func (*TCPWire) Send ¶
func (wire *TCPWire) Send(packetArray []WirePacket) error
Send a packetarray over the wire. Returns any error
func (*TCPWire) SendAll ¶
func (wire *TCPWire) SendAll(packets ...*WirePacket) error
SendAll will send N number of packets in a single send over the wire.
func (*TCPWire) SendCheckEOF ¶
func (wire *TCPWire) SendCheckEOF(packetArray []WirePacket) bool
SendCheckEOF will send packetArray over the wire. If send failed and EOF detected TRUE is returned.
type Terrain ¶
type Terrain byte
Terrain enumeration
const ( // Grass is the default. Grass Terrain = iota // Mountains are assumed to be any stoney structure Mountains // Trees are 0..N number of trees. Trees // Water is just that. An ocean is just a large number of these. Water // Sand is more or less a desert terrain. Sand // Snow is the white stuff. Snow // Dirt is dirt. Dirt )
type Tower ¶
type Tower struct {
BaseUnit
}
Tower is an IUnit that maintains a military watch tower with some defensive capability
type UDPWire ¶
type UDPWire struct { Host string Port string Connection net.PacketConn }
UDPWire encapsulates our UDP wire connection.
type UnitMap ¶
UnitMap maintains a map of IUnits
type UnitType ¶
type UnitType byte
UnitType is the type of unit
const ( // UnitArcher or other ranged unit UnitArcher UnitType = iota + 1 // UnitArmory produces soldiers UnitArmory // UnitCastle fortification UnitCastle // UnitCatapult or other artillery UnitCatapult // UnitCavalry or mobile units UnitCavalry // UnitFarm or food production UnitFarm // UnitFence wood pallasade or abitus UnitFence // UnitGoldMine for gold UnitGoldMine // UnitHomeStead for creating a population UnitHomeStead // UnitInfantry or foot soldiers UnitInfantry // UnitPeasant is any villager UnitPeasant // UnitShip or some military vessel UnitShip // UnitStoneQuarry produces building material. UnitStoneQuarry // UnitTower or scout position UnitTower // UnitWall or defensive parameter UnitWall // UnitWoodPile or wood production UnitWoodPile )
type View ¶
type View struct { // Width and Height of this Grid Span image.Rectangle // Where the upper left hand corner of this grid // is located in world coordinates. If it is 0,0 then // WorldOrigin == Grid WorldOrigin image.Point // Generator Random number generator for this view Generator *rand.Rand }
View is a projection onto the World Grid
func (*View) CenterOfRect ¶
CenterOfRect returns the center of the Rectangle passed as a parameter.
func (*View) GenerateView ¶
GenerateView will initialize all internal structures. It will set the grid widith and height and situate the view onto the world at worldLocation
func (*View) RandomPointCloseToPoint ¶
RandomPointCloseToPoint will generate a point close to locus no farther than maxDistance away
func (*View) RandomPointInView ¶
RandomPointInView returns a pointer to a point randomly selected within the view.
func (*View) ToViewPoint ¶
ToViewPoint Converts world coordinates to view coordinates
type Wall ¶
type Wall struct {
BaseUnit
}
Wall is an IUnit that maintains a stone (masonry) wall or defensive fortification like an abatis.
type Waypoint ¶
type Waypoint struct { Poolable // The parent Waypoint in a path Parent *Waypoint // Location in the World Grid in world coordinates Locus image.Point // Scoring. // g is the cost it takes to get to this Waypoint // h is our guess (heuristic) as to how much it'll cost to reach the goal from that node // f = g + h so f is the final cost. The lower the better. F, G, H float64 // Position (also known as a neihborhood Position int }
Waypoint maintains scoring for a waypoint in the World Grid.
type WireCommand ¶
type WireCommand byte
WireCommand enumeration
const ( // NOOP is the no operation NOOP WireCommand = iota + 1 // MoveUnit moves unit to and fro. The rts-engine produces this command MoveUnit // PathUnitToLocation will set the destination of a unit to the CurrentX, CurrentY // does starting a pathing operation for the unit. Used by both client and rts-engine. PathUnitToLocation // NewUnitAdded means a new unit has been generated and added to the world. NewUnitAdded // UnitDestroyed means just that. That means dead and should be removed. UnitDestroyed // FullRefreshPlayerToUI means a screen refresh inwhich every acre of a player's view // is sent over the wire. FullRefreshPlayerToUI // PartialRefreshPlayerToUI means a screen refresh inwhich every unit and non-grass acre // is sent over the wire. Tha means the UI should assume missing acres are grass // Simple alogorithm for reducing chatter. PartialRefreshPlayerToUI // CancelMove will cancel a move in progress CancelMove // UnitStateRefresh means the complete state of a unit is sent over the wire to the ui. UnitStateRefresh // ResourceUpdate means the current tally of resources of a player should be sent over the wire to the ui. ResourceUpdate // ScrollView scrolls the view to the new x and y which is ToX and ToY ScrollView // SetView will set the view directly to world coordinates WorldX, WorldY, Width and Height. SetView // FullView will set the view to the entire World. Used mostly for testing. FullView // WhoAmI queries the rtsengine to return information on the current user connection. WhoAmI )
type WirePacket ¶
type WirePacket struct { Command WireCommand // The tarrain at CurrentX and CurrentY LocalTerrain Terrain // Unit ID. <= 0 if no ID UnitID int // Is the unique ID of the player that owns the unit. // OwnerPlayerID <= 0 if no ID and thus the unit is owned by nobody. OwnerPlayerID int // The Type of Unit if any. <=0 means no unit Unit UnitType // Used in MoveUnit, NewUnitAdded, NewUnitAdded, CancelMove, UnitStateRefresh, UnitDestroyed, ScrollView CurrentRow, CurrentColumn int // View Coordinates // Used in ResourceUpdate Gold, Wood, Food, Stone int // UnitStateRefresh Life int // For the World WorldWidth, WorldHeight, WorldRow, WorldColumn int // World Coordinates // For the View. The ViewRow and ViewColumn are in world coordinates // FullView uses these. SetView sets the new ViewWidth and ViewHeight ViewWidth, ViewHeight, ViewRow, ViewColumn int // WhoAmI fills this in and nothing more. PlayerName string // name of this player PlayerID int // unique ID of this player }
WirePacket is a packet of data that can be JSON marshalled/unmarshalled and sent over the wire. Naming of the fields is IMPORTANT so careful.
func (*WirePacket) Clear ¶
func (p *WirePacket) Clear()
Clear will reinitialize the structure for reuse.
type WoodPile ¶
type WoodPile struct {
BaseUnit
}
WoodPile is an IUnit that maintains a wood pile that provides wood.
type World ¶
type World struct {
Grid
}
World maintains the world state. This is the big one!
func NewWorld ¶
NewWorld will construct a random world of width and height specified. works on 'this'. Another way of thinking is width are the columns and height are the rows.
func (*World) GenerateGrassWorld ¶
func (world *World) GenerateGrassWorld()
GenerateGrassWorld will generate a world of grass....
func (*World) GenerateSimple ¶
func (world *World) GenerateSimple()
GenerateSimple will generate a simple world for basic testing. Good for testing pathing etcetera.
Source Files
¶
- AIPlayer.go
- acre.go
- archer.go
- armory.go
- autonumber.go
- baseplayer.go
- baseunit.go
- castle.go
- catapult.go
- cavalry.go
- farm.go
- fence.go
- game.go
- gamemaster.go
- goldmine.go
- grid.go
- healthandattack.go
- homestead.go
- humanplayer.go
- imechanic.go
- infantry.go
- iplayer.go
- ipoolable.go
- iunit.go
- movement.go
- movementmech.go
- pathing.go
- peasant.go
- pool.go
- poolable.go
- ship.go
- stonequarry.go
- tcpwire.go
- terrain.go
- tower.go
- udpwire.go
- unitmap.go
- view.go
- wall.go
- waypoint.go
- wirepacket.go
- woodpile.go
- world.go