def setup_scenario_2(): # walls # scene.add_physic_cube(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(tile_quantizer(md_screen_h * -0.2), -md_screen_h * 0.5,0),gs.Vector3(0,0,0)), # width=sphere_radius * 2.0, height=sphere_radius * 12.0, depth=sphere_radius, mass=0.0) # scene.add_physic_cube(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(tile_quantizer(md_screen_h * 0.2), -md_screen_h * 0.5,0),gs.Vector3(0,0,0)), # width=sphere_radius * 2.0, height=sphere_radius * 12.0, depth=sphere_radius, mass=0.0) scene.add_physic_cube(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(tile_quantizer(md_screen_h * -0.4), -md_screen_h * 0.5,0),gs.Vector3(0,0,0)), width=sphere_radius * 2.0, height=sphere_radius * 8, depth=sphere_radius, mass=0.0) scene.add_physic_cube(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(tile_quantizer(md_screen_h * 0.4), -md_screen_h * 0.5,0),gs.Vector3(0,0,0)), width=sphere_radius * 2.0, height=sphere_radius * 8, depth=sphere_radius, mass=0.0) scene.add_physic_sphere(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(0,-md_screen_h * 0.25,0),gs.Vector3(0,0,0)), radius=sphere_radius * 4.0, mass=0.0) scene.add_physic_cube(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(tile_quantizer(md_screen_w * -0.48), -md_screen_h * 0.5,0),gs.Vector3(0,0,0)), width=sphere_radius * 2.0, height=sphere_radius * 16.0, depth=sphere_radius, mass=0.0) scene.add_physic_cube(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(tile_quantizer(md_screen_w * 0.48), -md_screen_h * 0.5,0),gs.Vector3(0,0,0)), width=sphere_radius * 2.0, height=sphere_radius * 16.0, depth=sphere_radius, mass=0.0)
def throw_bullet(size=1.0, mass=1.0, type='sphere', spread_angle=1.0, spread_pos=1.0): world = gs.Matrix4.TransformationMatrix(make_solid_pos(uniform(md_screen_w * -0.01 * size * spread_pos, md_screen_w * 0.01 * size * spread_pos), md_screen_h / 2 + (sphere_radius * size)), gs.Vector3()) if type.find('sphere') > -1: new_bullet, rigid_body = scene.add_physic_sphere(scn, world, sphere_radius * size, mass=mass) elif type.find('cube') > -1: new_bullet, rigid_body = scene.add_physic_cube(scn, world, sphere_radius * size * 1.6, sphere_radius * size * 1.6, sphere_radius * size * 1.6, mass=mass) if type.find('elastic') > -1: rigid_body.SetRestitution(1.15) ejection_vector = world.GetY() + gs.Vector3(uniform(-1.0, 1.0), uniform(0.0, 1.0), 0.0) * spread_angle rigid_body.ApplyLinearImpulse(ejection_vector * (-50 / scale_factor)) new_bullet.SetName('type;' + type + ';size;' + str(int(size)) + ';mass;' + str(int(mass)))