Direction
This commit is contained in:
@@ -3,9 +3,11 @@ package terrain
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/hajimehoshi/ebiten/v2"
|
||||
"gitlab.com/kbr4/9heroja/configuration"
|
||||
"gitlab.com/kbr4/9heroja/resources"
|
||||
"image"
|
||||
"log"
|
||||
"slices"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -15,6 +17,7 @@ var (
|
||||
type Terrain struct {
|
||||
positionX float64
|
||||
positionY float64
|
||||
direction configuration.Direction
|
||||
}
|
||||
|
||||
func (t *Terrain) DrawTerrain(screen *ebiten.Image) {
|
||||
@@ -49,6 +52,22 @@ func NewTerrain() *Terrain {
|
||||
}
|
||||
}
|
||||
|
||||
func (t *Terrain) GoDown() {
|
||||
t.positionY += 1
|
||||
func (t *Terrain) Move() {
|
||||
if slices.Contains([]configuration.Direction{configuration.North, configuration.NorthEast, configuration.NorthWest}, t.direction) {
|
||||
t.positionY += 1
|
||||
}
|
||||
if slices.Contains([]configuration.Direction{configuration.South, configuration.SouthEast, configuration.SouthWest}, t.direction) {
|
||||
t.positionY -= 1
|
||||
}
|
||||
if slices.Contains([]configuration.Direction{configuration.East, configuration.NorthEast, configuration.SouthEast}, t.direction) {
|
||||
t.positionX -= 1
|
||||
}
|
||||
if slices.Contains([]configuration.Direction{configuration.West, configuration.NorthWest, configuration.SouthWest}, t.direction) {
|
||||
t.positionX += 1
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (t *Terrain) ChangeDirection(direction configuration.Direction) {
|
||||
t.direction = direction
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user