diff --git a/physics/box2d_distance_joint/all.texture_profiles b/physics/box2d_distance_joint/all.texture_profiles new file mode 100644 index 00000000..5b0d7762 --- /dev/null +++ b/physics/box2d_distance_joint/all.texture_profiles @@ -0,0 +1,18 @@ +path_settings { + path: "**" + profile: "Default" +} +profiles { + name: "Default" + platforms { + os: OS_ID_GENERIC + formats { + format: TEXTURE_FORMAT_RGBA + compression_level: BEST + compression_type: COMPRESSION_TYPE_DEFAULT + } + mipmaps: false + max_texture_size: 0 + premultiply_alpha: true + } +} diff --git a/physics/box2d_distance_joint/box2d_v2.appmanifest b/physics/box2d_distance_joint/box2d_v2.appmanifest new file mode 100644 index 00000000..b3abe8c8 --- /dev/null +++ b/physics/box2d_distance_joint/box2d_v2.appmanifest @@ -0,0 +1,95 @@ +platforms: + arm64-ios: + context: + excludeLibs: [] + excludeSymbols: [] + symbols: [] + libs: [] + frameworks: [] + linkFlags: [] + x86_64-ios: + context: + excludeLibs: [] + excludeSymbols: [] + symbols: [] + libs: [] + frameworks: [] + linkFlags: [] + armv7-android: + context: + excludeLibs: [] + excludeJars: [] + excludeSymbols: [] + symbols: [] + libs: [] + linkFlags: [] + jetifier: true + arm64-android: + context: + excludeLibs: [] + excludeJars: [] + excludeSymbols: [] + symbols: [] + libs: [] + linkFlags: [] + jetifier: true + arm64-osx: + context: + excludeLibs: [] + excludeSymbols: [] + symbols: [] + libs: [] + frameworks: [] + linkFlags: [] + x86_64-osx: + context: + excludeLibs: [] + excludeSymbols: [] + symbols: [] + libs: [] + frameworks: [] + linkFlags: [] + x86_64-linux: + context: + excludeLibs: [] + excludeSymbols: [] + symbols: [] + libs: [] + linkFlags: [] + arm64-linux: + context: + excludeLibs: [] + excludeSymbols: [] + symbols: [] + libs: [] + linkFlags: [] + x86-win32: + context: + excludeLibs: [] + excludeSymbols: [] + symbols: [] + libs: [] + linkFlags: [] + x86_64-win32: + context: + excludeLibs: [] + excludeSymbols: [] + symbols: [] + libs: [] + linkFlags: [] + wasm-web: + context: + excludeLibs: [] + excludeJsLibs: [] + excludeSymbols: [] + symbols: [] + libs: [] + linkFlags: [] + wasm_pthread-web: + context: + excludeLibs: [] + excludeJsLibs: [] + excludeSymbols: [] + symbols: [] + libs: [] + linkFlags: [] diff --git a/physics/box2d_distance_joint/box2d_v3.appmanifest b/physics/box2d_distance_joint/box2d_v3.appmanifest new file mode 100644 index 00000000..9751deca --- /dev/null +++ b/physics/box2d_distance_joint/box2d_v3.appmanifest @@ -0,0 +1,100 @@ +platforms: + armv7-ios: + context: + excludeLibs: [physics, box2d_defold, script_box2d_defold] + excludeSymbols: [] + libs: [physics_2d, box2d, script_box2d, physics_3d] + arm64-ios: + context: + excludeLibs: [physics, box2d_defold, script_box2d_defold] + excludeSymbols: [] + symbols: [] + libs: [physics_2d, box2d, script_box2d, physics_3d] + frameworks: [] + linkFlags: [] + x86_64-ios: + context: + excludeLibs: [physics, box2d_defold, script_box2d_defold] + excludeSymbols: [] + symbols: [] + libs: [physics_2d, box2d, script_box2d, physics_3d] + frameworks: [] + linkFlags: [] + armv7-android: + context: + excludeLibs: [physics, box2d_defold, script_box2d_defold] + excludeJars: [] + excludeSymbols: [] + symbols: [] + libs: [physics_2d, box2d, script_box2d, physics_3d] + linkFlags: [] + jetifier: true + arm64-android: + context: + excludeLibs: [physics, box2d_defold, script_box2d_defold] + excludeJars: [] + excludeSymbols: [] + symbols: [] + libs: [physics_2d, box2d, script_box2d, physics_3d] + linkFlags: [] + jetifier: true + arm64-osx: + context: + excludeLibs: [physics, box2d_defold, script_box2d_defold] + excludeSymbols: [] + symbols: [] + libs: [physics_2d, box2d, script_box2d, physics_3d] + frameworks: [] + linkFlags: [] + x86_64-osx: + context: + excludeLibs: [physics, box2d_defold, script_box2d_defold] + excludeSymbols: [] + symbols: [] + libs: [physics_2d, box2d, script_box2d, physics_3d] + frameworks: [] + linkFlags: [] + x86_64-linux: + context: + excludeLibs: [physics, box2d_defold, script_box2d_defold] + excludeSymbols: [] + symbols: [] + libs: [physics_2d, box2d, script_box2d, physics_3d] + linkFlags: [] + arm64-linux: + context: + excludeLibs: [physics, box2d_defold, script_box2d_defold] + excludeSymbols: [] + symbols: [] + libs: [physics_2d, box2d, script_box2d, physics_3d] + linkFlags: [] + x86-win32: + context: + excludeLibs: [libphysics, libbox2d_defold, script_box2d_defold] + excludeSymbols: [] + symbols: [] + libs: [libphysics_2d.lib, libbox2d.lib, libscript_box2d.lib, libphysics_3d.lib] + linkFlags: [] + x86_64-win32: + context: + excludeLibs: [libphysics, libbox2d_defold, script_box2d_defold] + excludeSymbols: [] + symbols: [] + libs: [libphysics_2d.lib, libbox2d.lib, libscript_box2d.lib, libphysics_3d.lib] + linkFlags: [] + wasm-web: + context: + excludeLibs: [physics, box2d_defold, script_box2d_defold] + excludeJsLibs: [] + excludeSymbols: [] + symbols: [] + libs: [physics_2d, box2d, script_box2d, physics_3d] + linkFlags: [] + wasm_pthread-web: + context: + excludeLibs: [physics, box2d_defold, script_box2d_defold] + excludeJsLibs: [] + excludeSymbols: [] + symbols: [] + libs: [physics_2d, box2d, script_box2d, physics_3d] + linkFlags: [] diff --git a/physics/box2d_distance_joint/example.md b/physics/box2d_distance_joint/example.md new file mode 100644 index 00000000..b8ec226f --- /dev/null +++ b/physics/box2d_distance_joint/example.md @@ -0,0 +1,58 @@ +--- +tags: physics, box2d +title: Box2D Distance Joint +brief: Compare a rigid distance joint with the same joint configured as a damped spring. +author_ids: + - defold-foundation +scripts: box2d_distance_joint.script +thumbnail: thumbnail.webp +--- + +A distance joint keeps two body anchor points at a specified distance. It can also behave like a damped spring when spring behavior, hertz, and damping ratio are configured. + +This example suspends two platforms from pairs of distance joints. Identical balls drop onto both at the same time: the rigid platform preserves both joint lengths, while the spring platform stretches, rebounds, oscillates, and settles. + +The balls are dropped automatically every 5.5 seconds. + +## What You'll Learn + +- How to create distance joints with `b2d.joint.create_distance()` +- How local anchors connect a platform at two distinct attachment points +- How `enable_spring`, `hertz`, and `damping_ratio` configure rigid and spring behavior +- How to read current world-space joint anchors for visualization +- How to reset existing physics bodies for a repeated demonstration +- How to repeat an action with `timer.delay()` + +## Setup + +The collection contains two arrangements separated by a static wall divider: + +`rigid_left_anchor`, `rigid_right_anchor`, and `rigid_platform` +: Two static supports and one dynamic platform connected by rigid distance joints. + +`spring_left_anchor`, `spring_right_anchor`, and `spring_platform` +: An identical arrangement whose distance joints use a spring frequency of 1.35 Hz and a damping ratio of 0.25. + +`rigid_ball` and `spring_ball` +: Identical dynamic balls that are reset at the same height to drop on the platforms in the scene. + +`controller` +: Contains the shared script and the labels with information, like title, hint, `RIGID`, and `SPRING`. + +`wall` +: A static vertical divider between the two arrangements. + +![setup](setup.png) + +The `game.project` of this example is configured to build with `/box2d_v3.appmanifest` by default. +To test V2 locally after downloading the example, change `Native Extensions -> App Manifest` in `game.project` to `/box2d_v2.appmanifest`. + +## How It Works + +Each platform is connected at two points near its ends. A distance joint constrains only the separation between its two anchors, so the platform remains free to swing, tilt, and rotate. This differs from a revolute joint, which brings two local anchors together at one shared hinge point while allowing relative rotation. + +For the rigid setup, both joints have a fixed length and spring behavior is disabled. The upper anchors are closer together than the platform attachment points, which lets an off-center impact visibly couple sideways swing with platform rotation. For the spring setup, the same length is used as the spring rest length, with a given frequency and a damping ratio. Hertz controls how quickly the spring responds and therefore how stiff it feels. Damping ratio controls how quickly oscillation is removed. + +Every frame, the script calls `b2d.joint.get_anchor_a()` and `b2d.joint.get_anchor_b()` and draws a line between those current world-space positions. The lower endpoints therefore stay attached to the correct points as each platform moves and rotates. + +The same two authored ball bodies are moved back above the platforms every few seconds by a repeating `timer.delay()`. Their linear and angular motion is reset, so the comparison repeats without factories or accumulating objects. diff --git a/physics/box2d_distance_joint/example/anchor.go b/physics/box2d_distance_joint/example/anchor.go new file mode 100644 index 00000000..cf69d69e --- /dev/null +++ b/physics/box2d_distance_joint/example/anchor.go @@ -0,0 +1,41 @@ +embedded_components { + id: "sprite" + type: "sprite" + data: "default_animation: \"pixel_gold\"\n" + "material: \"/builtins/materials/sprite.material\"\n" + "size {\n" + " x: 24.0\n" + " y: 24.0\n" + "}\n" + "size_mode: SIZE_MODE_MANUAL\n" + "textures {\n" + " sampler: \"texture_sampler\"\n" + " texture: \"/textures/textures.atlas\"\n" + "}\n" + "" +} +embedded_components { + id: "collisionobject" + type: "collisionobject" + data: "type: COLLISION_OBJECT_TYPE_STATIC\n" + "mass: 0.0\n" + "friction: 0.5\n" + "restitution: 0.0\n" + "group: \"default\"\n" + "mask: \"default\"\n" + "embedded_collision_shape {\n" + " shapes {\n" + " shape_type: TYPE_BOX\n" + " position {\n" + " }\n" + " rotation {\n" + " }\n" + " index: 0\n" + " count: 3\n" + " }\n" + " data: 12.0\n" + " data: 12.0\n" + " data: 10.0\n" + "}\n" + "" +} diff --git a/physics/box2d_distance_joint/example/ball.go b/physics/box2d_distance_joint/example/ball.go new file mode 100644 index 00000000..7c3dbe27 --- /dev/null +++ b/physics/box2d_distance_joint/example/ball.go @@ -0,0 +1,39 @@ +embedded_components { + id: "sprite" + type: "sprite" + data: "default_animation: \"ball\"\n" + "material: \"/builtins/materials/sprite.material\"\n" + "size {\n" + " x: 64.0\n" + " y: 64.0\n" + "}\n" + "size_mode: SIZE_MODE_MANUAL\n" + "textures {\n" + " sampler: \"texture_sampler\"\n" + " texture: \"/textures/textures.atlas\"\n" + "}\n" + "" +} +embedded_components { + id: "collisionobject" + type: "collisionobject" + data: "type: COLLISION_OBJECT_TYPE_DYNAMIC\n" + "mass: 2.0\n" + "friction: 0.5\n" + "restitution: 0.15\n" + "group: \"default\"\n" + "mask: \"default\"\n" + "embedded_collision_shape {\n" + " shapes {\n" + " shape_type: TYPE_SPHERE\n" + " position {\n" + " }\n" + " rotation {\n" + " }\n" + " index: 0\n" + " count: 1\n" + " }\n" + " data: 32.0\n" + "}\n" + "" +} diff --git a/physics/box2d_distance_joint/example/box2d_distance_joint.collection b/physics/box2d_distance_joint/example/box2d_distance_joint.collection new file mode 100644 index 00000000..fd284e56 --- /dev/null +++ b/physics/box2d_distance_joint/example/box2d_distance_joint.collection @@ -0,0 +1,178 @@ +name: "box2d_distance_joint" +instances { + id: "rigid_left_anchor" + prototype: "/example/anchor.go" + position { + x: 125.0 + y: 455.0 + } +} +instances { + id: "rigid_right_anchor" + prototype: "/example/anchor.go" + position { + x: 225.0 + y: 455.0 + } +} +instances { + id: "spring_left_anchor" + prototype: "/example/anchor.go" + position { + x: 500.0 + y: 455.0 + } +} +instances { + id: "spring_right_anchor" + prototype: "/example/anchor.go" + position { + x: 600.0 + y: 455.0 + } +} +instances { + id: "rigid_platform" + prototype: "/example/platform.go" + position { + x: 175.0 + y: 220.0 + } +} +instances { + id: "spring_platform" + prototype: "/example/platform.go" + position { + x: 550.0 + y: 220.0 + } +} +instances { + id: "rigid_ball" + prototype: "/example/ball.go" + position { + x: 130.0 + y: 400.0 + } +} +instances { + id: "spring_ball" + prototype: "/example/ball.go" + position { + x: 505.0 + y: 400.0 + } +} +scale_along_z: 0 +embedded_instances { + id: "controller" + data: "components {\n" + " id: \"script\"\n" + " component: \"/example/box2d_distance_joint.script\"\n" + "}\n" + "embedded_components {\n" + " id: \"title\"\n" + " type: \"label\"\n" + " data: \"size {\\n" + " x: 680.0\\n" + " y: 42.0\\n" + "}\\n" + "line_break: true\\n" + "text: \\\"Box2D distance joint\\\"\\n" + "font: \\\"/fonts/text28.font\\\"\\n" + "material: \\\"/builtins/fonts/label-df.material\\\"\\n" + "\"\n" + " position {\n" + " y: -60.0\n" + " z: 1.0\n" + " }\n" + "}\n" + "embedded_components {\n" + " id: \"rigid_label\"\n" + " type: \"label\"\n" + " data: \"size {\\n" + " x: 320.0\\n" + " y: 42.0\\n" + "}\\n" + "text: \\\"RIGID\\\"\\n" + "font: \\\"/fonts/text28.font\\\"\\n" + "material: \\\"/builtins/fonts/label-df.material\\\"\\n" + "\"\n" + " position {\n" + " x: -180.0\n" + " y: -160.0\n" + " z: 1.0\n" + " }\n" + "}\n" + "embedded_components {\n" + " id: \"spring_label\"\n" + " type: \"label\"\n" + " data: \"size {\\n" + " x: 320.0\\n" + " y: 42.0\\n" + "}\\n" + "text: \\\"SPRING\\\"\\n" + "font: \\\"/fonts/text28.font\\\"\\n" + "material: \\\"/builtins/fonts/label-df.material\\\"\\n" + "\"\n" + " position {\n" + " x: 180.0\n" + " y: -160.0\n" + " z: 1.0\n" + " }\n" + "}\n" + "" + position { + x: 360.0 + y: 720.0 + } +} +embedded_instances { + id: "wall" + data: "embedded_components {\n" + " id: \"collisionobject\"\n" + " type: \"collisionobject\"\n" + " data: \"type: COLLISION_OBJECT_TYPE_STATIC\\n" + "mass: 0.0\\n" + "friction: 0.4\\n" + "restitution: 0.0\\n" + "group: \\\"default\\\"\\n" + "mask: \\\"default\\\"\\n" + "embedded_collision_shape {\\n" + " shapes {\\n" + " shape_type: TYPE_BOX\\n" + " position {\\n" + " }\\n" + " rotation {\\n" + " }\\n" + " index: 0\\n" + " count: 3\\n" + " }\\n" + " data: 2.0\\n" + " data: 280.0\\n" + " data: 10.0\\n" + "}\\n" + "\"\n" + "}\n" + "embedded_components {\n" + " id: \"sprite\"\n" + " type: \"sprite\"\n" + " data: \"default_animation: \\\"pixel_white\\\"\\n" + "material: \\\"/builtins/materials/sprite.material\\\"\\n" + "size {\\n" + " x: 4.0\\n" + " y: 560.0\\n" + "}\\n" + "size_mode: SIZE_MODE_MANUAL\\n" + "textures {\\n" + " sampler: \\\"texture_sampler\\\"\\n" + " texture: \\\"/textures/textures.atlas\\\"\\n" + "}\\n" + "\"\n" + "}\n" + "" + position { + x: 360.0 + y: 270.0 + } +} diff --git a/physics/box2d_distance_joint/example/box2d_distance_joint.script b/physics/box2d_distance_joint/example/box2d_distance_joint.script new file mode 100644 index 00000000..6b907c3d --- /dev/null +++ b/physics/box2d_distance_joint/example/box2d_distance_joint.script @@ -0,0 +1,142 @@ +-- This example creates two pairs of distance joints at runtime. The left pair +-- keeps a fixed length, while the right pair is configured as a damped spring. + +-- Centers of the two demonstrations and settings used when the balls are reset. +local RIGID_CENTER_X = 180 +local SPRING_CENTER_X = 540 +local BALL_START_Y = 400 +local DROP_MAX_OFFSET_X = 80 +local DROP_START_VELOCITY = -40 +local DROP_INTERVAL = 5.5 + +-- Both joints attach near the upper corners of a platform. These coordinates +-- are local to the platform, so they rotate and move together with it. +local PLATFORM_ANCHOR_X = 90 +local PLATFORM_ANCHOR_Y = 12 +local JOINT_LENGTH = 226.56 + +-- Spring frequency controls stiffness. The damping ratio controls how quickly +-- the spring loses energy: 0 is undamped and 1 is critically damped. +local SPRING_HERTZ = 1.35 +local SPRING_DAMPING_RATIO = 0.25 + +-- The joints have no visual component, so lines are drawn in different colors +-- to make the rigid and spring constraints visible. +local RIGID_LINE_COLOR = vmath.vector4(0.85, 0.9, 1.0, 1.0) +local SPRING_LINE_COLOR = vmath.vector4(1.0, 0.68, 0.2, 1.0) + +-- Return the Box2D body handle belonging to a game object's collision object. +-- A body handle is required by the b2d body and joint APIs. +local function body(id) + return b2d.get_body(msg.url(nil, id, "collisionobject")) +end + +-- Ask the render script to draw a debug line for the current frame. +local function draw_line(from, to, color) + msg.post("@render:", "draw_line", { + start_point = from, + end_point = to, + color = color, + }) +end + +-- Connect one static anchor body to one dynamic platform body. +-- `local_anchor` is the attachment point in the platform's local coordinates. +-- `spring` selects between a fixed-length constraint and a damped spring. +local function create_distance_joint(self, anchor, platform, local_anchor, spring) + local joint = b2d.joint.create_distance(anchor, platform, { + -- Attach body A at its origin and body B at one corner of the platform. + local_anchor_a = vmath.vector3(), + local_anchor_b = local_anchor, + length = JOINT_LENGTH, + -- A rigid distance joint solves toward one fixed length. Unlike a revolute + -- joint, it does not force the two anchor points to occupy the same point. + enable_spring = spring, + -- Hertz controls how quickly the spring responds: higher values are stiffer. + hertz = spring and SPRING_HERTZ or 0, + -- Damping ratio removes oscillation; 0 has none and 1 is critically damped. + damping_ratio = spring and SPRING_DAMPING_RATIO or 0, + -- The connected bodies do not need to collide with each other. + collide_connected = false, + }) + + -- Keep the handle for drawing the joint now and destroying it during cleanup. + table.insert(self.connections, { + joint = joint, + color = spring and SPRING_LINE_COLOR or RIGID_LINE_COLOR, + }) +end + +-- Build one suspended platform from the consistently named collection objects. +-- For example, the "rigid" prefix finds rigid_platform and both rigid anchors. +local function create_setup(self, prefix, spring) + local platform = body(prefix .. "_platform") + -- Negative and positive X values attach the joints on opposite sides. + create_distance_joint(self, body(prefix .. "_left_anchor"), platform, + vmath.vector3(-PLATFORM_ANCHOR_X, PLATFORM_ANCHOR_Y, 0), spring) + create_distance_joint(self, body(prefix .. "_right_anchor"), platform, + vmath.vector3(PLATFORM_ANCHOR_X, PLATFORM_ANCHOR_Y, 0), spring) +end + +-- Reposition an existing ball instead of spawning a new one for every drop. +local function reset_body(body_handle, id, position) + -- Update both the game object and its Box2D body to the same transform. + go.set_position(position, msg.url(nil, id, nil)) + b2d.body.set_transform(body_handle, position, 0) + -- Give each ball the same downward start and remove any previous spin. + b2d.body.set_linear_velocity(body_handle, vmath.vector3(0, DROP_START_VELOCITY, 0)) + b2d.body.set_angular_velocity(body_handle, 0) + -- A sleeping body must be awakened so that gravity and collisions affect it. + b2d.body.set_awake(body_handle, true) +end + +-- Drop both balls with the same randomly selected horizontal offset. Using the +-- same offset makes their impacts comparable while varying repeated drops. +local function drop_pair(self) + -- math.random(-1, 1) selects -1, 0, or 1. + local offset = DROP_MAX_OFFSET_X * math.random(-1, 1) + reset_body(self.rigid_ball, "rigid_ball", vmath.vector3(RIGID_CENTER_X + offset, BALL_START_Y, 0)) + reset_body(self.spring_ball, "spring_ball", vmath.vector3(SPRING_CENTER_X + offset, BALL_START_Y, 0)) +end + +function init(self) + -- Create the four joints and cache the two ball body handles once. + self.connections = {} + create_setup(self, "rigid", false) + create_setup(self, "spring", true) + self.rigid_ball = body("rigid_ball") + self.spring_ball = body("spring_ball") + + -- Show the active Box2D major version and perform the first drop immediately. + local major_b2d_version = b2d.get_version().major + label.set_text("#title", "Box2D V" .. major_b2d_version .. " distance joint") + drop_pair(self) + + -- Repeat the drop at a fixed interval. update() is only responsible for drawing. + self.drop_timer = timer.delay(DROP_INTERVAL, true, function() + drop_pair(self) + end) +end + +function update(self) + -- Querying the joint anchors gives their current world-space positions, so + -- each line stays attached while its platform translates and rotates. + for _, connection in ipairs(self.connections) do + draw_line( + b2d.joint.get_anchor_a(connection.joint), + b2d.joint.get_anchor_b(connection.joint), + connection.color + ) + end +end + +function final(self) + -- Stop the repeating callback before releasing the resources it uses. + timer.cancel(self.drop_timer) + + -- Joints created through the runtime API must be explicitly destroyed when + -- the script is removed or the collection is unloaded. + for _, connection in ipairs(self.connections) do + b2d.joint.destroy(connection.joint) + end +end diff --git a/physics/box2d_distance_joint/example/platform.go b/physics/box2d_distance_joint/example/platform.go new file mode 100644 index 00000000..1439f04f --- /dev/null +++ b/physics/box2d_distance_joint/example/platform.go @@ -0,0 +1,43 @@ +embedded_components { + id: "sprite" + type: "sprite" + data: "default_animation: \"pixel_blue\"\n" + "material: \"/builtins/materials/sprite.material\"\n" + "size {\n" + " x: 220.0\n" + " y: 24.0\n" + "}\n" + "size_mode: SIZE_MODE_MANUAL\n" + "textures {\n" + " sampler: \"texture_sampler\"\n" + " texture: \"/textures/textures.atlas\"\n" + "}\n" + "" +} +embedded_components { + id: "collisionobject" + type: "collisionobject" + data: "type: COLLISION_OBJECT_TYPE_DYNAMIC\n" + "mass: 2.0\n" + "friction: 0.8\n" + "restitution: 0.0\n" + "group: \"default\"\n" + "mask: \"default\"\n" + "embedded_collision_shape {\n" + " shapes {\n" + " shape_type: TYPE_BOX\n" + " position {\n" + " }\n" + " rotation {\n" + " }\n" + " index: 0\n" + " count: 3\n" + " }\n" + " data: 110.0\n" + " data: 12.0\n" + " data: 10.0\n" + "}\n" + "linear_damping: 0.12\n" + "angular_damping: 0.35\n" + "" +} diff --git a/physics/box2d_distance_joint/fonts/SourceSansPro-Semibold.ttf b/physics/box2d_distance_joint/fonts/SourceSansPro-Semibold.ttf new file mode 100644 index 00000000..50205948 Binary files /dev/null and b/physics/box2d_distance_joint/fonts/SourceSansPro-Semibold.ttf differ diff --git a/physics/box2d_distance_joint/fonts/text28.font b/physics/box2d_distance_joint/fonts/text28.font new file mode 100644 index 00000000..3d9c4a8e --- /dev/null +++ b/physics/box2d_distance_joint/fonts/text28.font @@ -0,0 +1,5 @@ +font: "/fonts/SourceSansPro-Semibold.ttf" +material: "/builtins/fonts/font-df.material" +size: 28 +output_format: TYPE_DISTANCE_FIELD +characters: " !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" diff --git a/physics/box2d_distance_joint/game.project b/physics/box2d_distance_joint/game.project new file mode 100644 index 00000000..4ad380e5 --- /dev/null +++ b/physics/box2d_distance_joint/game.project @@ -0,0 +1,33 @@ +[bootstrap] +main_collection = /example/box2d_distance_joint.collectionc + +[script] +shared_state = 1 + +[display] +width = 720 +height = 720 +high_dpi = 1 + +[physics] +gravity_y = -900.0 +scale = 0.01 +use_fixed_timestep = 1 + +[html5] +scale_mode = no_scale + +[project] +title = Box2D Distance Joint + +[native_extension] +app_manifest = /box2d_v3.appmanifest + +[render] +clear_color_red = 0.160156 +clear_color_green = 0.164063 +clear_color_blue = 0.183594 + +[input] +game_binding = /builtins/input/all.input_bindingc + diff --git a/physics/box2d_distance_joint/setup.png b/physics/box2d_distance_joint/setup.png new file mode 100644 index 00000000..9f3c354f Binary files /dev/null and b/physics/box2d_distance_joint/setup.png differ diff --git a/physics/box2d_distance_joint/textures/ball.png b/physics/box2d_distance_joint/textures/ball.png new file mode 100644 index 00000000..c6f1173d Binary files /dev/null and b/physics/box2d_distance_joint/textures/ball.png differ diff --git a/physics/box2d_distance_joint/textures/pixel_blue.png b/physics/box2d_distance_joint/textures/pixel_blue.png new file mode 100644 index 00000000..2db50d55 Binary files /dev/null and b/physics/box2d_distance_joint/textures/pixel_blue.png differ diff --git a/physics/box2d_distance_joint/textures/pixel_gold.png b/physics/box2d_distance_joint/textures/pixel_gold.png new file mode 100644 index 00000000..5e398769 Binary files /dev/null and b/physics/box2d_distance_joint/textures/pixel_gold.png differ diff --git a/physics/box2d_distance_joint/textures/pixel_white.png b/physics/box2d_distance_joint/textures/pixel_white.png new file mode 100644 index 00000000..0e34154f Binary files /dev/null and b/physics/box2d_distance_joint/textures/pixel_white.png differ diff --git a/physics/box2d_distance_joint/textures/textures.atlas b/physics/box2d_distance_joint/textures/textures.atlas new file mode 100644 index 00000000..8ed1fc49 --- /dev/null +++ b/physics/box2d_distance_joint/textures/textures.atlas @@ -0,0 +1,13 @@ +images { + image: "/textures/pixel_white.png" +} +images { + image: "/textures/ball.png" +} +images { + image: "/textures/pixel_blue.png" +} +images { + image: "/textures/pixel_gold.png" +} +extrude_borders: 2 diff --git a/physics/box2d_distance_joint/thumbnail.webp b/physics/box2d_distance_joint/thumbnail.webp new file mode 100644 index 00000000..582b04f8 Binary files /dev/null and b/physics/box2d_distance_joint/thumbnail.webp differ