Moveable viewport. Absolute positioning (for UI etc) is possible. Added distance-based bounder for projectiles etc as 'screen' is no longer a suitable bounder. Removed debug msg.

This commit is contained in:
stevenhowes
2022-03-27 17:02:32 +01:00
parent bfa9ab0037
commit 428e2d175c
7 changed files with 88 additions and 24 deletions
+5 -4
View File
@@ -9,7 +9,6 @@ package GoRetro
import (
"encoding/json"
"fmt"
"os"
"time"
@@ -65,12 +64,16 @@ func (an *animator) onUpdate() error {
}
func (an *animator) onDraw() error {
Position := an.container.Position
if !an.container.PositionAbsolute {
Position = vectorAdd(an.container.Position, ViewPort.Position)
}
return drawTexture(
an.tex,
VectorInt32{an.sequences[an.current].frames[an.sequences[an.current].frame].W, an.sequences[an.current].frames[an.sequences[an.current].frame].H},
VectorInt32{an.sequences[an.current].frames[an.sequences[an.current].frame].X, an.sequences[an.current].frames[an.sequences[an.current].frame].Y},
an.container.Position,
Position,
an.container.Rotation,
an.container.Renderer)
}
@@ -131,8 +134,6 @@ func NewSequence(
}
defer jsonFile.Close()
fmt.Println(seq.frames)
seq.frame = 0
seq.sampleRate = sampleRate
seq.loop = loop