71 lines
1.1 KiB
Go
71 lines
1.1 KiB
Go
package entity
|
|
|
|
import (
|
|
"steel/interfaces"
|
|
|
|
"github.com/kettek/goro"
|
|
)
|
|
|
|
// Entity is a type that represents an active entity in the world.
|
|
type Entity struct {
|
|
x, y int
|
|
rune rune
|
|
style goro.Style
|
|
}
|
|
|
|
// NewEntity returns a pointer to a newly created Entity.
|
|
func NewEntity(x int, y int, r rune, s goro.Style) interfaces.Entity {
|
|
return &Entity{
|
|
x: x,
|
|
y: y,
|
|
rune: r,
|
|
style: s,
|
|
}
|
|
}
|
|
|
|
// Move moves the entity by a given amount.
|
|
func (e *Entity) Move(x, y int) {
|
|
e.x += x
|
|
e.y += y
|
|
}
|
|
|
|
// X returns the entity's X value.
|
|
func (e *Entity) X() int {
|
|
return e.x
|
|
}
|
|
|
|
// SetX sets the entity's X value
|
|
func (e *Entity) SetX(x int) {
|
|
e.x = x
|
|
}
|
|
|
|
// Y returns the entity's Y value.
|
|
func (e *Entity) Y() int {
|
|
return e.y
|
|
}
|
|
|
|
// SetY sets the entity's Y value
|
|
func (e *Entity) SetY(y int) {
|
|
e.y = y
|
|
}
|
|
|
|
// Rune returns the entity's rune.
|
|
func (e *Entity) Rune() rune {
|
|
return e.rune
|
|
}
|
|
|
|
// SetRune sets the entity's rune.
|
|
func (e *Entity) SetRune(r rune) {
|
|
e.rune = r
|
|
}
|
|
|
|
// Style returns the entity's style.
|
|
func (e *Entity) Style() goro.Style {
|
|
return e.style
|
|
}
|
|
|
|
// SetStyle sets the entity's style.
|
|
func (e *Entity) SetStyle(s goro.Style) {
|
|
e.style = s
|
|
}
|