diff --git a/src/cmd/test/main.go b/src/cmd/test/main.go index af9c23e..f67221b 100644 --- a/src/cmd/test/main.go +++ b/src/cmd/test/main.go @@ -34,7 +34,9 @@ func (p *Player) Update(e *gx.Engine) { //p.Sprite.Object.T.P.Y += 40 * e.DT() dt := e.DT() c := e.Camera() - c.Object.T.P.X += 40 * dt + //c.Object.T.P.X += 40 * dt + //c.Object.T.S.X += .01 * dt + c.Object.T.R += .2 * dt } func main() { diff --git a/src/gix/main.go b/src/gix/main.go new file mode 100644 index 0000000..27f1319 --- /dev/null +++ b/src/gix/main.go @@ -0,0 +1,5 @@ +package gix + +import ( + "github.com/hajimehoshi/ebiten/v2/inpututil" +) diff --git a/src/gx/camera.go b/src/gx/camera.go index 3e83153..9c98a13 100644 --- a/src/gx/camera.go +++ b/src/gx/camera.go @@ -14,8 +14,8 @@ func (c *Camera)Matrix(scale bool) Matrix { g := &Matrix{} g.Translate( - c.Object.T.RA.X, - c.Object.T.RA.Y, + -c.Object.T.RA.X, + -c.Object.T.RA.Y, ) g.Rotate(c.Object.T.R) diff --git a/src/gx/keys.go b/src/gx/keys.go new file mode 100644 index 0000000..bcfce50 --- /dev/null +++ b/src/gx/keys.go @@ -0,0 +1,8 @@ +package gx + +import ( + "github.com/hajimehoshi/ebiten/v2" +) + +type Key = ebiten.Key + diff --git a/src/gx/main.go b/src/gx/main.go index eb43c6b..0c16086 100644 --- a/src/gx/main.go +++ b/src/gx/main.go @@ -2,6 +2,7 @@ package gx import ( "github.com/hajimehoshi/ebiten/v2" + "github.com/hajimehoshi/ebiten/v2/inpututil" "github.com/surdeus/godat/src/sparsex" //"fmt" "time" @@ -23,6 +24,7 @@ type Engine struct { lastTime time.Time dt Float camera *Camera + keys []Key } type engine Engine @@ -31,6 +33,10 @@ func (e *Engine) Camera() *Camera { return e.camera } +func (e *Engine) Keys() []Key { + return e.keys +} + func New( cfg *WindowConfig, ) *Engine { @@ -43,7 +49,8 @@ func New( camera: &Camera{ Object: &Object{ T: Transform{ - S: Vector{0.1, 1}, + S: Vector{1, 1}, + RA: Vector{480, 320}, }, }, }, @@ -85,6 +92,9 @@ func (e *Engine) AddBehaver(b Behaver) { func (e *engine) Update() error { eng := (*Engine)(e) + e.keys = inpututil. + AppendPressedKeys(e.keys[:0]) + e.dt = time.Since(e.lastTime).Seconds() for _, v := range eng.behavers { v.Update(eng)