Beispiel #1
0
func initCamera(screen *window.Screen) func() {
	cam1 := camera.New(true)
	cam1.SetOrtho(screen.Width, screen.Height, 200)
	cam1.SetPosition2D(0, 0)
	camx := 0.0
	camy := 0.0
	speed := 300.0
	return func() {
		if window.GetKeyState(window.KeyA) == window.KeyStatePressed {
			camx -= screen.AmountPerSecond(speed)
		}
		if window.GetKeyState(window.KeyD) == window.KeyStatePressed {
			camx += screen.AmountPerSecond(speed)
		}
		if window.GetKeyState(window.KeyW) == window.KeyStatePressed {
			camy -= screen.AmountPerSecond(speed)
		}
		if window.GetKeyState(window.KeyS) == window.KeyStatePressed {
			camy += screen.AmountPerSecond(speed)
		}
		cam1.SetPosition2D(float32(camx), float32(camy))
	}
}