From d5f7088b7dd51e68b1e5edd84ef5d2fe3657b9bb Mon Sep 17 00:00:00 2001
From: faiface <faiface@ksp.sk>
Date: Fri, 26 May 2017 14:04:44 +0200
Subject: [PATCH] update 05 guide code

---
 .../05_drawing_efficiently_with_batch/main.go | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/examples/guide/05_drawing_efficiently_with_batch/main.go b/examples/guide/05_drawing_efficiently_with_batch/main.go
index 80ba261..3cb596f 100644
--- a/examples/guide/05_drawing_efficiently_with_batch/main.go
+++ b/examples/guide/05_drawing_efficiently_with_batch/main.go
@@ -46,8 +46,8 @@ func run() {
 	batch := pixel.NewBatch(&pixel.TrianglesData{}, spritesheet)
 
 	var treesFrames []pixel.Rect
-	for x := spritesheet.Bounds().Min.X(); x < spritesheet.Bounds().Max.X(); x += 32 {
-		for y := spritesheet.Bounds().Min.Y(); y < spritesheet.Bounds().Max.Y(); y += 32 {
+	for x := spritesheet.Bounds().Min.X; x < spritesheet.Bounds().Max.X; x += 32 {
+		for y := spritesheet.Bounds().Min.Y; y < spritesheet.Bounds().Max.Y; y += 32 {
 			treesFrames = append(treesFrames, pixel.R(x, y, x+32, y+32))
 		}
 	}
@@ -69,28 +69,27 @@ func run() {
 		dt := time.Since(last).Seconds()
 		last = time.Now()
 
-		cam := pixel.IM.Scaled(camPos, camZoom).Moved(win.Bounds().Center() - camPos)
+		cam := pixel.IM.Scaled(camPos, camZoom).Moved(win.Bounds().Center().Sub(camPos))
 		win.SetMatrix(cam)
 
 		if win.Pressed(pixelgl.MouseButtonLeft) {
 			tree := pixel.NewSprite(spritesheet, treesFrames[rand.Intn(len(treesFrames))])
 			mouse := cam.Unproject(win.MousePosition())
-			tree.SetMatrix(pixel.IM.Scaled(0, 4).Moved(mouse))
-			tree.Draw(batch)
+			tree.Draw(batch, pixel.IM.Scaled(pixel.ZV, 4).Moved(mouse))
 		}
 		if win.Pressed(pixelgl.KeyLeft) {
-			camPos -= pixel.X(camSpeed * dt)
+			camPos.X -= camSpeed * dt
 		}
 		if win.Pressed(pixelgl.KeyRight) {
-			camPos += pixel.X(camSpeed * dt)
+			camPos.X += camSpeed * dt
 		}
 		if win.Pressed(pixelgl.KeyDown) {
-			camPos -= pixel.Y(camSpeed * dt)
+			camPos.Y -= camSpeed * dt
 		}
 		if win.Pressed(pixelgl.KeyUp) {
-			camPos += pixel.Y(camSpeed * dt)
+			camPos.Y += camSpeed * dt
 		}
-		camZoom *= math.Pow(camZoomSpeed, win.MouseScroll().Y())
+		camZoom *= math.Pow(camZoomSpeed, win.MouseScroll().Y)
 
 		win.Clear(colornames.Forestgreen)
 		batch.Draw(win)
-- 
GitLab