From 400552e7429f1223c99de08f19ec1b9f808a1ea6 Mon Sep 17 00:00:00 2001 From: Josh Deprez Date: Wed, 1 Sep 2021 09:34:49 +1000 Subject: [PATCH] sprite is now Transformer --- cpuprofile.pprof | Bin 5620 -> 4087 bytes engine/sprite.go | 15 +++++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/cpuprofile.pprof b/cpuprofile.pprof index 53dbe3d70537641e1514e15c4874d4568d65a7c5..e3d82765e34e558069e8e0140dffcfb5e3aa8404 100644 GIT binary patch literal 4087 zcmVYFj1XD!m;Xr`&0O2GM zLg}G7ZGg0Cfs*sx+0{zMviy+$k#^_z-PiBC_kQ=AU4P=q8y|S?=)JF0mKL)B6qOdU zQBd6S?(v)MjO?b*`wu<*Ua<@;fG=Htha?AC08RuT5MwL=K@3Wxpnj&upoR{ zL|72U;#jFXTn+&cj+7P$ibfU7z=HVp$*aZE(eQ2GozXB3$4Ma>*l2wJKVB2q82EV^ zsTl)+AdQ!SjlsYD@f!kTaMCx=AdF#Yf?UNIo_yv#ftA2xMRJgp!fPcYUIGaeCdmYVJ6O$s>2iW zT#pTo9>YpX%f^C$I_l;N6d3{qdL6&2vVGR(ty(tH`%B)sA1ivpVh?*s{(0tzZpJY11; zth6jRv9by$jV026O~&s$aP*q~0K;X#;LwM+&1RD+fGPN+yQ!?E!kxa8Q=tZHq|tJS zO~v>7Zj|I=b_r}ETbDpB)=H`j>=OL_3)c!irop}b?oER_tdr_xVAHVg_FDut9r`Aa z+;mug3#4ip*mQjJ+k{DQyn-+Z7UDv}B>eur5HVWW4b`!e+wLQwW<0OK=HcGx3_wsG_UkM}9?D!%|!-m50N5zDlM{y=2;SX@)#g z23C#tfAYOTI)uw$6dXEw|2S67DQ3vYdvOwEEL0XfKK!z)!}aTYAYWzwZF#%9BE zTu!!U<3Bt^i|4@GBDENs11oR^VRP_AKA!t0Lm)gZ?@e&l>^bsGIm9CP=uvUOYLr84E`8-&QYo*2*WAkAhu9McwAvPc1eTJ4Q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(1`I=~GynihHQRsy diff --git a/engine/sprite.go b/engine/sprite.go index 6eefbcd..bc7ab0f 100644 --- a/engine/sprite.go +++ b/engine/sprite.go @@ -11,6 +11,7 @@ import ( var _ interface { Drawer Scanner + Transformer Updater } = &Sprite{} @@ -30,14 +31,7 @@ type Sprite struct { } func (s *Sprite) Draw(screen *ebiten.Image, opts ebiten.DrawImageOptions) { - dp := s.Actor.Pos.Add(s.FrameOffset) - var geom ebiten.GeoM - geom.Translate(float64(dp.X), float64(dp.Y)) - geom.Concat(opts.GeoM) - opts.GeoM = geom - - src := s.Sheet.SubImage(s.anim.CurrentFrame()) - screen.DrawImage(src, &opts) + screen.DrawImage(s.Sheet.SubImage(s.anim.CurrentFrame()), &opts) } func (s *Sprite) Scan() []interface{} { @@ -54,5 +48,10 @@ func (s *Sprite) SetAnim(a *Anim) { s.anim = a } +func (s *Sprite) Transform() (opts ebiten.DrawImageOptions) { + opts.GeoM.Translate(float2(s.Actor.Pos.Add(s.FrameOffset))) + return opts +} + // anim isn't returned from Scan so we must update it ourselves func (s *Sprite) Update() error { return s.anim.Update() }