Documentation ¶
Index ¶
- Constants
- func ImageAsMap(imgkey string) ([]uint8, vec.I2, error)
- func Navigate(from, to vec.I2) []vec.I2
- func PushDialogue(dl ...*DialogueLine)
- func PushDialogueToBack(dl ...*DialogueLine)
- func RegisterImage(key string, png []byte)
- func Run(g Game, cfg *Config) error
- type BaseDoodad
- type Bubble
- type Button
- type ButtonSpec
- type CharInfo
- type CharMetrics
- type Config
- type DialogueDisplay
- type DialogueLine
- type Doodad
- type Event
- type EventType
- type Font
- type FrameInfo
- type Game
- type Grid
- type GridDelegate
- type Handler
- type ImageView
- type Level
- type Part
- type Scene
- type Sheet
- type SheetFrame
- type Sprite
- func (s *Sprite) AdvanceAnim()
- func (s *Sprite) Container() *View
- func (s *Sprite) Dst() (x0, y0, x1, y1 int)
- func (s *Sprite) Fixed() bool
- func (s *Sprite) ImageKey() string
- func (s *Sprite) ResetAnim()
- func (s *Sprite) Retire() bool
- func (s *Sprite) Src() (x0, y0, x1, y1 int)
- func (s *Sprite) Update(t int)
- func (s *Sprite) Visible() bool
- func (s *Sprite) Z() int
- type SpriteDelegate
- type Terrain
- func (t *Terrain) AddToScene(s *Scene)
- func (t *Terrain) Block(x, y int) TileInfo
- func (t *Terrain) Blocking(i, j int) bool
- func (t *Terrain) Fixed() bool
- func (t *Terrain) MakeAllVisible()
- func (t *Terrain) ObstaclesAndPaths(fatUL, fatDR, limit vec.I2) (obstacles, paths *vec.Graph)
- func (t *Terrain) Retire() bool
- func (t *Terrain) Size() vec.I2
- func (t *Terrain) Tile(x, y int) TileInfo
- func (t *Terrain) TileCoord(wc vec.I2) vec.I2
- func (t *Terrain) UpdatePartVisibility(origin vec.I2, dist int)
- type Text
- type TileInfo
- type Trigger
- type Unit
- type View
- func (v *View) Bounds() vec.Rect
- func (v *View) Container() *View
- func (v *View) Dispose()
- func (v *View) Fixed() bool
- func (v *View) Position() vec.I2
- func (v *View) RelativeBounds() vec.Rect
- func (v *View) RelativeZ() int
- func (v *View) Retire() bool
- func (v *View) SetBounds(bounds vec.Rect)
- func (v *View) SetParent(parent *View)
- func (v *View) SetPosition(ul vec.I2)
- func (v *View) SetPositionAndSize(pos, size vec.I2)
- func (v *View) SetRetire(ret bool)
- func (v *View) SetSize(sz vec.I2)
- func (v *View) SetVisible(vis bool)
- func (v *View) SetZ(z int)
- func (v *View) Size() vec.I2
- func (v *View) Visible() bool
- func (v *View) Z() int
Constants ¶
const ( EventNone = EventType(iota) EventMouseDown EventMouseUp )
Variables ¶
This section is empty.
Functions ¶
func ImageAsMap ¶
ImageAsMap returns the contents and size of a paletted PNG file.
func PushDialogue ¶
func PushDialogue(dl ...*DialogueLine)
PushDialogue makes some dialogue the next dialogue to play.
func PushDialogueToBack ¶
func PushDialogueToBack(dl ...*DialogueLine)
PushDialogueToBack makes some dialogue the dialogue to play after all the current dialogue is finished.
func RegisterImage ¶
RegisterImage tells the engine that a key maps to an image. Registered images will be loaded into a texture atlas with loadAllImages.
Types ¶
type BaseDoodad ¶
type BaseDoodad struct { *SheetFrame Offset vec.I2 UL, DR vec.I2 // base obstacle box (frame relative) }
BaseDoodad models a static object rendered at the player layer, but computed as obstacles (like terrain).
type Bubble ¶
Bubble renders a bubble at any size larger than bubblePartSize.Mul(3)
func (*Bubble) AddToScene ¶
type Button ¶
func (*Button) AddToScene ¶
type ButtonSpec ¶
type ButtonSpec struct { Label string Action func() }
type CharMetrics ¶
type DialogueDisplay ¶
type DialogueDisplay struct { *View // contains filtered or unexported fields }
Dialogue is all the things needed for displaying blocking dialogue text.
func NewDialogueDisplay ¶
func NewDialogueDisplay(scene *Scene) *DialogueDisplay
NewDialogueDisplay creates a new DialogueDisplay.
func (*DialogueDisplay) AddToScene ¶
func (d *DialogueDisplay) AddToScene(scene *Scene)
func (*DialogueDisplay) Handle ¶
func (d *DialogueDisplay) Handle(event *Event) bool
Update updates things in the dialogue, based on user input or passage of time. Returns true if the event is handled.
func (*DialogueDisplay) Layout ¶
func (d *DialogueDisplay) Layout(line *DialogueLine)
Layout rearranges views
type DialogueLine ¶
type DialogueLine struct { Avatar *SheetFrame Text string Buttons []*ButtonSpec AutoNext bool Slowness int }
DialogueLine is information for displaying a singe line of dialogue in a display.
type Doodad ¶
type Doodad struct { P vec.I2 *BaseDoodad }
Doodad is an instance of a BaseDoodad in a specific location.
type Font ¶
type Font interface { ImageKey(invert bool) string Metrics() CharMetrics LineHeight() int YOffset() int }
type FrameInfo ¶
type FrameInfo struct { Duration int // in model frames. -1 means infinite, 0 means 1 Next int // next model frame index, no special meaning for 0... Offset vec.I2 // subtract from position to get top-left of destination }
FrameInfo describes how to play a frame in an animation.
type Game ¶
type Game interface { // BubbleKey returns the key for the bubble image, and inverse. BubbleKey() (string, string) // Font is the general/default typeface to use. Font() Font Handler // Level provides the base level. Level() (*Level, error) // Player provides the player unit. Player() (Unit, *Sprite) Scene() *Scene // Triggers provide some dynamic behaviour. Triggers() []*Trigger // Viewport is the size of the window and the pixels in the window. Viewport() (pixelSize int, title string) }
Game abstracts the non-engine parts of the game: the story, art, level design, etc.
type Grid ¶
type Grid struct { *View GridDelegate // contains filtered or unexported fields }
type GridDelegate ¶
type Handler ¶
type Handler interface { // Handle handles the event e and returns true if the event is "consumed" or // false if the event "lives on" to be handled elsewhere. Handle(e *Event) bool }
Handler handles events.
type ImageView ¶
type ImageView struct { *View *SheetFrame }
ImageView displays one frame of a sheet filling a view.
type Level ¶
type Level struct { Doodads []*Doodad // sparse terrain objects MapSize vec.I2 TileMap, BlockMap []uint8 TileInfos, BlockInfos []TileInfo // dense terrain objects TilesetKey, BlocksetKey string TileSize, BlockHeight int // Obstacles and Paths are optional but speed up game start time. Obstacles, Paths *vec.Graph }
Level describes things needed for a base terrain/level.
type Part ¶
type Part interface { Container() *View ImageKey() string Src() (x0, y0, x1, y1 int) // relative to the image referred to by ImageKey() Dst() (x0, y0, x1, y1 int) // relative to the containing view. Fixed() bool Retire() bool // true if the part will never draw again. Visible() bool // true if the part is visible. Z() int }
Part participates in the draw system.
type Scene ¶
Scene manages drawing one scene.
Using a Scene as a parent will subtract the camera position. To use screen coordinates, use a parent of nil.
func (*Scene) CameraFocus ¶
CameraFocus sets the World offset such that p should be center of screen, or at least within the bounds of the terrain.
type SheetFrame ¶
SheetFrame lets you specify a frame in addition to a sheet.
func (*SheetFrame) ImageKey ¶
func (s *SheetFrame) ImageKey() string
func (*SheetFrame) Src ¶
func (s *SheetFrame) Src() (x0, y0, x1, y1 int)
type Sprite ¶
type Sprite struct { *View // Container for drawPosition; can be a new view. Pos vec.F2 // Position SpriteDelegate // contains filtered or unexported fields }
Sprite concerns itself with displaying the right frame of an animation at the right time, at the right position, and at the right Z order.
func (*Sprite) AdvanceAnim ¶
func (s *Sprite) AdvanceAnim()
type SpriteDelegate ¶
type Terrain ¶
Terrain is the base layer of the game world.
func (*Terrain) AddToScene ¶
AddToScene adds terrain objects to the scene.
func (*Terrain) MakeAllVisible ¶
func (t *Terrain) MakeAllVisible()
MakeAllVisible enables visiblity for all parts of the terrain.
func (*Terrain) ObstaclesAndPaths ¶
ObstaclesAndPaths constructs two graphs, the first describing terrain obsctacles, the second describing a network of valid paths around the obstacles. Obstacles will be fattened according to the footprint fatUL, fatDR, and paths will be based on vertices at convex points of the obstacle graph plus 1 pixel in both dimensions outwards from the convex vertex.
type Text ¶
func (*Text) AddToScene ¶
type Trigger ¶
type Trigger struct { Name string Tiles []vec.I2 Active func(gameFrame int) bool Depends []string Fire func(gameFrame int) Repeat bool // contains filtered or unexported fields }
Trigger is everything to do with reacting to the player or time or ... On the PC entering any of the Tiles, Fired, Active, and Depends will be checked and then Fire will happen. If no Tiles are listed, it will be added to a global list of triggers checked on every frame.
type Unit ¶
type Unit interface { // GoIdle asks the unit to stop whatever it's doing ("at ease"). GoIdle() // Footprint is the rectangle relative to the sprite position with the ground area of the unit. Footprint() (ul, dr vec.I2) // Path is the path the unit is currently following. The current position is // implied as the first point. Path() []vec.I2 }
Unit can be given orders. Examples of units include the player character, NPCs, etc. Or it could be a unit in an RTS.
type View ¶
type View struct {
// contains filtered or unexported fields
}
View represents a rectangular region in a view hierarchy. It caches its real position information because why not.
func (*View) Dispose ¶
func (v *View) Dispose()
Dispose retires this view and all subviews, and disconnects everything.
func (*View) RelativeBounds ¶
func (*View) SetPosition ¶
SetPosition moves the view to a new position without altering the size. It invalidates.
func (*View) SetPositionAndSize ¶
SetPosition moves the view to a new position and changes its size. It invalidates.
func (*View) SetSize ¶
SetSize alters the size of the view without altering the top-left corner of the bounds. It invalidates nothing.