diff --git a/.gitignore b/.gitignore index 49c6010..a909d61 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /src /pkg +/bin tags +*.pxm diff --git a/ld48-29.go b/ld48-29.go index b2f83e5..78ba44d 100644 --- a/ld48-29.go +++ b/ld48-29.go @@ -160,12 +160,13 @@ func scaledSpriteQuad(x int, y int, w int, h int, scale float32) { gl.End() } -func drawSprite(texture gl.Texture, x float64, y float64, a float64, list uint) { +func drawSprite(texture gl.Texture, x float64, y float64, a float64, s 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.Scalef(float32(s), float32(s), 1.0) gl.CallList(list) } @@ -255,7 +256,7 @@ func setup() (textures map[string]gl.Texture, lists map[string]uint) { gl.Enable(gl.CULL_FACE) gl.Enable(gl.BLEND) - gl.ClearColor(0.0, 0.0, 0.5, 0) + gl.ClearColor(0.4, 0.8, 0.95, 0) gl.ClearDepth(1) gl.DepthFunc(gl.LEQUAL) gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA) @@ -274,7 +275,12 @@ func setup() (textures map[string]gl.Texture, lists map[string]uint) { textures["sprites"] = spriteSheet lists["test"] = makeSprite(0, 0, 2, 2) - lists["cursor"] = makeSprite(2, 0, 1, 1) + lists["cursor"] = makeSprite(4, 0, 1, 1) + lists["cloud"] = makeSprite(0, 2, 3, 2) + lists["stonewall"] = makeSprite(2, 0, 1, 1) + lists["stonewallright"] = makeSprite(3, 0, 1, 1) + lists["stonewalltopright"] = makeSprite(3, 1, 1, 1) + lists["stonewalltop"] = makeSprite(2, 1, 1, 1) return } @@ -301,63 +307,60 @@ func render(textures map[string]gl.Texture, lists map[string]uint) { gl.LoadIdentity() // lighten things - ambient := []float32{0.5, 0.5, 0.5, 1} - diffuse := []float32{1, 1, 1, 1} - lightpos := []float32{-5, 5, 10, 0} + ambient := []float32{1, 1, 1, 1} gl.Lightfv(gl.LIGHT0, gl.AMBIENT, ambient) - gl.Lightfv(gl.LIGHT0, gl.DIFFUSE, diffuse) - gl.Lightfv(gl.LIGHT0, gl.POSITION, lightpos) gl.Enable(gl.LIGHT0) - gl.Disable(gl.TEXTURE_2D) - gl.Disable(gl.LIGHTING) - gl.Begin(gl.TRIANGLES) - gl.Color3f(1.0, 0.0, 0.0) - gl.Vertex3f(0, 0, 0.0) - gl.Color3f(0.0, 1.0, 0.0) - gl.Vertex3f(width, 0, 0.0) - gl.Color3f(0.0, 0.0, 1.0) - gl.Vertex3f(0.0, height, 0.0) - gl.End() - gl.Begin(gl.TRIANGLES) - gl.Color3f(1.0, 0.0, 0.0) - gl.Vertex3f(width, height, 0.0) - gl.Color3f(0.0, 0.0, 1.0) - gl.Vertex3f(0.0, height, 0.0) - gl.Color3f(0.0, 1.0, 0.0) - gl.Vertex3f(width, 0, 0.0) - gl.End() - gl.Enable(gl.TEXTURE_2D) - gl.Enable(gl.LIGHTING) - 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"]) + // clouds t := float64(time.Now().UnixNano()) / math.Pow(10, 9) - 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"]) + fy := 2 * math.Pi * t / 60 + _, f := math.Modf(3*t/1000) + drawSprite(textures["sprites"], math.Mod(f*640, 640), 400+8*math.Sin(fy/1.3), 0, 3.0, lists["cloud"]) - 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"]) + _, f = math.Modf(33*t/1000) + drawSprite(textures["sprites"], math.Mod(f*640+35, 640), 300+4*math.Sin(fy+3), 0, 2.0, lists["cloud"]) - 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"]) + _, f = math.Modf(31*t/1000) + drawSprite(textures["sprites"], math.Mod(f*640+142, 640), 340+3*math.Sin(fy/3+1), 0, 2.5, lists["cloud"]) + + _, f = math.Modf(17*t/1000) + drawSprite(textures["sprites"], math.Mod(f*640+213, 640), 450+7*math.Sin(fy/1.5+2), 0, 1.0, lists["cloud"]) + + _, f = math.Modf(11*t/1000) + drawSprite(textures["sprites"], math.Mod(f*640+317, 640), 400+5*math.Sin(fy/2+1.1), 0, 1.5, lists["cloud"]) + + _, f = math.Modf(27*t/1000) + drawSprite(textures["sprites"], math.Mod(f*640+332, 640), 380+3*math.Sin(fy/4+3.1), 0, 1.5, lists["cloud"]) + + _, f = math.Modf(13*t/1000) + drawSprite(textures["sprites"], math.Mod(f*640+417, 640), 420+5*math.Sin(fy/2.2+2.5), 0, 1.0, lists["cloud"]) + + // wall tiles + + for i:= 0; i < 11; i++ { + drawSprite(textures["sprites"], 3*16+16/2, 16*float64(i)+16/2, 0, 1, lists["stonewallright"]) + } + drawSprite(textures["sprites"], 3*16+16/2, 1*16*float64(11)+16/2, 0, 1, lists["stonewalltopright"]) + + for i:= 0; i < 11; i++ { + drawSprite(textures["sprites"], 2*16+16/2, 16*float64(i)+16/2, 0, 1, lists["stonewall"]) + } + drawSprite(textures["sprites"], 2*16+16/2, 1*16*float64(11)+16/2, 0, 1, lists["stonewalltop"]) + + for i:= 0; i < 11; i++ { + drawSprite(textures["sprites"], 1*16+16/2, 16*float64(i)+16/2, 0, 1, lists["stonewall"]) + } + drawSprite(textures["sprites"], 1*16+16/2, 1*16*float64(11)+16/2, 0, 1, lists["stonewalltop"]) + + for i:= 0; i < 11; i++ { + drawSprite(textures["sprites"], 0*16+16/2, 16*float64(i)+16/2, 0, 1, lists["stonewall"]) + } + drawSprite(textures["sprites"], 0*16+16/2, 1*16*float64(11)+16/2, 0, 1, lists["stonewalltop"]) if mouseVisible { - drawSprite(textures["sprites"], mouseX, mouseY, 0, lists["cursor"]) + drawSprite(textures["sprites"], mouseX, mouseY, 0, 1.0, lists["cursor"]) } } diff --git a/log.mdown b/log.mdown index 08f48d6..72bd4b2 100644 --- a/log.mdown +++ b/log.mdown @@ -117,3 +117,17 @@ All time is CEST - 10:50 A good night sleep is a good call. Sprites are easier to make. + +- 12:09 + + Drawing clouds. This is starting to look like an actual game. + +- 12:10 + + Going back to hotel. + +- 13:55 + + This is vaguely starting to ressemble a form of game. + + ![](screenshots/5.png) diff --git a/screenshots/5.png b/screenshots/5.png new file mode 100644 index 0000000..ab38964 Binary files /dev/null and b/screenshots/5.png differ diff --git a/spritesheet.png b/spritesheet.png index fb43233..8e73ac2 100644 Binary files a/spritesheet.png and b/spritesheet.png differ