diff --git a/main.go b/main.go index 20ccff5..df56753 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "image" _ "image/png" "os" + "time" "github.com/faiface/pixel" "github.com/faiface/pixel/pixelgl" @@ -57,12 +58,28 @@ func run() { player := pixel.NewSprite(spritesheet, shipFrames[0]) + angle := 0.0 + + last := time.Now() for !win.Closed() { - //dt := time.Since(last).Seconds() - //last = time.Now() + dt := time.Since(last).Seconds() + last = time.Now() + win.Clear(colornames.Whitesmoke) - player.Draw(win, pixel.IM.Scaled(pixel.ZV, 0.25).Moved(win.Bounds().Center())) + mat := pixel.IM + mat = mat.Rotated(pixel.ZV, angle) + mat = mat.Scaled(pixel.ZV, 0.25).Moved(win.Bounds().Center()) + + player.Draw(win, mat) + + if win.Pressed(pixelgl.KeyLeft) { + angle += 3 * dt + } + if win.Pressed(pixelgl.KeyRight) { + angle -= 3 * dt + + } win.Update() }