steel-lord/entity/entity.go

71 lines
1.1 KiB
Go
Raw Normal View History

2019-06-28 16:37:33 -07:00
package entity
import (
2019-07-17 20:05:05 -07:00
"steel/interfaces"
2019-06-28 16:37:33 -07:00
"github.com/kettek/goro"
)
2019-07-17 20:05:05 -07:00
2019-06-28 16:37:33 -07:00
// Entity is a type that represents an active entity in the world.
type Entity struct {
2019-07-17 20:05:05 -07:00
x, y int
rune rune
style goro.Style
2019-06-28 16:37:33 -07:00
}
2019-07-17 20:05:05 -07:00
2019-06-28 16:37:33 -07:00
// NewEntity returns a pointer to a newly created Entity.
2019-07-17 20:05:05 -07:00
func NewEntity(x int, y int, r rune, s goro.Style) interfaces.Entity {
2019-06-28 16:37:33 -07:00
return &Entity{
2019-07-17 20:05:05 -07:00
x: x,
y: y,
rune: r,
style: s,
2019-06-28 16:37:33 -07:00
}
2019-07-17 20:05:05 -07:00
}
// 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
}