Documentation ¶
Overview ¶
aerth game copyright 2017 aerth <aerth@riseup.net>
aerth game copyright 2017 aerth <aerth@riseup.net>
Index ¶
- Constants
- Variables
- func Distance(v1, v2 pixel.Vec) float64
- func DrawBar(imd *imdraw.IMDraw, color color.RGBA, cur, max float64, rect pixel.Rect)
- func DrawBase(canvas *pixelgl.Canvas)
- func DrawPattern(canvas pixel.Target, sprite *pixel.Sprite, bounds pixel.Rect, width float64)
- func DrawScore(winbounds pixel.Rect, t *text.Text, canvas pixel.Target, format string, ...)
- func DrawText(winbounds pixel.Rect, t *text.Text, canvas pixel.Target, format string, ...)
- func Drawbg(canvas *pixelgl.Canvas)
- func FindRandomTile(os []Object) pixel.Vec
- func FormatItemList(items []Item) string
- func GenerateItemName() string
- func GenerateName() string
- func GenerateWord() string
- func GetCursor(num int) *pixel.Sprite
- func InventoryLoop(win *pixelgl.Window, world *World)
- func LoadCharacterSheet(sheetPath string, numframes uint8) (sheet pixel.Picture, anims map[Direction][]pixel.Rect, err error)
- func LoadEntitySheet(sheetPath string, framesx, framesy uint8) (sheet pixel.Picture, anims map[EntityState]map[Direction][]pixel.Rect, ...)
- func LoadNewCharacterSheet(sheetPath string) (sheet pixel.Picture, anims map[Direction][]pixel.Rect, err error)
- func LoadPicture(path string) (pixel.Picture, error)
- func LoadSpriteSheet(path string) (pixel.Picture, []*pixel.Sprite)
- func LoadTTF(path string, size float64) (font.Face, error)
- func NewGame(win *pixelgl.Window, difficulty int, leveltest ...string)
- func NewText(size float64) *text.Text
- func NewTextSmooth(size float64) *text.Text
- func NewTitleText(size float64) *text.Text
- func RandomColor() pixel.RGBA
- func RandomItemEffect(t ItemType) func(Stats) Stats
- func Sqrt(x float64) float64
- func TitleMenu(win *pixelgl.Window) (breakloop bool)
- func UI() *text.Text
- func Version() string
- type ActionType
- type Animation
- type Button
- type Character
- func (char *Character) CountGold() string
- func (char *Character) Damage(n uint, from string)
- func (char *Character) Draw(t pixel.Target)
- func (c *Character) DrawBars(target pixel.Target, bounds pixel.Rect)
- func (char *Character) ExpUp(amount uint64)
- func (c *Character) MaxHealth() uint64
- func (c *Character) NextLevel() uint64
- func (c *Character) PickUp(items []Item) string
- func (char *Character) ResetLocation()
- func (c *Character) StatsReport() string
- func (char *Character) Update(dt float64, dir Direction, world *World)
- type DObject
- type DObjectType
- type Direction
- type Entity
- type EntityProperties
- type EntityState
- type EntityType
- type Item
- type ItemProperties
- type ItemType
- type Object
- func DrawPatternObject(spritenum int, objecttype ObjectType, bounds pixel.Rect, width float64) []Object
- func GetBlocks(objects []Object, position pixel.Vec) []Object
- func GetObjects(objects []Object, position pixel.Vec) []Object
- func GetObjectsAt(objects []Object, position pixel.Vec) []Object
- func GetTiles(objects []Object) []Object
- func NewBlock(loc pixel.Vec) Object
- func NewBlockBox(rect pixel.Rect) Object
- func NewTile(loc pixel.Vec) Object
- func NewTileBox(rect pixel.Rect) Object
- func TileNear(all []Object, loc pixel.Vec) Object
- func TilesAt(objects []Object, position pixel.Vec) []Object
- func (o Object) Draw(win pixel.Target, spritesheet pixel.Picture, sheetFrames []*pixel.Sprite, ...)
- func (o Object) GetNeighbors() []Object
- func (o Object) Highlight(win pixel.Target, color pixel.RGBA)
- func (o Object) PathEstimatedCost(to astar.Pather) float64
- func (o Object) PathNeighborCost(to astar.Pather) float64
- func (o Object) PathNeighbors() []astar.Pather
- func (o Object) String() string
- type ObjectProperties
- type ObjectType
- type Region
- type Stats
- type StatusEffect
- type World
- func (w *World) Action(char *Character, loc pixel.Vec, t ActionType, dir Direction)
- func (w *World) Block(dot pixel.Vec) Object
- func (w *World) Clean()
- func (w *World) CleanAnimations()
- func (w *World) Draw(target pixel.Target)
- func (w *World) DrawEntity(n int)
- func (w *World) Exit(code int)
- func (w *World) HighlightPaths(target pixel.Target)
- func (w *World) Init() *pixel.Batch
- func (w *World) IsButton(buttons []Button, point pixel.Vec) (Button, func(win pixel.Target, world *World), bool)
- func (w *World) IsLoot(location pixel.Vec) ([]Item, bool)
- func (w *World) LoadMap(path string) error
- func (w *World) LoadMapFile(path string) error
- func (w *World) Message(s string)
- func (w *World) NewAnimation(loc pixel.Vec, kind string, direction Direction)
- func (w *World) NewEntity(t EntityType) *Entity
- func (w *World) NewLoot(location pixel.Vec, items []Item)
- func (w *World) NewMobs(n int)
- func (w *World) NewRegion(name string, mapobjects []Object) *Region
- func (w *World) Object(dot pixel.Vec) Object
- func (w *World) RandomLootSomewhere()
- func (w *World) Reset()
- func (w *World) ShowAnimations(imd *imdraw.IMDraw)
- func (w World) String() string
- func (w *World) TextBox(win *pixelgl.Window, msg string)
- func (w *World) Tile(dot pixel.Vec) Object
- func (w *World) Update(dt float64)
- type WorldSettings
Constants ¶
View Source
const ( WEST = LEFT EAST = RIGHT NORTH = UP SOUTH = DOWN )
View Source
const ( Idle animState = iota Running )
Variables ¶
View Source
var DefaultEntityRectangle = pixel.R(-16, -16, 16, 16)
View Source
var DefaultMobPhys = ePhys{
RunSpeed: 40.5,
Gravity: 50.00,
Rate: 2,
}
DefaultPhys character
View Source
var DefaultPhys = charPhys{ RunSpeed: 60.5, Rect: pixel.R(-8, -8, 8, 8), Gravity: 50.00, Rate: 2, }
DefaultPhys character
View Source
var DefaultSpriteRectangle = pixel.R(-16, -16, 16, 16)
View Source
var DefaultStats = Stats{
Intelligence: 60,
Strength: 60,
Wisdom: 60,
Vitality: 60,
}
View Source
var GraphicRanges = []*unicode.RangeTable{ unicode.L, unicode.M, unicode.N, unicode.P, unicode.S, unicode.Zs, }
View Source
var SpriteFrame = pixel.R(-100, -100, 100, 100)
View Source
var TransparentBlue = pixel.ToRGBA(colornames.Blue).Scaled(0.4)
View Source
var TransparentPurple = pixel.ToRGBA(colornames.Purple).Scaled(0.4)
View Source
var TransparentRed = pixel.ToRGBA(colornames.Red).Scaled(0.4)
Functions ¶
func DrawPattern ¶
func FormatItemList ¶
func GenerateItemName ¶
func GenerateItemName() string
func GenerateName ¶
func GenerateName() string
func GenerateWord ¶
func GenerateWord() string
func InventoryLoop ¶
func LoadCharacterSheet ¶
func LoadCharacterSheet(sheetPath string, numframes uint8) (sheet pixel.Picture, anims map[Direction][]pixel.Rect, err error)
loadCharacterSheet returns an animated spritesheet
func LoadEntitySheet ¶
func LoadEntitySheet(sheetPath string, framesx, framesy uint8) (sheet pixel.Picture, anims map[EntityState]map[Direction][]pixel.Rect, err error)
loadCharacterSheet returns an animated spritesheet 13W 21H
func LoadNewCharacterSheet ¶
func NewTextSmooth ¶
func NewTitleText ¶
func RandomColor ¶
func RandomItemEffect ¶
Types ¶
type ActionType ¶
type ActionType int
const ( Talk ActionType = iota Slash ManaStorm MagicBullet Arrow )
func (ActionType) String ¶
func (i ActionType) String() string
type Animation ¶
type Animation struct { Name string Type ActionType // contains filtered or unexported fields }
type Character ¶
type Character struct { Phys charPhys // properties Stats Stats Sprite *pixel.Sprite // current stamp Matrix pixel.Matrix // location in canvas/map Frame pixel.Rect // size (for animation) Rect pixel.Rect // size (for collision) Dir Direction // Running direction (Idle down) Sheet pixel.Picture // all frames of animation (4 for each 4 direction, total 16) Anims map[Direction][]pixel.Rect // animation Rate float64 // animation State animState // Idle or Running Inventory []Item // inventory Health uint // hp Mana uint // mp Invisible bool // hidden from enemies Level uint W *World // contains filtered or unexported fields }
func NewCharacter ¶
func (*Character) ResetLocation ¶
func (char *Character) ResetLocation()
func (*Character) StatsReport ¶
type DObject ¶
type DObject struct { Object Object Contains []Item Until time.Time `json:"-"` Type DObjectType }
type Entity ¶
type Entity struct { Name string Type EntityType Rate float64 State animState Frame pixel.Rect // of sprite sheet Rect pixel.Rect // for damage, collisions Program EntityState P EntityProperties Phys ePhys Dir Direction // facing, attacking // contains filtered or unexported fields }
func (*Entity) ChangeMind ¶
type EntityProperties ¶
type EntityState ¶
type EntityState int
const ( S_IDLE EntityState = iota S_RUN S_WANDER S_GUARD S_SUSPECT S_HUNT S_DEAD )
func (EntityState) String ¶
func (i EntityState) String() string
type EntityType ¶
type EntityType int
const ( SKELETON EntityType = iota SKELETON_GUARD DOBJECT )
func (EntityType) String ¶
func (i EntityType) String() string
type Item ¶
type Item struct { Name string Type ItemType Properties ItemProperties Effect func(Stats) Stats Quantity uint64 }
func RandomLoot ¶
func RandomLoot() []Item
func RandomMagicItem ¶
func RandomMagicItem() Item
func StackItems ¶
type ItemProperties ¶
func DefaultItemProperties ¶
func DefaultItemProperties() ItemProperties
type Object ¶
type Object struct { Loc pixel.Vec `json:"L"` Rect pixel.Rect `json:"-"` Type ObjectType `json:"T,ObjectType"` P ObjectProperties `json:",omitempty"` SpriteNum int `json:"S,omitempty"` Sprite *pixel.Sprite `json:"-"` W *World `json:"-"` }
func DrawPatternObject ¶
func NewBlockBox ¶
func NewTileBox ¶
func (Object) GetNeighbors ¶
GetNeighbors gets the neighboring tiles
func (Object) PathNeighbors ¶
type ObjectProperties ¶
type ObjectType ¶
type ObjectType int
const ( O_NONE ObjectType = iota O_TILE O_BLOCK O_INVISIBLE O_SPECIAL O_WIN O_DYNAMIC // loot, doors )
func (ObjectType) String ¶
func (i ObjectType) String() string
type Region ¶
type Stats ¶
type StatusEffect ¶
type StatusEffect int
const ( E_POISON StatusEffect E_PARALYSIS E_FROZEN E_BURNED E_SLEEP E_CONFUSED E_TIRED E_DRUNK )
func (StatusEffect) String ¶
func (i StatusEffect) String() string
type World ¶
type World struct { Name string Bounds pixel.Rect Regions []*Region DObjects []*DObject Tiles, Blocks []Object // sorted Background string // path to pic, will be repeated xy if not empty Batches map[EntityType]*pixel.Batch // one batch for every spritemap Color pixel.RGBA // clear window with this color Entities []*Entity Sheets map[EntityType]pixel.Picture Anims map[EntityType]map[EntityState]map[Direction][]pixel.Rect // frankenmap Char *Character Animations []*Animation Messages []string Settings WorldSettings // contains filtered or unexported fields }
World holds all information about a world
func (*World) CleanAnimations ¶
func (w *World) CleanAnimations()
func (*World) Draw ¶
// Object returns the object at dot, very expensive func (w *World) Object(dot pixel.Vec) Object {
var ob Object for i := range w.Objects { if w.Objects[i].Rect.Contains(dot) { ob = w.Objects[i] if ob.Type == O_BLOCK { // prefer block over tile return ob } } } return ob
}
func (*World) DrawEntity ¶
func (*World) HighlightPaths ¶
func (*World) LoadMapFile ¶
func (*World) NewAnimation ¶
func (*World) NewEntity ¶
func (w *World) NewEntity(t EntityType) *Entity
func (*World) RandomLootSomewhere ¶
func (w *World) RandomLootSomewhere()
func (*World) ShowAnimations ¶
type WorldSettings ¶
type WorldSettings struct {
NumEnemy int
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.