Documentation ¶
Index ¶
- Variables
- func ListBuiltin() ([]string, error)
- func ListDoodads() ([]string, error)
- func SortByName(list []*Doodad)
- type Actor
- type Doodad
- func Deserialize(filename string, bin []byte) (*Doodad, error)
- func FromGzip(data []byte) (*Doodad, error)
- func FromJSON(filename string, data []byte) (*Doodad, error)
- func FromZipfile(data []byte) (*Doodad, error)
- func LoadFile(filename string) (*Doodad, error)
- func LoadJSON(filename string) (*Doodad, error)
- func New(dimensions ...int) *Doodad
- func NewDummy(size int) *Doodad
- func (d *Doodad) AddLayer(name string, chunker *level.Chunker) Layer
- func (d *Doodad) AsJSON() ([]byte, error)
- func (d *Doodad) ChunkSize() int
- func (d *Doodad) ChunkSize8() uint8
- func (d *Doodad) Inflate()
- func (d *Doodad) Loop() error
- func (d *Doodad) Rect() render.Rect
- func (d *Doodad) ReloadZipfile(data []byte) error
- func (d *Doodad) Serialize() ([]byte, error)
- func (d *Doodad) SetOption(name, dataType, v string) string
- func (d *Doodad) Tag(name string) string
- func (d *Doodad) Teardown()
- func (d *Doodad) ToGzip() ([]byte, error)
- func (d *Doodad) ToJSON() ([]byte, error)
- func (d *Doodad) ToZipfile() ([]byte, error)
- func (m *Doodad) Vacuum() error
- func (d *Doodad) WriteFile(filename string) error
- func (d *Doodad) WriteJSON(filename string) error
- type Drawing
- type Layer
- type Option
Constants ¶
This section is empty.
Variables ¶
var (
ErrNotFound = errors.New("file not found")
)
Errors.
Functions ¶
func ListBuiltin ¶
ListBuiltin returns a listing of all built-in doodads. Exactly like ListDoodads() but doesn't return user home folder doodads.
func ListDoodads ¶
ListDoodads returns a listing of all available doodads between all locations, including user doodads.
func SortByName ¶
func SortByName(list []*Doodad)
SortByName orders an array of loaded Doodads by their titles.
Types ¶
type Actor ¶
type Actor interface { ID() string // Position and velocity, not saved to disk. Position() render.Point // DEPRECATED Velocity() render.Point // DEPRECATED for uix.Actor Size() render.Rect Grounded() bool SetGrounded(bool) // Movement commands. MoveBy(render.Point) // Add {X,Y} to current Position. MoveTo(render.Point) // Set current Position to {X,Y}. }
Actor is a reusable run-time drawing component used in Doodle. Actors are an active instance of a Doodad which have a position, velocity, etc.
type Doodad ¶
type Doodad struct { level.Base Filename string `json:"-"` // used internally, not saved in json Hidden bool `json:"hidden,omitempty"` Palette *level.Palette `json:"palette"` Size render.Rect `json:"size"` // doodad dimensions Script string `json:"script"` Hitbox render.Rect `json:"hitbox"` Layers []Layer `json:"layers"` Tags map[string]string `json:"data"` // arbitrary key/value data storage Options map[string]*Option `json:"options"` // runtime options for a doodad // Undo history, temporary live data not persisted to the level file. UndoHistory *drawtool.History `json:"-"` }
Doodad is a reusable component for Levels that have scripts and graphics.
func Deserialize ¶
Deserialize loads a doodad from its bytes format.
func FromZipfile ¶
FromZipfile reads a doodad from zipfile format.
func LoadFile ¶
LoadFile reads a doodad file from disk, checking a few locations.
It checks for embedded bindata, system-level doodads on the filesystem, and then user-owned doodads in their profile folder.
func New ¶
New creates a new Doodad.
You can give it one or two values for dimensions:
- New(size int) creates a square doodad (classic) - New(width, height int) lets you have a different width x height.
func (*Doodad) AddLayer ¶
AddLayer adds a new layer to the doodad. Call this rather than appending your own layer so it points the Zipfile and layer number in. The chunker is optional - pass nil and a new blank chunker is created.
func (*Doodad) ChunkSize8 ¶
ChunkSize8 returns the chunk size of the Doodad's first layer as its actual uint8 value.
func (*Doodad) Inflate ¶
func (d *Doodad) Inflate()
Inflate attaches the pixels to their swatches after loading from disk.
func (*Doodad) Loop ¶
Loop may be called each loop to allow the level to maintain its memory usage, e.g., for chunks not requested recently from a zipfile level to free those from RAM.
func (*Doodad) ReloadZipfile ¶
ReloadZipfile re-reads the level's zipfile after a write.
func (*Doodad) Serialize ¶
Serialize encodes a doodad to bytes and returns them, instead of writing to a file.
func (*Doodad) Teardown ¶
func (d *Doodad) Teardown()
Teardown cleans up texture cache memory when the doodad is no longer needed by the game.
func (*Doodad) ToJSON ¶
ToJSON serializes the doodad as JSON (gzip supported).
If balance.CompressLevels=true the doodad will be gzip compressed and the return value is gz bytes and not the raw JSON.
func (*Doodad) Vacuum ¶
Vacuum runs any maintenance or migration tasks for the level at time of save.
It will prune broken links between actors, or migrate internal data structures to optimize storage on disk of its binary data.
type Drawing ¶
type Drawing struct { Doodad *Doodad // contains filtered or unexported fields }
Drawing is a Doodad Actor that is based on drawings made inside the game.
func NewDrawing ¶
NewDrawing creates a Drawing actor based on a Doodad drawing. If you pass an empty ID string, it will make a random UUIDv4 ID.