diff --git a/ld48-29.go b/ld48-29.go index 8488ec8..ed9aebd 100644 --- a/ld48-29.go +++ b/ld48-29.go @@ -146,13 +146,16 @@ func scaledSpriteQuad(x int, y int, w int, h int, scale float32) { gl.End() } -func drawSprite(texture gl.Texture, x float64, y float64, list uint) { +func drawSprite(texture gl.Texture, x float64, y float64, a float64, list uint) { + deg := math.Mod(360 * float64(a) / (2 * math.Pi), 360.0) gl.LoadIdentity() texture.Bind(gl.TEXTURE_2D) gl.Translatef(float32(x), float32(y), 0) + gl.Rotatef(float32(deg), 0.0, 0.0, 1.0); gl.CallList(list) } + // main func main() { @@ -269,27 +272,30 @@ func render(textures map[string]gl.Texture, lists map[string]uint) { gl.Enable(gl.TEXTURE_2D) gl.Enable(gl.LIGHTING) - drawSprite(textures["sprites"], 0, 0, lists["test"]) - drawSprite(textures["sprites"], 320, 0, lists["test"]) - drawSprite(textures["sprites"], 640, 0, lists["test"]) - drawSprite(textures["sprites"], 320, 240, lists["test"]) - drawSprite(textures["sprites"], 320, 480, lists["test"]) - drawSprite(textures["sprites"], 0, 240, lists["test"]) - drawSprite(textures["sprites"], 0, 480, lists["test"]) - drawSprite(textures["sprites"], 640, 240, lists["test"]) - drawSprite(textures["sprites"], 640, 480, lists["test"]) + drawSprite(textures["sprites"], 0, 0, 0, lists["test"]) + drawSprite(textures["sprites"], 320, 0, 0, lists["test"]) + drawSprite(textures["sprites"], 640, 0, 0, lists["test"]) + drawSprite(textures["sprites"], 320, 240, 0, lists["test"]) + drawSprite(textures["sprites"], 320, 480, 0, lists["test"]) + drawSprite(textures["sprites"], 0, 240, 0, lists["test"]) + drawSprite(textures["sprites"], 0, 480, 0, lists["test"]) + drawSprite(textures["sprites"], 640, 240, 0, lists["test"]) + drawSprite(textures["sprites"], 640, 480, 0, lists["test"]) t := float64(time.Now().UnixNano()) / math.Pow(10, 9) - x := (math.Sin(2*math.Pi*t/60) + 1)/2 * float64(width) - y := (math.Cos(2*math.Pi*t/60) + 1)/2 * float64(height) - drawSprite(textures["sprites"], x, y, lists["test"]) + a := 2 * math.Pi * t / 60 + x := (math.Sin(a) + 1) / 2 * float64(width) + y := (math.Cos(a) + 1) / 2 * float64(height) + drawSprite(textures["sprites"], x, y, -a, lists["test"]) - x = (math.Sin(10*2*math.Pi*t/60) + 1)/2 * float64(width) - y = (math.Cos(10*2*math.Pi*t/60) + 1)/2 * float64(height) - drawSprite(textures["sprites"], x, y, lists["test"]) + a = 10 * 2 * math.Pi * t / 60 + x = (math.Sin(a) + 1) / 2 * float64(width) + y = (math.Cos(a) + 1) / 2 * float64(height) + drawSprite(textures["sprites"], x, y, -a, lists["test"]) - x = (math.Sin(60*2*math.Pi*t/60) + 1)/2 * float64(width) - y = (math.Cos(60*2*math.Pi*t/60) + 1)/2 * float64(height) - drawSprite(textures["sprites"], x, y, lists["test"]) + a = 60 * 2 * math.Pi * t / 60 + x = (math.Sin(a) + 1) / 2 * float64(width) + y = (math.Cos(a) + 1) / 2 * float64(height) + drawSprite(textures["sprites"], x, y, -a, lists["test"]) } diff --git a/log.mdown b/log.mdown index 951d7e3..44b0047 100644 --- a/log.mdown +++ b/log.mdown @@ -79,3 +79,17 @@ All time is CEST After much fight against GLOrtho, now having arbitrary sprite positioning in viewport coordinates. ![](screenshots/3.png) + +- 17:55 + + Girlfriend back home. Let's take a break and have a walk outside. + +- 19:15 + + Back to the task! + +- 19:40 + + Sprite rotation support + + ![](screenshots/4.gif) diff --git a/screenshots/4.gif b/screenshots/4.gif new file mode 100644 index 0000000..19a4788 Binary files /dev/null and b/screenshots/4.gif differ