diff --git a/physics/box2d_revolute_bridge/all.texture_profiles b/physics/box2d_revolute_bridge/all.texture_profiles new file mode 100644 index 00000000..5b0d7762 --- /dev/null +++ b/physics/box2d_revolute_bridge/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_revolute_bridge/box2d_v2.appmanifest b/physics/box2d_revolute_bridge/box2d_v2.appmanifest new file mode 100644 index 00000000..b3abe8c8 --- /dev/null +++ b/physics/box2d_revolute_bridge/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_revolute_bridge/box2d_v3.appmanifest b/physics/box2d_revolute_bridge/box2d_v3.appmanifest new file mode 100644 index 00000000..9751deca --- /dev/null +++ b/physics/box2d_revolute_bridge/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_revolute_bridge/example.md b/physics/box2d_revolute_bridge/example.md new file mode 100644 index 00000000..b1b1c070 --- /dev/null +++ b/physics/box2d_revolute_bridge/example.md @@ -0,0 +1,52 @@ +--- +tags: physics, box2d +title: Box2D Revolute Bridge +brief: Create a bridge from revolute joints between existing Defold collision objects. +author: Defold Foundation +scripts: box2d_revolute_bridge_v3.script, box2d_revolute_bridge_v2.script +thumbnail: thumbnail.webp +--- + +This example builds a simple rope bridge from rectangular dynamic bodies connected with Box2D revolute joints. +A ball drops onto the bridge so the hinge chain bends under load. + +Click or tap the window to reset the ball. + +## What You'll Learn + +- How to get Box2D bodies from Defold collision objects with `b2d.get_body()` +- How to connect two bodies with a `revolute` type joint +- How local joint anchors define hinge points on each connected body + +## Setup + +The collection contains these game objects: + +`controller` +: Contains both backend scripts, `box2d_revolute_bridge_v2.script` and `box2d_revolute_bridge_v3.script`, plus the title and hint labels. Each script checks the active Box2D version and only one script runs. + +`left_anchor` and `right_anchor` +: Static collision objects used as the fixed bridge supports. + +`segment_01` to `segment_10` +: Dynamic rectangular collision objects. The active script creates revolute joints between neighboring segments. + +`ball` +: A dynamic circle collision object that falls onto the bridge to show how the joints move. + +`floor`, `left_wall`, and `right_wall` +: Static collision objects that keep the simulation in view after the ball falls through or off the bridge. + +The project uses `box2d_v3.appmanifest` by default, so it runs with Box2D V3. +To use the older legacy V2 backend, switch the native extension app manifest in `game.project` to `/box2d_v2.appmanifest`. + +![setup](setup.png) + +## How It Works + +Both scripts use the same collection-authored bodies. `b2d.get_body()` returns the Box2D body owned by each collision object, and `b2d.joint.create_revolute()` creates the hinge constraints at runtime. + +Each bridge segment is 48 pixels wide. The script connects the right edge of one body to the left edge of the next body by using local anchors: `(24, 0, 0)` on the previous segment and `(-24, 0, 0)` on the current segment. +The first and last joints connect to static anchors at the bridge supports. + +On reset, the script moves the ball up and drops it onto the bridge again. The joints are created once in `init()` and destroyed in `final()`. diff --git a/physics/box2d_revolute_bridge/example/anchor.go b/physics/box2d_revolute_bridge/example/anchor.go new file mode 100644 index 00000000..0e47cb75 --- /dev/null +++ b/physics/box2d_revolute_bridge/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: 22.0\n" + " y: 22.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.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: 11.0\n" + " data: 11.0\n" + " data: 10.0\n" + "}\n" + "" +} diff --git a/physics/box2d_revolute_bridge/example/ball.go b/physics/box2d_revolute_bridge/example/ball.go new file mode 100644 index 00000000..241d5b8e --- /dev/null +++ b/physics/box2d_revolute_bridge/example/ball.go @@ -0,0 +1,42 @@ +embedded_components { + id: "sprite" + type: "sprite" + data: "default_animation: \"ball\"\n" + "material: \"/builtins/materials/sprite.material\"\n" + "size {\n" + " x: 254.0\n" + " y: 254.0\n" + "}\n" + "textures {\n" + " sampler: \"texture_sampler\"\n" + " texture: \"/textures/textures.atlas\"\n" + "}\n" + "" + scale { + x: 0.5 + y: 0.5 + } +} +embedded_components { + id: "collisionobject" + type: "collisionobject" + data: "type: COLLISION_OBJECT_TYPE_DYNAMIC\n" + "mass: 1.0\n" + "friction: 0.35\n" + "restitution: 0.2\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_revolute_bridge/example/box2d_revolute_bridge.collection b/physics/box2d_revolute_bridge/example/box2d_revolute_bridge.collection new file mode 100644 index 00000000..a2b04bb4 --- /dev/null +++ b/physics/box2d_revolute_bridge/example/box2d_revolute_bridge.collection @@ -0,0 +1,180 @@ +name: "box2d_revolute_bridge" +instances { + id: "left_anchor" + prototype: "/example/anchor.go" + position { + x: 120.0 + y: 300.0 + } +} +instances { + id: "right_anchor" + prototype: "/example/anchor.go" + position { + x: 600.0 + y: 300.0 + } +} +instances { + id: "segment_01" + prototype: "/example/segment.go" + position { + x: 144.0 + y: 300.0 + } +} +instances { + id: "segment_02" + prototype: "/example/segment.go" + position { + x: 192.0 + y: 300.0 + } +} +instances { + id: "segment_03" + prototype: "/example/segment.go" + position { + x: 240.0 + y: 300.0 + } +} +instances { + id: "segment_04" + prototype: "/example/segment.go" + position { + x: 288.0 + y: 300.0 + } +} +instances { + id: "segment_05" + prototype: "/example/segment.go" + position { + x: 336.0 + y: 300.0 + } +} +instances { + id: "segment_06" + prototype: "/example/segment.go" + position { + x: 384.0 + y: 300.0 + } +} +instances { + id: "segment_07" + prototype: "/example/segment.go" + position { + x: 432.0 + y: 300.0 + } +} +instances { + id: "segment_08" + prototype: "/example/segment.go" + position { + x: 480.0 + y: 300.0 + } +} +instances { + id: "segment_09" + prototype: "/example/segment.go" + position { + x: 528.0 + y: 300.0 + } +} +instances { + id: "segment_10" + prototype: "/example/segment.go" + position { + x: 576.0 + y: 300.0 + } +} +instances { + id: "ball" + prototype: "/example/ball.go" + position { + x: 360.0 + y: 560.0 + } +} +instances { + id: "floor" + prototype: "/example/wall.go" + position { + x: 360.0 + y: 54.0 + } + rotation { + z: 0.70710677 + w: 0.70710677 + } +} +instances { + id: "left_wall" + prototype: "/example/wall.go" + position { + x: 50.0 + y: 360.0 + } +} +instances { + id: "right_wall" + prototype: "/example/wall.go" + position { + x: 670.0 + y: 360.0 + } +} +scale_along_z: 0 +embedded_instances { + id: "controller" + data: "components {\n" + " id: \"script_v3\"\n" + " component: \"/example/box2d_revolute_bridge_v3.script\"\n" + "}\n" + "components {\n" + " id: \"script_v2\"\n" + " component: \"/example/box2d_revolute_bridge_v2.script\"\n" + "}\n" + "embedded_components {\n" + " id: \"title\"\n" + " type: \"label\"\n" + " data: \"size {\\n" + " x: 640.0\\n" + " y: 42.0\\n" + "}\\n" + "line_break: true\\n" + "text: \\\"Box2D revolute bridge\\\"\\n" + "font: \\\"/fonts/text28.font\\\"\\n" + "material: \\\"/builtins/fonts/label-df.material\\\"\\n" + "\"\n" + " position {\n" + " x: 360.0\n" + " y: 680.0\n" + " }\n" + "}\n" + "embedded_components {\n" + " id: \"hint\"\n" + " type: \"label\"\n" + " data: \"size {\\n" + " x: 640.0\\n" + " y: 42.0\\n" + "}\\n" + "line_break: true\\n" + "text: \\\"Click or touch to reset\\\"\\n" + "font: \\\"/fonts/text28.font\\\"\\n" + "material: \\\"/builtins/fonts/label-df.material\\\"\\n" + "\"\n" + " position {\n" + " x: 360.0\n" + " y: 640.0\n" + " }\n" + "}\n" + "" +} diff --git a/physics/box2d_revolute_bridge/example/box2d_revolute_bridge_v2.script b/physics/box2d_revolute_bridge/example/box2d_revolute_bridge_v2.script new file mode 100644 index 00000000..a77d52b9 --- /dev/null +++ b/physics/box2d_revolute_bridge/example/box2d_revolute_bridge_v2.script @@ -0,0 +1,103 @@ +local TOUCH = hash("touch") +local MOUSE_BUTTON_LEFT = hash("mouse_button_left") +local SEGMENT_HALF_WIDTH = 24 +local START_BALL_POSITION = vmath.vector3(360, 560, 0) + +local SEGMENTS = { + "segment_01", + "segment_02", + "segment_03", + "segment_04", + "segment_05", + "segment_06", + "segment_07", + "segment_08", + "segment_09", + "segment_10", +} + +local function body(id) + return b2d.get_body(msg.url(nil, id, "collisionobject")) -- <1> +end + +local function create_joint(self, body_a, body_b, local_anchor_a, local_anchor_b) + local joint = b2d.joint.create_revolute(body_a, body_b, { -- <2> + local_anchor_a = local_anchor_a, + local_anchor_b = local_anchor_b, + collide_connected = false, + }) + table.insert(self.joints, joint) +end + +local function reset_body(body, position) + b2d.body.set_transform(body, position, 0) -- <3> + b2d.body.set_linear_velocity(body, vmath.vector3()) + b2d.body.set_angular_velocity(body, 0) + b2d.body.set_awake(body, true) +end + +local function reset_ball(self) + go.set_position(START_BALL_POSITION, msg.url(nil, "ball", nil)) -- <4> + reset_body(self.ball, START_BALL_POSITION) -- <5> + b2d.body.set_linear_velocity(self.ball, vmath.vector3(0, -80, 0)) -- <6> +end + +local function create_bridge(self) + self.joints = {} + + local previous = body("left_anchor") + for index, segment_id in ipairs(SEGMENTS) do + local current = body(segment_id) + + local anchor_a = index == 1 and vmath.vector3() or vmath.vector3(SEGMENT_HALF_WIDTH, 0, 0) + create_joint(self, previous, current, anchor_a, vmath.vector3(-SEGMENT_HALF_WIDTH, 0, 0)) -- <7> + previous = current + end + + create_joint(self, previous, body("right_anchor"), vmath.vector3(SEGMENT_HALF_WIDTH, 0, 0), vmath.vector3()) -- <8> + self.ball = body("ball") +end + +function init(self) + self.active = b2d.get_version().major == 2 -- <9> + if not self.active then + return + end + + label.set_text("#title", "Box2D V2 revolute bridge") + create_bridge(self) + reset_ball(self) + msg.post(".", "acquire_input_focus") -- <10> +end + +function on_input(self, action_id, action) + if self.active and (action_id == TOUCH or action_id == MOUSE_BUTTON_LEFT) and action.pressed then -- <11> + reset_ball(self) + end +end + +function final(self) + if not self.active then + return + end + + for _, joint in ipairs(self.joints) do + b2d.joint.destroy(joint) -- <12> + end + msg.post(".", "release_input_focus") +end + +--[[ +1. Get the native Box2D body owned by a Defold collision object in the collection. +2. Create one revolute joint. The local anchors define the hinge point on each connected body. +3. Reset a dynamic body to a known transform and clear its previous motion. +4. Move the visible ball game object back above the bridge so the reset is immediate. +5. Move the Box2D body to the same position and clear old motion. +6. Give the ball a small downward velocity so the reset immediately drops it onto the bridge. +7. Connect each segment to the previous body. The first segment connects to the left static anchor. +8. Connect the last segment to the right static anchor, completing the bridge. +9. Run this script only when the active Box2D backend is V2. +10. Acquire input so a click or touch can reset the ball. +11. Reset the ball when the user clicks or taps. The built-in input binding may send mouse clicks as `mouse_button_left` or `touch`. +12. Destroy the scripted joints when the collection is finalized. +]] diff --git a/physics/box2d_revolute_bridge/example/box2d_revolute_bridge_v3.script b/physics/box2d_revolute_bridge/example/box2d_revolute_bridge_v3.script new file mode 100644 index 00000000..999441ff --- /dev/null +++ b/physics/box2d_revolute_bridge/example/box2d_revolute_bridge_v3.script @@ -0,0 +1,103 @@ +local TOUCH = hash("touch") +local MOUSE_BUTTON_LEFT = hash("mouse_button_left") +local SEGMENT_HALF_WIDTH = 24 +local START_BALL_POSITION = vmath.vector3(360, 610, 0) + +local SEGMENTS = { + "segment_01", + "segment_02", + "segment_03", + "segment_04", + "segment_05", + "segment_06", + "segment_07", + "segment_08", + "segment_09", + "segment_10", +} + +local function body(id) + return b2d.get_body(msg.url(nil, id, "collisionobject")) -- <1> +end + +local function create_joint(self, body_a, body_b, local_anchor_a, local_anchor_b) + local joint = b2d.joint.create_revolute(body_a, body_b, { -- <2> + local_anchor_a = local_anchor_a, + local_anchor_b = local_anchor_b, + collide_connected = false, + }) + table.insert(self.joints, joint) +end + +local function reset_body(body, position) + b2d.body.set_transform(body, position, 0) -- <3> + b2d.body.set_linear_velocity(body, vmath.vector3()) + b2d.body.set_angular_velocity(body, 0) + b2d.body.set_awake(body, true) +end + +local function reset_ball(self) + go.set_position(START_BALL_POSITION, msg.url(nil, "ball", nil)) -- <4> + reset_body(self.ball, START_BALL_POSITION) -- <5> + b2d.body.set_linear_velocity(self.ball, vmath.vector3(0, -80, 0)) -- <6> +end + +local function create_bridge(self) + self.joints = {} + + local previous = body("left_anchor") + for index, segment_id in ipairs(SEGMENTS) do + local current = body(segment_id) + + local anchor_a = index == 1 and vmath.vector3() or vmath.vector3(SEGMENT_HALF_WIDTH, 0, 0) + create_joint(self, previous, current, anchor_a, vmath.vector3(-SEGMENT_HALF_WIDTH, 0, 0)) -- <7> + previous = current + end + + create_joint(self, previous, body("right_anchor"), vmath.vector3(SEGMENT_HALF_WIDTH, 0, 0), vmath.vector3()) -- <8> + self.ball = body("ball") +end + +function init(self) + self.active = b2d.get_version().major == 3 -- <9> + if not self.active then + return + end + + label.set_text("#title", "Box2D V3 revolute bridge") + create_bridge(self) + reset_ball(self) + msg.post(".", "acquire_input_focus") -- <10> +end + +function on_input(self, action_id, action) + if self.active and (action_id == TOUCH or action_id == MOUSE_BUTTON_LEFT) and action.pressed then -- <11> + reset_ball(self) + end +end + +function final(self) + if not self.active then + return + end + + for _, joint in ipairs(self.joints) do + b2d.joint.destroy(joint) -- <12> + end + msg.post(".", "release_input_focus") +end + +--[[ +1. Get the native Box2D body owned by a Defold collision object in the collection. +2. Create one revolute joint. The local anchors define the hinge point on each connected body. +3. Reset a dynamic body to a known transform and clear its previous motion. +4. Move the visible ball game object back above the bridge so the reset is immediate. +5. Move the Box2D body to the same position and clear old motion. +6. Give the ball a small downward velocity so the reset immediately drops it onto the bridge. +7. Connect each segment to the previous body. The first segment connects to the left static anchor. +8. Connect the last segment to the right static anchor, completing the bridge. +9. Run this script only when the active Box2D backend is V3. +10. Acquire input so a click or touch can reset the ball. +11. Reset the ball when the user clicks or taps. The built-in input binding may send mouse clicks as `mouse_button_left` or `touch`. +12. Destroy the scripted joints when the collection is finalized. +]] diff --git a/physics/box2d_revolute_bridge/example/segment.go b/physics/box2d_revolute_bridge/example/segment.go new file mode 100644 index 00000000..7572b543 --- /dev/null +++ b/physics/box2d_revolute_bridge/example/segment.go @@ -0,0 +1,42 @@ +embedded_components { + id: "sprite" + type: "sprite" + data: "default_animation: \"pixel_blue\"\n" + "material: \"/builtins/materials/sprite.material\"\n" + "size {\n" + " x: 48.0\n" + " y: 14.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: 1.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: 24.0\n" + " data: 7.0\n" + " data: 10.0\n" + "}\n" + "angular_damping: 0.1\n" + "" +} diff --git a/physics/box2d_revolute_bridge/example/wall.go b/physics/box2d_revolute_bridge/example/wall.go new file mode 100644 index 00000000..982103d7 --- /dev/null +++ b/physics/box2d_revolute_bridge/example/wall.go @@ -0,0 +1,41 @@ +embedded_components { + id: "sprite" + type: "sprite" + data: "default_animation: \"pixel_white\"\n" + "material: \"/builtins/materials/sprite.material\"\n" + "size {\n" + " x: 18.0\n" + " y: 630.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.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: 9.0\n" + " data: 315.0\n" + " data: 10.0\n" + "}\n" + "" +} diff --git a/physics/box2d_revolute_bridge/fonts/SourceSansPro-Semibold.ttf b/physics/box2d_revolute_bridge/fonts/SourceSansPro-Semibold.ttf new file mode 100644 index 00000000..50205948 Binary files /dev/null and b/physics/box2d_revolute_bridge/fonts/SourceSansPro-Semibold.ttf differ diff --git a/physics/box2d_revolute_bridge/fonts/text28.font b/physics/box2d_revolute_bridge/fonts/text28.font new file mode 100644 index 00000000..3d9c4a8e --- /dev/null +++ b/physics/box2d_revolute_bridge/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_revolute_bridge/game.project b/physics/box2d_revolute_bridge/game.project new file mode 100644 index 00000000..aa081a53 --- /dev/null +++ b/physics/box2d_revolute_bridge/game.project @@ -0,0 +1,36 @@ +[bootstrap] +main_collection = /example/box2d_revolute_bridge.collectionc + +[script] +shared_state = 1 + +[display] +width = 720 +height = 720 +high_dpi = 1 + +[android] +input_method = HiddenInputField + +[physics] +gravity_y = -900.0 +scale = 0.01 +use_fixed_timestep = 1 + +[html5] +scale_mode = stretch + +[input] +game_binding = /builtins/input/all.input_bindingc + +[project] +title = Box2D Revolute Bridge + +[native_extension] +app_manifest = /box2d_v2.appmanifest + +[render] +clear_color_red = 0.160156 +clear_color_green = 0.164063 +clear_color_blue = 0.183594 + diff --git a/physics/box2d_revolute_bridge/setup.png b/physics/box2d_revolute_bridge/setup.png new file mode 100644 index 00000000..15dc02d7 Binary files /dev/null and b/physics/box2d_revolute_bridge/setup.png differ diff --git a/physics/box2d_revolute_bridge/textures/ball.png b/physics/box2d_revolute_bridge/textures/ball.png new file mode 100644 index 00000000..c6f1173d Binary files /dev/null and b/physics/box2d_revolute_bridge/textures/ball.png differ diff --git a/physics/box2d_revolute_bridge/textures/pixel_blue.png b/physics/box2d_revolute_bridge/textures/pixel_blue.png new file mode 100644 index 00000000..2db50d55 Binary files /dev/null and b/physics/box2d_revolute_bridge/textures/pixel_blue.png differ diff --git a/physics/box2d_revolute_bridge/textures/pixel_gold.png b/physics/box2d_revolute_bridge/textures/pixel_gold.png new file mode 100644 index 00000000..5e398769 Binary files /dev/null and b/physics/box2d_revolute_bridge/textures/pixel_gold.png differ diff --git a/physics/box2d_revolute_bridge/textures/pixel_orange.png b/physics/box2d_revolute_bridge/textures/pixel_orange.png new file mode 100644 index 00000000..9fb97e44 Binary files /dev/null and b/physics/box2d_revolute_bridge/textures/pixel_orange.png differ diff --git a/physics/box2d_revolute_bridge/textures/pixel_white.png b/physics/box2d_revolute_bridge/textures/pixel_white.png new file mode 100644 index 00000000..0e34154f Binary files /dev/null and b/physics/box2d_revolute_bridge/textures/pixel_white.png differ diff --git a/physics/box2d_revolute_bridge/textures/textures.atlas b/physics/box2d_revolute_bridge/textures/textures.atlas new file mode 100644 index 00000000..e788effb --- /dev/null +++ b/physics/box2d_revolute_bridge/textures/textures.atlas @@ -0,0 +1,16 @@ +images { + image: "/textures/pixel_white.png" +} +images { + image: "/textures/ball.png" +} +images { + image: "/textures/pixel_blue.png" +} +images { + image: "/textures/pixel_gold.png" +} +images { + image: "/textures/pixel_orange.png" +} +extrude_borders: 2 diff --git a/physics/box2d_revolute_bridge/thumbnail.webp b/physics/box2d_revolute_bridge/thumbnail.webp new file mode 100644 index 00000000..366418e1 Binary files /dev/null and b/physics/box2d_revolute_bridge/thumbnail.webp differ