Ejemplo n.º 1
0
/*
Binds each key to an action
*/
func takeKeyAction(key int, action int) {

	if action == glfw.KeyPress {

		switch {
		// WASD change the camera postion by movespeed
		case w == key:
			camera.Y += movespeed
			camera.PositionCamera(camera.X, camera.Y, 640, 480)
		case a == key:
			camera.X -= movespeed
			camera.PositionCamera(camera.X, camera.Y, 640, 480)
		case s == key:
			camera.Y -= movespeed
			camera.PositionCamera(camera.X, camera.Y, 640, 480)
		case d == key:
			camera.X += movespeed
			camera.PositionCamera(camera.X, camera.Y, 640, 480)
			// reimpliment once finished remodeling the universe.systems
			/*		case h == key:
					camera.CameraToObj(universe.Systems[0].Planets[0])
			*/

		}

	}
}
Ejemplo n.º 2
0
func GameLoop() {

	t := 0.0
	dt := 0.1

	CreateUniverse()

	camera.PositionCamera(0, 0, 1000, 900)

	for glfw.WindowParam(glfw.Opened) == 1 {

		t += dt

		gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
		gl.Clear(gl.DEPTH_BUFFER_BIT | gl.LIGHTING_BIT)

		for i := range universe.Systems {
			for j := range universe.Systems[i].Planets {
				BufferPlanet(universe.Systems[i].Planets[j])
				ai.PlanetOrbit(universe.Systems[i].Planets[j], t)
			}
			for j := range universe.Systems[i].Stars {
				BufferStar(universe.Systems[i].Stars[j])
				ai.StarStationary(universe.Systems[i].Stars[j], t)
			}
		}

		glfw.SwapBuffers()
	}
}