2024-04-24 17:11:33 +03:00
|
|
|
package model
|
|
|
|
|
|
|
|
import (
|
2024-05-06 21:19:08 +03:00
|
|
|
"mvvasilev/last_light/engine"
|
2024-04-24 17:11:33 +03:00
|
|
|
|
|
|
|
"github.com/gdamore/tcell/v2"
|
|
|
|
"github.com/google/uuid"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Direction int
|
|
|
|
|
|
|
|
const (
|
2024-04-27 22:32:05 +03:00
|
|
|
DirectionNone Direction = iota
|
|
|
|
DirectionUp
|
|
|
|
DirectionDown
|
|
|
|
DirectionLeft
|
|
|
|
DirectionRight
|
2024-04-24 17:11:33 +03:00
|
|
|
)
|
|
|
|
|
2024-04-27 22:32:05 +03:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2024-04-24 17:11:33 +03:00
|
|
|
type Entity interface {
|
|
|
|
UniqueId() uuid.UUID
|
|
|
|
Input(e *tcell.EventKey)
|
|
|
|
Tick(dt int64)
|
|
|
|
}
|
|
|
|
|
|
|
|
type MovableEntity interface {
|
2024-05-06 21:19:08 +03:00
|
|
|
Position() engine.Position
|
|
|
|
MoveTo(newPosition engine.Position)
|
2024-05-06 18:59:14 +03:00
|
|
|
|
|
|
|
Entity
|
2024-04-24 17:11:33 +03:00
|
|
|
}
|