This commit is contained in:
Andrey Parhomenko 2023-02-18 04:03:28 +05:00
parent 8d8ce41e71
commit 92db008ccf
3 changed files with 5 additions and 7 deletions

View file

@ -20,8 +20,9 @@ func NewPlayer() *Player {
Sprite: &gx.Sprite{ Sprite: &gx.Sprite{
Object: &gx.Object{ Object: &gx.Object{
T: gx.Transform { T: gx.Transform {
P: gx.Vector{1, 1}, P: gx.Vector{100, 150},
S: gx.Vector{5, 5}, S: gx.Vector{5, 5},
RA: gx.Vector{200, 200},
}, },
}, },
Image: playerImg, Image: playerImg,

View file

@ -70,19 +70,15 @@ func (e *Engine) AddBehaver(b Behaver) {
e.behavers = append(e.behavers, b) e.behavers = append(e.behavers, b)
} }
func (e *engine) setNewDT() {
e.dt = time.Since(e.lastTime).Seconds()
e.lastTime = time.Now()
}
func (e *engine) Update() error { func (e *engine) Update() error {
eng := (*Engine)(e) eng := (*Engine)(e)
e.setNewDT() e.dt = time.Since(e.lastTime).Seconds()
for _, v := range eng.behavers { for _, v := range eng.behavers {
v.Update(eng) v.Update(eng)
//fmt.Println(v) //fmt.Println(v)
} }
e.lastTime = time.Now()
return nil return nil
} }

View file

@ -29,6 +29,7 @@ func (t Transform)Matrix() Matrix {
g := &Matrix{} g := &Matrix{}
g.Scale(t.S.X, t.S.Y) g.Scale(t.S.X, t.S.Y)
g.Translate(-t.RA.X, -t.RA.Y)
g.Rotate(t.R) g.Rotate(t.R)
g.Translate(t.P.X, t.P.Y) g.Translate(t.P.X, t.P.Y)