Ejemplo n.º 1
0
// handle key press events
func handleKeyPress(keysym sdl.Keysym) {
	switch keysym.Sym {
	case sdl.K_f: // f key pages through filters
		filter = (filter + 1) % 3
		p("new filter:", filter)
	case sdl.K_l: // l key toggles light
		light = !light
		if light {
			p("light on")
			gl.Enable(gl.LIGHTING)
		} else {
			p("light off")
			gl.Disable(gl.LIGHTING)
		}
	case sdl.K_PAGEUP: // page up zooms into the scene
		z -= 0.02
	case sdl.K_PAGEDOWN: // zoom out of the scene
		z += 0.02
	case sdl.K_UP: // up arrow affects x rotation
		xspeed -= 0.01
	case sdl.K_DOWN: // down arrow affects x rotation
		xspeed += 0.01
	case sdl.K_RIGHT: // affect y rotation
		yspeed += 0.01
	case sdl.K_LEFT: // affect y rotation
		yspeed -= 0.01
	case sdl.K_ESCAPE:
		Quit(0)
	case sdl.K_F1:
		sdl.WM_ToggleFullScreen(surface)
	}
}
Ejemplo n.º 2
0
// handle key press events
func handleKeyPress(keysym sdl.Keysym) {
	switch keysym.Sym {
	case sdl.K_ESCAPE:
		Quit(0)
	case sdl.K_F1:
		sdl.WM_ToggleFullScreen(surface)
	}
}
Ejemplo n.º 3
0
// handle key press events
func handleKeyPress(keysym sdl.Keysym) {
	keys := sdl.GetKeyState()

	if keys[sdl.K_ESCAPE] == 1 {
		Quit(0)
	}

	if keys[sdl.K_F1] == 1 {
		sdl.WM_ToggleFullScreen(surface)
	}

	if keys[sdl.K_f] == 1 {
		filter = (filter + 1) % 3
	}

	if keys[sdl.K_RIGHT] == 1 {
		yrot -= 1.5
	}

	if keys[sdl.K_LEFT] == 1 {
		yrot += 1.5
	}

	if keys[sdl.K_UP] == 1 {
		xpos -= math.Sin(yrot*PiOver100) * 0.05
		zpos -= math.Cos(yrot*PiOver100) * 0.05
		if walkbiasangle >= 359.0 {
			walkbiasangle = 0.0
		} else {
			walkbiasangle += 10.0
		}
		walkbias = math.Sin(walkbiasangle*PiOver100) / 20.0
	}

	if keys[sdl.K_DOWN] == 1 {
		xpos += math.Sin(yrot*PiOver100) * 0.05
		zpos += math.Cos(yrot*PiOver100) * 0.05
		if walkbiasangle <= 1.0 {
			walkbiasangle = 359.0
		} else {
			walkbiasangle -= 10.0
		}
		walkbias = math.Sin(walkbiasangle*PiOver100) / 20.0
	}
}
Ejemplo n.º 4
0
// handle key press events
func handleKeyPress(keysym sdl.Keysym) {
	switch keysym.Sym {
	case sdl.K_t:
		twinkle = !twinkle
	case sdl.K_UP:
		tilt -= 0.5
	case sdl.K_DOWN:
		tilt += 0.5
	case sdl.K_PAGEUP:
		zoom -= 0.2
	case sdl.K_PAGEDOWN:
		zoom += 0.2
	case sdl.K_ESCAPE:
		Quit(0)
	case sdl.K_F1:
		sdl.WM_ToggleFullScreen(surface)
	}
}