2
from pygame.locals import *
4
from OpenGL.GL import (
5
GL_DEPTH_TEST, glEnable, glTranslate)
6
from OpenGL.GLU import gluPerspective, gluLookAt
13
pygame.display.set_mode(
14
(1024, 768), pygame.locals.OPENGL | pygame.locals.DOUBLEBUF)
16
glEnable(GL_DEPTH_TEST)
17
gluPerspective(60.0, 640.0 / 480.0, 0.5, 1000.0)
18
glTranslate(0, -15, -60)
22
terrain = pal.body.StaticBox((0,0,0,60,1,60))
23
sbox = pal.body.StaticBox((0,10,0,1.,1.,1.))
24
sbox1 = pal.body.StaticBox((10,10,0,1.,1.,1.))
25
box1 = pal.body.Box((-10,5,0,1,1,1),mass=10)
26
ssphere = pal.body.StaticSphere((-10,10,0,1))
27
sphere = pal.body.Sphere((5,10,0,1),mass=1)
29
objects.append(glh.Box(terrain,(0,0,255)))
30
objects.append(glh.Box(sbox, (255, 0, 0)))
31
objects.append(glh.Box(sbox1, (0, 255, 0)))
32
objects.append(glh.Ball(sphere, (0, 255, 255)))
33
objects.append(glh.Box(box1, (255, 255, 0)))
34
objects.append(glh.Ball(ssphere, (255, 0, 255)))
36
#prismatic = pal.link.Prismatic(sbox,sphere,sbox.get_position(),(1,0,0),False)
37
#prismatic.set_limits(0,20)
38
#revolute = pal.link.Spherical(sbox1,box,sbox1.get_position(),False)
40
#rigid = pal.link.Rigid(box,sphere.body,False)
44
gluLookAt(5,5,5,0,0,0,0,1,0)
49
events = pygame.event.get()
51
if event.type == QUIT:
53
elif event.type == KEYDOWN:
54
if event.key == K_SPACE:
56
elif event.key == K_RIGHT:
57
control.set_active(True)
58
control.apply_impulse((75,0,0))
59
elif event.key == K_LEFT:
60
control.set_active(True)
61
control.apply_impulse((-75,0,0))
62
elif event.key == K_UP:
63
control.set_active(True)
64
control.apply_impulse((0,75,0))
65
elif event.key == K_DOWN:
66
control.set_active(True)
67
control.apply_impulse((0,-75,0))
68
elif event.key == K_d:
69
control.set_active(True)
70
control.apply_impulse((75,0,0))
71
elif event.key == K_a:
72
control.set_active(True)
73
control.apply_impulse((-75,0,0))
74
elif event.key == K_s:
75
control.set_active(True)
76
control.apply_impulse((0,0,75))
77
elif event.key == K_w:
78
control.set_active(True)
79
control.apply_impulse((0,0,-75))