-
Notifications
You must be signed in to change notification settings - Fork 0
/
actor.go
28 lines (24 loc) · 856 Bytes
/
actor.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Package maze, moving objects
package maze
// Actor is something that can move around on the level
type Actor struct {
Character rune // Display character
CurrPos Position // Current location
EndPos Position // Destination, if calculated
Path []Position // Path, if calculated.
PathNav Walker
}
// Walker specifies the interface that can be used to walk an Actor through the maze
type Walker interface {
Initialize(level *Level, actor *Actor)
NextPosition()
}
// NewActor creates and initializes and Actor
func NewActor(c rune, startPos, endPos Position, navigator Walker) *Actor {
actor := Actor{Character: c, CurrPos: startPos, EndPos: endPos, PathNav: navigator}
return &actor
}
// HasFinished returns true if the actor has reached its destination
func (a Actor) HasFinished() bool {
return a.CurrPos == a.EndPos
}