✨ Object-based land engine
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package entities
|
||||
|
||||
import (
|
||||
"git.solsynth.dev/highland/codingland/pkg/internal/common"
|
||||
"git.solsynth.dev/highland/codingland/pkg/internal/land"
|
||||
"github.com/veandco/go-sdl2/sdl"
|
||||
)
|
||||
|
||||
@@ -11,9 +11,30 @@ const (
|
||||
)
|
||||
|
||||
type Player struct {
|
||||
Position common.Vector2D
|
||||
Size common.Vector2D
|
||||
Velocity common.Vector2D
|
||||
land.BaseObject
|
||||
|
||||
Position land.Vector2D
|
||||
Size land.Vector2D
|
||||
Velocity land.Vector2D
|
||||
}
|
||||
|
||||
func (p *Player) Update() {
|
||||
keys := sdl.GetKeyboardState()
|
||||
if keys[sdl.SCANCODE_UP] == 1 || keys[sdl.SCANCODE_W] == 1 {
|
||||
p.Move(0, -1)
|
||||
}
|
||||
if keys[sdl.SCANCODE_DOWN] == 1 || keys[sdl.SCANCODE_S] == 1 {
|
||||
p.Move(0, 1)
|
||||
}
|
||||
if keys[sdl.SCANCODE_LEFT] == 1 || keys[sdl.SCANCODE_A] == 1 {
|
||||
p.Move(-1, 0)
|
||||
}
|
||||
if keys[sdl.SCANCODE_RIGHT] == 1 || keys[sdl.SCANCODE_D] == 1 {
|
||||
p.Move(1, 0)
|
||||
}
|
||||
|
||||
p.Move(0, 0)
|
||||
p.BaseObject.Update()
|
||||
}
|
||||
|
||||
func (p *Player) Move(deltaX, deltaY float64) {
|
||||
|
Reference in New Issue
Block a user