doodle/pkg/doodads/drawing.go
Noah Petherbridge 405aaf509d Link Start Flags to Change Characters
New feature: link a Start Flag to another doodad in your level
and you will play as that doodad instead of Boy. All Creatures
are designed to be playable. Playing as "other" doodads leads
to interesting effects, like not being able to activate buttons,
switches, or warp doors and not having an inventory to pick up
keys. The Anvil is fun: it can destroy other mobile doodads by
jumping on them.

If the actor does not specify that it has gravity, the gameplay
starts in antigravity mode. This will be the vast majority of
non-mobile doodads and the Bird.

Other changes:

* The Blue and Red Azulians now share a doodad script.
* The Azulians AI is still to walk back and forth, pickup keys and
  press buttons. The Blue Azulian walks slower than the red one.
* The Blue Azulian is no longer hidden from the doodads list.
* Actor UUID values in levels are now V1 UUIDs (time-ordered).
  This will help to reliably resolve conflicts in draw order
  of overlapping doodads (newest added to level wins).
* Link Tool: clicking on a pair of already-linked doodads will
  now unlink them, so you don't have to delete one to delete
  the link.
* Actor Tool: deleting an actor immediately calls PruneLinks()
  to clean up any links that the deleted doodad might have.
2021-08-11 20:40:31 -07:00

93 lines
1.8 KiB
Go

package doodads
import (
"git.kirsle.net/go/render"
"github.com/google/uuid"
)
// Drawing is a Doodad Actor that is based on drawings made inside the game.
type Drawing struct {
Doodad *Doodad
id string
point render.Point
velocity render.Point
accel int
size render.Rect
hitbox render.Rect
grounded bool
}
// NewDrawing creates a Drawing actor based on a Doodad drawing. If you pass
// an empty ID string, it will make a random UUIDv4 ID.
func NewDrawing(id string, doodad *Doodad) *Drawing {
if id == "" {
id = uuid.Must(uuid.NewUUID()).String()
}
return &Drawing{
id: id,
Doodad: doodad,
size: doodad.Rect(),
}
}
// ID to get the Drawing ID.
func (d *Drawing) ID() string {
return d.id
}
// Position returns the Drawing's position.
func (d *Drawing) Position() render.Point {
return d.point
}
// Velocity returns the Drawing's velocity.
func (d *Drawing) Velocity() render.Point {
return d.velocity
}
// SetVelocity to set the speed.
func (d *Drawing) SetVelocity(v render.Point) {
d.velocity = v
}
// Acceleration returns the Drawing's acceleration.
func (d *Drawing) Acceleration() int {
return d.accel
}
// SetAcceleration to set the acceleration.
func (d *Drawing) SetAcceleration(v int) {
d.accel = v
}
// Size returns the Drawing's size.
func (d *Drawing) Size() render.Rect {
return d.size
}
// Grounded returns whether the Drawing is standing on solid ground.
func (d *Drawing) Grounded() bool {
return d.grounded
}
// SetGrounded sets the grounded state.
func (d *Drawing) SetGrounded(v bool) {
d.grounded = v
}
// MoveBy a relative value.
func (d *Drawing) MoveBy(by render.Point) {
d.point.Add(by)
}
// MoveTo an absolute world value.
func (d *Drawing) MoveTo(to render.Point) {
d.point = to
}
// Draw the drawing.
func (d *Drawing) Draw(e render.Engine) {
}