Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
scene.add_object("acar1", aabb_car_1)
scene.add_object("acar2", aabb_car_2)
spherical_collision.add_object(spherical_car_1)
spherical_collision.add_object(spherical_car_2)
aabb_collision.add_object(aabb_car_1)
aabb_collision.add_object(aabb_car_2)
scene.add_collision_test("spherical_collision", spherical_collision)
scene.add_collision_test("aabb_collision", aabb_collision)
scene.create_clock("motion", 0.01, motion)
scene.add_object(
"info", info_box(left=10, top=10, width=220, height=100, label="Hit SPACE\nto start animation",),
)
scene.run()
self.ragdoll = RagDoll()
self.state = 1
self.total_ang = 0
self.add_object("ragdoll", self.ragdoll)
self.create_clock("walk", 0.01, self.walk)
self.add_object("ground", Plane(20, 20))
self.target = [5, 0, 2]
self.ragdoll.direct_to([5, 0, 2])
self.ragdoll.joints[R_SHOULDER].rotate_around_y(math.radians(50))
self.ragdoll.joints[L_SHOULDER].rotate_around_y(math.radians(-50))
self.ragdoll.joints[R_KNEE].rotate_around_x(math.radians(-20))
self.ragdoll.joints[L_KNEE].rotate_around_x(math.radians(-20))
self.add_object(
"info", info_box(left=10, top=10, width=220, height=100, label="Hit SPACE\nto start animation",),
)
minutes = 0
def change_background(period, total):
global minutes
h = int(minutes / 60) % 24
m = minutes % 60
scene.background.set_time(h, m)
minutes += 10
scene = Scene()
scene.create_clock("sun", 0.1, change_background)
scene.add_object(
"info", info_box(left=10, top=10, width=220, height=100, label="Hit SPACE\nto start animation",),
)
scene.run()
def step_back_history(period, total):
success = scene.objects["cube"].step_back()
if not success:
scene.clocks["back"].pause()
cube = Cube()
cube.track_motion = True
scene.add_object("cube", cube)
scene.create_clock("forward", 0.2, move_forward)
scene.create_clock("back", 0.2, step_back_history)
scene.add_object(
"info", info_box(left=10, top=10, width=220, height=100, label="Hit SPACE\nto start animation",),
)
scene.run()
for i in range(20):
x = random.randint(-1000, 1000) / 100
y = random.randint(-1000, 1000) / 100
z = random.randint(-1000, 1000) / 100
self.line.append(vertices=[[x, y, z]])
v = normalize_vector([x, y, z])
if random.randint(0, 1) == 1:
v = scale_vector(v, -1)
self.vertex_velocities.append(v)
self.add_object("line", self.line)
self.create_clock("clock", 0.01, self.animate)
self.background.top_color = BLACK
self.background.bottom_color = BLACK
self.add_object(
"info", info_box(left=10, top=10, width=220, height=100, label="Hit SPACE\nto start animation",),
)
def keyboard(self, event, scene):
super().keyboard(event, scene)
if event.type == sdl2.SDL_KEYUP:
key = event.key.keysym.sym
if key == sdl2.SDLK_UP:
model.animate("walk", 0, 52)
if key == sdl2.SDLK_DOWN:
model.animate("death", 0, 76, False)
label = """
Hit Keyboard UP to walk
Hit Keyboard Down to death animation
"""
scene.add_object("info", info_box(left=10, top=10, width=320, height=100, label=label))
scene.add_object("ground", ground)
scene.add_object("infantry", model)
scene.controller = CustomKeyboardControls()
model.bake_animation("walk", 2, 14, 3)
model.bake_animation("death", 0, 19, 3)
print(model.animations)
model.animate("walk", 0, 52)
scene.run()
def __init__(self, **kwargs):
super().__init__(**kwargs)
cube = Cube()
self.add_object("cube", cube)
self.create_clock("rotator", 0.01, self.timer)
self.add_object(
"info", info_box(left=10, top=10, width=220, height=100, label="Hit SPACE\nto start animation",),
)
ball = Sphere(radius=1, track_motion=True)
# Add ball to the scene
scene.add_object("ball", ball)
scene.active_observer.target_object = ball # Track the ball
scene.grid.resize(30, 30, 2)
ground = Plane(80, 80)
scene.add_object("gr", ground)
scene.create_clock("motion", 0.005, projectile_motion)
scene.create_clock("logger", 0.05, logger)
scene.add_object(
"info", info_box(left=10, top=10, width=220, height=100, label="Hit SPACE\nto start animation",),
)
scene.run()
# Re-use the existing objects
global score_board
for obj in list:
x = random.randint(-5, 5)
y = random.randint(-5, 5)
z = random.randint(10, 20)
obj.position = [x, y, z]
score_board += 1
game.create_clock("move-balloons", 0.02, move_balloons)
game.on_select = select
create_balloons()
game.add_object(
"info", info_box(left=10, top=10, width=220, height=100, label="Hit SPACE to\nstart popping!",),
)
game.run()
earth = Sphere(radius=5, parallels=36, meridians=36)
earth.material.texture = texture_file
moon = Sphere()
moon.position = [8, 0, 0]
moon_moon = Sphere(radius=0.5)
moon_moon.position = [0, 2, 0]
earth.add_child("moon", moon)
moon.add_child("moon_moon", moon_moon)
space.add_object("earth", earth)
space.create_clock("motion", 0.01, motion)
space.add_object(
"info", info_box(left=10, top=10, width=220, height=100, label="Hit SPACE\nto start animation",),
)
space.run()