Documentation ¶
Index ¶
- type Buildable
- type EditorMode
- type EntityFactory
- type Fonts
- type GameSpeed
- type GameTick
- type Grid
- func (g *Grid[T]) Clamp(x, y int) (int, int)
- func (g *Grid[T]) Contains(x, y int) bool
- func (g *Grid[T]) Fill(value T)
- func (g *Grid[T]) Get(x, y int) T
- func (g *Grid[T]) GetPointer(x, y int) *T
- func (g *Grid[T]) Height() int
- func (g *Grid[T]) MarshalJSON() ([]byte, error)
- func (g *Grid[T]) Set(x, y int, value T)
- func (g *Grid[T]) UnmarshalJSON(data []byte) error
- func (g *Grid[T]) Width() int
- type LandUse
- type LandUseEntities
- type Mouse
- type Production
- type RandomTerrains
- type Rules
- type SaveEvent
- type SaveTime
- type Screen
- type Selection
- type Sprites
- func (s *Sprites) Get(idx int) *ebiten.Image
- func (s *Sprites) GetIndex(name string) int
- func (s *Sprites) GetInfo(idx int) *util.Sprite
- func (s *Sprites) GetMultiTileIndex(idx int, dirs terr.Directions, frame int, rand int) int
- func (s *Sprites) GetMultiTileTerrainIndex(t terr.Terrain, dirs terr.Directions, frame int, rand int) int
- func (s *Sprites) GetRand(idx int, frame int, rand int) *ebiten.Image
- func (s *Sprites) GetSprite(idx int) *ebiten.Image
- func (s *Sprites) GetTerrainIndex(t terr.Terrain) int
- type Stock
- type Terrain
- type TerrainEntities
- type TerrainGrid
- func (g *TerrainGrid) CountNeighbors4(x, y int, tp terr.Terrain) int
- func (g *TerrainGrid) CountNeighbors8(x, y int, tp terr.Terrain) int
- func (g *TerrainGrid) CountNeighborsMask4(x, y int, tp terr.Terrains) int
- func (g *TerrainGrid) CountNeighborsMask8(x, y int, tp terr.Terrains) int
- func (g *TerrainGrid) NeighborsMask(x, y int, tp terr.Terrain) terr.Directions
- func (g *TerrainGrid) NeighborsMaskMulti(x, y int, tp terr.Terrains) terr.Directions
- func (g *TerrainGrid) NeighborsMaskMultiReplace(x, y int, tp terr.Terrains, rx, ry int, rt terr.Terrain) terr.Directions
- type UI
- func (ui *UI) ClearSelection()
- func (ui *UI) CreateRandomButtons(randomTerrains int)
- func (ui *UI) DisableButton(id terr.Terrain, message string)
- func (ui *UI) Draw(screen *ebiten.Image)
- func (ui *UI) EnableButton(id terr.Terrain)
- func (ui *UI) MouseInside(x, y int) bool
- func (ui *UI) ReplaceAllButtons(rules *Rules)
- func (ui *UI) ReplaceButton(stock *Stock, rules *Rules, randTerrains *RandomTerrains, renderTick int64, ...) bool
- func (ui *UI) SetPopulationLabel(text string, warning bool)
- func (ui *UI) SetRandomTilesLabel(text string)
- func (ui *UI) SetResourceLabel(id resource.Resource, text string, warning bool)
- func (ui *UI) SetSpeedLabel(text string)
- func (ui *UI) SetStatusLabel(text string)
- func (ui *UI) SetTimerLabel(text string)
- func (ui *UI) UI() *ebitenui.UI
- func (ui *UI) Update()
- type UpdateInterval
- type View
- func (v *View) Bounds(w, h int) image.Rectangle
- func (v *View) BoundsToGlobal(b *WorldBounds) image.Rectangle
- func (v *View) Center(cell image.Point, screenWidth, screenHeight int)
- func (v *View) GlobalToTile(x, y int) image.Point
- func (v *View) MapBounds(screenWidth, screenHeight int) image.Rectangle
- func (v *View) Offset() image.Point
- func (v *View) ScreenToGlobal(x, y int) (int, int)
- func (v *View) SubtileToGlobal(x, y float64) image.Point
- func (v *View) TileToGlobal(x, y int) image.Point
- type WorldBounds
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buildable ¶
Buildable resource
func NewBuildable ¶
func (*Buildable) NeighborsMask ¶
func (b *Buildable) NeighborsMask(x, y int) (terr.Directions, terr.Directions)
type EditorMode ¶ added in v0.2.0
type EditorMode struct {
IsEditor bool
}
EditorMode resource, indicating editor mode.
type EntityFactory ¶
type EntityFactory struct {
// contains filtered or unexported fields
}
EntityFactory is a helper to create game entities.
func NewEntityFactory ¶
func NewEntityFactory(world *ecs.World) EntityFactory
NewEntityFactory creates a new EntityFactory for a given world.
func (*EntityFactory) RemoveLandUse ¶
func (f *EntityFactory) RemoveLandUse(world *ecs.World, x, y int)
RemoveLandUse removes land use from a given position, and updates the game grids.
func (*EntityFactory) Set ¶
func (f *EntityFactory) Set(world *ecs.World, x, y int, value terr.Terrain, randSprite uint16, randomize bool) ecs.Entity
Set creates an entity of the given terrain type, placing it in the world and updating the game grids.
func (*EntityFactory) SetBuildable ¶
func (f *EntityFactory) SetBuildable(x, y, r int, build bool)
SetBuildable updates the build-ability grid. Only used for initialization, not required when using EntityFactory.Set or EntityFactory.RemoveLandUse.
type GameSpeed ¶
type GameSpeed struct { // Is the game paused? Pause bool // Game speed as an exponent for base 2. s = 2^Speed Speed int8 // Minimum game speed, as an exponent for base 2. MinSpeed int8 // Maximum game speed, as an exponent for base 2. MaxSpeed int8 }
GameSpeed resource.
type GameTick ¶
type GameTick struct { // Current update tick. Stops when the game is paused. Tick int64 // Current render tick. Does not stop when the game is paused. RenderTick int64 }
GameTick resource.
type Grid ¶
type Grid[T comparable] struct { // contains filtered or unexported fields }
Grid data structure
func (*Grid[T]) GetPointer ¶
Get a pointer to a value from the Grid.
func (*Grid[T]) MarshalJSON ¶
func (*Grid[T]) UnmarshalJSON ¶
type Mouse ¶
type Mouse struct { // whether the mouse is inside the game window. IsInside bool }
Mouse resource.
type Production ¶
type Production struct { // Current production, indexed by [resource.Resource]. Prod []int // Current consumption, indexed by [resource.Resource]. Cons []int }
Production, accumulated globally.
func NewProduction ¶
func NewProduction() Production
NewProduction creates a new Production resource.
func (*Production) Reset ¶
func (p *Production) Reset()
Reset all production and consumption zo zero.
type RandomTerrains ¶ added in v0.2.0
type Rules ¶
type Rules struct { // World extent in X and Y direction, in number of tiles. WorldSize int // Initial build radius around the starting position. InitialBuildRadius int // Initial population limit. InitialPopulation int // Initial number of placable terrains. InitialRandomTerrains int // Number of random terrains/cards. RandomTerrainsCount int // List of terrains to draw cards from. RandomTerrains []terr.Terrain // Initial resources of the player. InitialResources []int // Probability of special cards/terrains that can be placed over existing terrain. SpecialCardProbability float64 }
Rules resource, holding game rules read from JSON.
type SaveEvent ¶
type SaveEvent struct { // Whether the save button was clicked in this tick. ShouldSave bool // Whether the game should quit and show the main menu. ShouldQuit bool // Whether the save as map button was clicked in this tick. ShouldSaveMap bool }
SaveEvent resource
type Screen ¶ added in v0.2.0
type Screen struct { // The screen image. Image *ebiten.Image // Current screen width. Width int // Current screen height. Height int }
Screen resource for drawing.
type Selection ¶
type Selection struct { // Selected terrain type. BuildType terr.Terrain // ID of the selected button. ButtonID int // Random sprite index of the selected button. RandSprite uint16 // Whether a new random sprite index should be draw on placement. Randomize bool // Whether a special tile has been selected. AllowRemove bool }
Selection from the build toolbar.
type Sprites ¶
type Sprites struct { // Tile width for rendering. TileWidth int // Tile height for rendering. TileHeight int // Game background color Background color.RGBA // UI text color TextColor color.RGBA // UI text color for highlight/warning TextHighlightColor color.RGBA // contains filtered or unexported fields }
Sprites holds all tileset data.
func NewSprites ¶
NewSprites creates a new Sprites resource from the given tileset folder.
func (*Sprites) GetMultiTileIndex ¶
GetMultiTileTerrainIndex returns the sprite index for an index, using multitile.
func (*Sprites) GetMultiTileTerrainIndex ¶
func (s *Sprites) GetMultiTileTerrainIndex(t terr.Terrain, dirs terr.Directions, frame int, rand int) int
GetMultiTileTerrainIndex returns the sprite index for a terrain ID, using multitile.
func (*Sprites) GetRand ¶
GetRand returns the sprite image for an index, with animation and random variations.
type Stock ¶
type Stock struct { // Total storage capacity, indexed by [resource.Resource]. Cap []int // Total storage, indexed by [resource.Resource]. Res []int // Total production ever delivered to storage, indexed by [resource.Resource]. Total []int // Total population. Population int // Total population limit. MaxPopulation int }
Stock resource, holding global stock information.
func (*Stock) AddResources ¶ added in v0.2.0
func (*Stock) CanPay ¶
func (s *Stock) CanPay(cost []terr.ResourceAmount) bool
CanPay checks whether there are sufficient resources in the stock to pay the given amounts.
func (*Stock) Pay ¶
func (s *Stock) Pay(cost []terr.ResourceAmount)
Pay the given amounts be subtracting them from the stock.
type TerrainGrid ¶
func (*TerrainGrid) CountNeighbors4 ¶
func (g *TerrainGrid) CountNeighbors4(x, y int, tp terr.Terrain) int
func (*TerrainGrid) CountNeighbors8 ¶
func (g *TerrainGrid) CountNeighbors8(x, y int, tp terr.Terrain) int
func (*TerrainGrid) CountNeighborsMask4 ¶
func (g *TerrainGrid) CountNeighborsMask4(x, y int, tp terr.Terrains) int
func (*TerrainGrid) CountNeighborsMask8 ¶
func (g *TerrainGrid) CountNeighborsMask8(x, y int, tp terr.Terrains) int
func (*TerrainGrid) NeighborsMask ¶
func (g *TerrainGrid) NeighborsMask(x, y int, tp terr.Terrain) terr.Directions
func (*TerrainGrid) NeighborsMaskMulti ¶
func (g *TerrainGrid) NeighborsMaskMulti(x, y int, tp terr.Terrains) terr.Directions
func (*TerrainGrid) NeighborsMaskMultiReplace ¶
func (g *TerrainGrid) NeighborsMaskMultiReplace(x, y int, tp terr.Terrains, rx, ry int, rt terr.Terrain) terr.Directions
type UI ¶
type UI struct {
// contains filtered or unexported fields
}
UI resource.Represents the complete game UI.
func NewUI ¶
func NewUI(world *ecs.World, selection *Selection, fonts *Fonts, sprts *Sprites, randomTerrains *RandomTerrains, save *SaveEvent, editor *EditorMode) UI
func (*UI) ClearSelection ¶
func (ui *UI) ClearSelection()
func (*UI) CreateRandomButtons ¶
func (*UI) DisableButton ¶ added in v0.2.0
func (*UI) EnableButton ¶ added in v0.2.0
func (*UI) MouseInside ¶
func (*UI) ReplaceAllButtons ¶
func (*UI) ReplaceButton ¶
func (*UI) SetPopulationLabel ¶
func (*UI) SetRandomTilesLabel ¶ added in v0.2.0
func (*UI) SetResourceLabel ¶
func (*UI) SetSpeedLabel ¶
func (*UI) SetStatusLabel ¶ added in v0.2.0
func (*UI) SetTimerLabel ¶
type UpdateInterval ¶
type UpdateInterval struct { // The interval between updates of entities, in game ticks. Usually equal to TPS. Interval int64 // Number of intervals used in (production) countdowns. Usually 60, resulting in 1 minute. Countdown int }
UpdateInterval resource.
type View ¶
type View struct {
// Tile width and height, for convenient access.
TileWidth, TileHeight int
// Current global coordinates of the top-left corner of the screen, in pixels.
X, Y int
// Y offset used to determine the mouse position.
MouseOffset int
// Current zoom factor.
Zoom float64
}
View resource, holding the game's view state.
func (*View) BoundsToGlobal ¶
func (v *View) BoundsToGlobal(b *WorldBounds) image.Rectangle
type WorldBounds ¶
WorldBounds contain the bounding box of the currently built world. Used to limit scrolling/panning.
func (*WorldBounds) AddPoint ¶
func (b *WorldBounds) AddPoint(p image.Point)
AddPoint extends the bounds sp that they contain the given point.