from common import cube, gl_init if __name__ == '__main__': window = Window(fullscreen=True, vsync=False) gl_init() fps = ClockDisplay() description = Label( 'cursor keys for movement, delete/page down/home/end for rotate', anchor_x='center', x=window.width / 2, y=10, bold=True, color=(255, 255, 255, 255)) world = World() world.gravity = 0, 0, 0 box = world.add_box_body(position=(0, 0, 0), size=(10, 10, 10), mass=5) box.disable_deactivation() @window.event def on_draw(): window.clear() with nested(Projection(0, 0, window.width, window.height, far=1000.0), Matrix, Lighting): glTranslatef(0, 0, -40) with Matrix: glMultMatrixf(box.matrix) cube(size=(10, 10, 10), color=(0.5, 0.5, 0.5, 1.0))
if __name__ == '__main__': window = Window(fullscreen=True, vsync=False) gl_init() fps = ClockDisplay() description = Label('mouse drag to rotate', anchor_x='center', x=window.width/2, y=10, bold=True, color=(255,255,255,255)) tilt = 0 rotate = 0 @window.event def on_mouse_drag(x, y, dx, dy, button, modifiers): global rotate, tilt rotate += dx tilt += dy world = World() world.gravity = 0, 0, 0 randpos = lambda size: [random() * size - size/2 for _ in range(3)] bodies = [] for _ in range(30): position = randpos(200) size = random() * 5 + 1 mass = size**3 body = world.add_box_body(position=position, size=[size]*3, mass=mass) body.disable_deactivation() body.add_impulse(linear=randpos(20*mass)) bodies.append(body) @window.event def on_draw():
description = Label('mouse drag to rotate', anchor_x='center', x=window.width / 2, y=10, bold=True, color=(255, 255, 255, 255)) tilt = 0 rotate = 0 @window.event def on_mouse_drag(x, y, dx, dy, button, modifiers): global rotate, tilt rotate += dx tilt += dy world = World() world.gravity = 0, 0, 0 randpos = lambda size: [random() * size - size / 2 for _ in range(3)] bodies = [] for _ in range(30): position = randpos(200) size = random() * 5 + 1 mass = size**3 body = world.add_box_body(position=position, size=[size] * 3, mass=mass) body.disable_deactivation() body.add_impulse(linear=randpos(20 * mass)) bodies.append(body)
def draw(self): with Matrix: glMultMatrixf(self.body.matrix) self.display.draw(GL_TRIANGLES) if __name__ == '__main__': window = Window(fullscreen=True, vsync=False) gl_init() fps = ClockDisplay() description = Label('mouse drag to rotate, space to create more cubes', anchor_x='center', x=window.width/2, y=10, bold=True, color=(255,255,255,255)) tilt = 0 rotate = 0 world = World() world.gravity = 0, -10, 0 ground_size = (50, 25, 50) box_size = (2,2,2) bunny = Bunny(world) ground = world.add_box_body(position=(0,-56,0), size=ground_size) boxes = list() def add_box(): x = random() * 10 - 5 z = random() * 10 - 5 boxes.append( world.add_box_body(position=(x,10,z), size=box_size, mass=5)
from pyglet.gl import * from pyglet.text import Label from bullet import World from common import cube, gl_init if __name__ == '__main__': window = Window(fullscreen=True, vsync=False) gl_init() fps = ClockDisplay() description = Label('mouse drag to rotate, space to create more cubes', anchor_x='center', x=window.width/2, y=10, bold=True, color=(255,255,255,255)) tilt = 0 rotate = 0 world = World() world.gravity = 0, -10, 0 ground_size = (25, 25, 25) box_size = (2,2,2) ground = world.add_box_body(position=(0,-56,0), size=ground_size) boxes = list() def add_box(): x = random() * 4 - 2 z = random() * 4 - 2 boxes.append( world.add_box_body(position=(x,10,z), size=box_size, mass=5) ) add_box()
from pyglet.clock import schedule_interval, ClockDisplay from pyglet.gl import * from pyglet.text import Label from bullet import World from common import cube, gl_init if __name__ == '__main__': window = Window(fullscreen=True, vsync=False) gl_init() fps = ClockDisplay() description = Label('cursor keys for movement, delete/page down/home/end for rotate', anchor_x='center', x=window.width/2, y=10, bold=True, color=(255,255,255,255)) world = World() world.gravity = 0, 0, 0 box = world.add_box_body(position=(0,0,0), size=(10,10,10), mass=5) box.disable_deactivation() @window.event def on_draw(): window.clear() with nested(Projection(0, 0, window.width, window.height, far=1000.0), Matrix, Lighting): glTranslatef(0, 0, -40) with Matrix: glMultMatrixf(box.matrix) cube(size=(10,10,10), color=(0.5, 0.5, 0.5, 1.0))