mirror of
https://github.com/mvvasilev/last_light.git
synced 2025-04-19 12:49:52 +03:00
46 lines
668 B
Go
46 lines
668 B
Go
package model
|
|
|
|
import (
|
|
"mvvasilev/last_light/engine"
|
|
|
|
"github.com/gdamore/tcell/v2"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type Direction int
|
|
|
|
const (
|
|
DirectionNone Direction = iota
|
|
DirectionUp
|
|
DirectionDown
|
|
DirectionLeft
|
|
DirectionRight
|
|
)
|
|
|
|
func MovementDirectionOffset(dir Direction) (int, int) {
|
|
switch dir {
|
|
case DirectionUp:
|
|
return 0, -1
|
|
case DirectionDown:
|
|
return 0, 1
|
|
case DirectionLeft:
|
|
return -1, 0
|
|
case DirectionRight:
|
|
return 1, 0
|
|
}
|
|
|
|
return 0, 0
|
|
}
|
|
|
|
type Entity interface {
|
|
UniqueId() uuid.UUID
|
|
Input(e *tcell.EventKey)
|
|
Tick(dt int64)
|
|
}
|
|
|
|
type MovableEntity interface {
|
|
Position() engine.Position
|
|
MoveTo(newPosition engine.Position)
|
|
|
|
Entity
|
|
}
|