{"id":17011238,"url":"https://github.com/sysl-dev/wooden-blocks","last_synced_at":"2026-04-15T22:36:09.995Z","repository":{"id":206904422,"uuid":"717957380","full_name":"sysl-dev/Wooden-Blocks","owner":"sysl-dev","description":"A Box2D Wrapper for Love@d","archived":false,"fork":false,"pushed_at":"2023-11-13T03:53:55.000Z","size":48,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-26T17:24:36.069Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sysl-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-13T03:40:47.000Z","updated_at":"2023-11-13T03:42:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"f48baeac-9289-477a-8a94-86465110b3b0","html_url":"https://github.com/sysl-dev/Wooden-Blocks","commit_stats":null,"previous_names":["sysl-dev/wooden-blocks"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sysl-dev/Wooden-Blocks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysl-dev%2FWooden-Blocks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysl-dev%2FWooden-Blocks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysl-dev%2FWooden-Blocks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysl-dev%2FWooden-Blocks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sysl-dev","download_url":"https://codeload.github.com/sysl-dev/Wooden-Blocks/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysl-dev%2FWooden-Blocks/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31863495,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"ssl_error","status_checked_at":"2026-04-15T15:24:39.138Z","response_time":63,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T06:06:34.457Z","updated_at":"2026-04-15T22:36:09.978Z","avatar_url":"https://github.com/sysl-dev.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# About Wooden Blocks\nWooden Blocks is a library that makes using Box2D a bit easier in love.\n\n# Test File (Love 11.4)\n[Love File](https://github.com/sysl-dev/Wooden-Blocks/raw/main/WoodenBlockTest.love)\n\n\u003cimg src=\"https://user-images.githubusercontent.com/13181256/180626724-9c54b5ef-c527-4df1-a166-58a8b1cb4eaf.gif\" height=\"200\"\u003e\n\nZ - Left / X - Right / Space - Launch\n\n## Using the Library\n1. Require it.\n```lua\nlocal Wb = require(\"library.Wooden_Blocks\")\n```\n2. Run the setup and assign defaults.\n```lua\nWb.setup({\n  world_gravity_x = 0, -- Gravity V (Negitive is ^)\n  world_gravity_y = 320, -- Gravity \u003e (Negitive is \u003c)\n  world_allow_sleep = true, -- Allow non-moving objects to sleep. (Likely will always be true)\n  pixels_per_meter = 16, -- How big is a meter in your world in pixels.\n  mouse = {Utilities.pixel_scale.mouse.get_x, Utilities.pixel_scale.mouse.get_y}, -- Using a non-standard mouse? Pass the function here.\n  pause = false, -- Start Paused?\n  -- You can also pass a table to change the debug colors used for testing.\n})\n```\n3. Add the update code under the love.update callback.\n```lua\nWb.update(dt, Wb.object_pool, Wb.joint_pool, optional velocity_iterations, optional position_iterations)\n-- The iterations allow you to give more time for physics to resolve, higher is better but more intensive. \n```\n4. Add a debug drawing function under the love.draw callback.\n```lua\nWb.debug_draw_pool(Wb.object_pool, Wb.joint_pool, [Display Object Names: true/false])\n```\n5. Create some shapes under the love.load callback.\n```lua\n-- Note BASE_HEIGHT and BASE_WIDTH are the width/height of the window.\nlocal BASE_WIDTH, BASE_HEIGHT = love.graphics.getDimensions()\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"floor\",\n  x = 0,\n  y = BASE_HEIGHT - 10,\n  w = BASE_WIDTH,\n  h = 10,\n  body_type = \"static\",\n})\n```\n\n# Creating Objects \n## Required Values\n```lua\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  x = 0, -- X Position\n  y = BASE_HEIGHT - 10, -- Y Position \n  w = BASE_WIDTH, -- Width \n  h = 10, -- Height \n  body_type = \"dynamic\", -- static, dynamic or kinematic \n})\n```\n### Optional Values\n```lua\nshape = [string] -- What shape to use, defaults to rectangle. \nradius = [number] -- if used for non-circle shapes, w/h become radius*2\nmass = [number] -- How heavy something is. (Use Density instead)\ndensity = [number] -- How dense the mass is in the object. \nsensor = [true/false] -- Used for sensing things / no collision\nrestitution = [0.0/1.0] -- How fast the object comes to a stop. Between 0.0 (Brick) - 1.0 (Infinite)\nfriction = [0.0/1.0] -- How objects slide against this object. 0 - friction-less to 1.0 sandpaper\nangle = [number] -- Starting angle\nactive = [true/false] -- Is this object active?\ncan_sleep  = [true/false] -- Can this object sleep if inactive?\nangular_damping  = [0.0/1.0] -- A spinning body with no damping and no external forces will continue spinning indefinitely.\nbullet = [true/false] -- Spends more time checking this shapes calculations for impact.\nlock_angle = [true/false] -- Can this object rotate?\ngravity_scale = [number (1)] -- How much does gravity impact this object?\n__scale = [true/false] -- Drawing command, if using built in simple drawing, scale to shape.\n```\n### Optional Values - Groups/Masking\n```lua\ngroup = [number (0)] -- Sets the group the fixture belongs to. \n                     -- Fixtures with the same group will always \n                     -- collide if the group is positive or never \n                     -- collide if it's negative. The group zero \n                     -- means no group. \n\ncategory = [table/number (1)] -- Sets the categories the fixture belongs to. \n                              -- There can be up to 16 categories represented \n                              -- as a number from 1 to 16.\n\nmask = [table/number (nil)]   -- Sets the category masks of the fixture. \n                              -- There can be up to 16 categories represented \n                              -- as a number from 1 to 16.\n\n                              -- This fixture will NOT collide with the fixtures\n                              -- that are in the selected categories if the other \n                              -- fixture also has a category of this fixture selected. \n```\n\n## Built in Shapes\n1. rectangle, circle, triangle, triangle-right, hexagon, glass\n\n![image](https://user-images.githubusercontent.com/13181256/179370830-d3620578-0700-40d7-9f52-d9c22886c620.png)\n\n2. wine-glass, heart, spade, diamond, cross, star\n\n![image](https://user-images.githubusercontent.com/13181256/179370876-2ddf1323-17b0-4b56-ae4e-53a17f09974a.png)\n\n3. arrow, moon, pentagon, octogon, trapezoid, parallelogram\n\n![image](https://user-images.githubusercontent.com/13181256/179370934-d88f0de8-9487-4b2e-a274-cbb4ecb7c506.png)\n\n4. kite, club, tall-gem, gem, four-star, stairs\n\n![image](https://user-images.githubusercontent.com/13181256/179370956-0b95f2ae-62ee-4c25-8e7e-8f632fa630a3.png)\n\n\n\n\n# Creating Joints\n## Rope Joint\nDoes what it says on the tin, acts like a rope.\n\n### Creating\n```lua\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"floor\",\n  x = 0,\n  y = BASE_HEIGHT - 16,\n  w = BASE_WIDTH,\n  h = 16,\n  body_type = \"static\",\n  __scale = true,\n})\n\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"block1\",\n  x = BASE_WIDTH/2 - 18 * 1,\n  y = BASE_HEIGHT/2, \n  w = 16,\n  h = 16,\n  body_type = \"dynamic\",\n  shape = \"rectangle\",\n})\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"block2\",\n  x = BASE_WIDTH/2 + 18 * 1,\n  y = BASE_HEIGHT/2, \n  w = 16,\n  h = 16,\n  body_type = \"dynamic\",\n  shape = \"rectangle\",\n})\n\nWb.joint_pool[#Wb.joint_pool+1] = Wb.create_joint({\n  name = \"see-saw\",\n  type = \"rope\",\n  collide_connected = true,\n  pool = Wb.object_pool,\n  body1 = Wb.get_body_by_name(\"block1\", Wb.object_pool),\n  body2 = Wb.get_body_by_name(\"block2\", Wb.object_pool),\n  x1 = Wb.get_properties_by_name(\"block1\").cx,\n  y1 = Wb.get_properties_by_name(\"block1\", Wb.object_pool).cy,\n  x2 = Wb.get_properties_by_name(\"block2\", Wb.object_pool).cx,\n  y2 = Wb.get_properties_by_name(\"block2\", Wb.object_pool).cy,\n  max_length = 64,\n})\n```\n![image](https://user-images.githubusercontent.com/13181256/180619139-76a2bfc9-bc3b-4025-8ac8-52cafcf0bc9b.png)\n\n\n## Distance Joint\nActs like there is a stick between two objects. Note, the stick can overlap with the objects. May be worthwhile to use revolve joints w/ rectangles instead. \n\n### Creating\n```lua\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"floor\",\n  x = 0,\n  y = BASE_HEIGHT - 16,\n  w = BASE_WIDTH,\n  h = 16,\n  body_type = \"static\",\n  __scale = true,\n})\n\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"block1\",\n  x = BASE_WIDTH/2 - 18 * 1,\n  y = BASE_HEIGHT/2, \n  w = 16,\n  h = 16,\n  body_type = \"dynamic\",\n  shape = \"rectangle\",\n})\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"block2\",\n  x = BASE_WIDTH/2 + 18 * 1,\n  y = BASE_HEIGHT/2, \n  w = 16,\n  h = 16,\n  body_type = \"dynamic\",\n  shape = \"rectangle\",\n})\n\nWb.joint_pool[#Wb.joint_pool+1] = Wb.create_joint({\n  name = \"joint2\",\n  type = \"distance\",\n  collide_connected = true,\n  pool = Wb.object_pool,\n  body1 = Wb.get_body_by_name(\"block1\", Wb.object_pool),\n  body2 = Wb.get_body_by_name(\"block2\", Wb.object_pool),\n  x1 = Wb.get_properties_by_name(\"block1\").cx,\n  y1 = Wb.get_properties_by_name(\"block1\", Wb.object_pool).cy,\n  x2 = Wb.get_properties_by_name(\"block2\", Wb.object_pool).cx,\n  y2 = Wb.get_properties_by_name(\"block2\", Wb.object_pool).cy,\n})\n```\n![image](https://user-images.githubusercontent.com/13181256/180619258-ad0f798e-60f9-4e2c-aab3-440ae5217872.png)\n\n\n\n## Weld Joint\nConnect two objects together at any point in the world. \n\n### Create\n```lua\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"floor\",\n  x = 0,\n  y = BASE_HEIGHT - 16,\n  w = BASE_WIDTH,\n  h = 16,\n  body_type = \"static\",\n  __scale = true,\n})\n\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"block1\",\n  x = BASE_WIDTH/2 - 16 * 0,\n  y = BASE_HEIGHT/2, \n  w = 16,\n  h = 16,\n  body_type = \"dynamic\",\n  shape = \"rectangle\",\n})\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"block2\",\n  x = BASE_WIDTH/2 + 16 * 1,\n  y = BASE_HEIGHT/2, \n  w = 16,\n  h = 16,\n  body_type = \"dynamic\",\n  shape = \"rectangle\",\n})\n\nWb.joint_pool[#Wb.joint_pool+1] = Wb.create_joint({\n  name = \"joint3\",\n  type = \"weld\",\n  collide_connected = true,\n  pool = Wb.object_pool,\n  body1 = Wb.get_body_by_name(\"block1\", Wb.object_pool),\n  body2 = Wb.get_body_by_name(\"block2\", Wb.object_pool),\n  x = Wb.get_properties_by_name(\"block1\").cx + Wb.get_properties_by_name(\"block1\").w/2,\n  y = Wb.get_properties_by_name(\"block1\", Wb.object_pool).cy,\n})\n```\n![image](https://user-images.githubusercontent.com/13181256/180619868-bd7d8d8f-1d14-44d7-82b1-7734d24b4567.png)\n\n\n## Revolute Joint\nConnect two objects together as if they had a hinge between each point.\n\n### Create\n```lua \nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"floor\",\n  x = 0,\n  y = BASE_HEIGHT - 16,\n  w = BASE_WIDTH,\n  h = 16,\n  body_type = \"static\",\n  __scale = true,\n})\n\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"block1\",\n  x = BASE_WIDTH/2 - 18 * 1,\n  y = BASE_HEIGHT/2, \n  w = 16,\n  h = 16,\n  body_type = \"dynamic\",\n  shape = \"rectangle\",\n})\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"block2\",\n  x = BASE_WIDTH/2 + 18 * 1,\n  y = BASE_HEIGHT/2, \n  w = 16,\n  h = 16,\n  body_type = \"dynamic\",\n  shape = \"rectangle\",\n})\n\nWb.joint_pool[#Wb.joint_pool+1] = Wb.create_joint({\n  name = \"joint4\",\n  type = \"revolute\",\n  collide_connected = true,\n  pool = Wb.object_pool,\n  body1 = Wb.get_body_by_name(\"block1\", Wb.object_pool),\n  body2 = Wb.get_body_by_name(\"block2\", Wb.object_pool),\n  x = Wb.get_properties_by_name(\"block1\").cx + 8 + 10,\n  y = Wb.get_properties_by_name(\"block1\", Wb.object_pool).cy,\n})\n```\n![image](https://user-images.githubusercontent.com/13181256/180620429-01671871-0cff-47c7-a07a-4e1dec4551b1.png)\n\n## Wheel Joint\nAllows the objects to pull apart from each other while pulling back together. Think like a pull-cord on a toy, if enough force is applied it separates, but one the force is removed it pulls back in. \n\n### Create\n```lua\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"floor\",\n  x = 0,\n  y = BASE_HEIGHT - 16,\n  w = BASE_WIDTH,\n  h = 16,\n  body_type = \"static\",\n  __scale = true,\n})\n\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"block1\",\n  x = BASE_WIDTH/2 + 16 * 1,\n  y = BASE_HEIGHT/2, \n  radius = 8,\n  body_type = \"dynamic\",\n  shape = \"circle\",\n})\n\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"block2\",\n  x = BASE_WIDTH/2 - 16 * 1,\n  y = BASE_HEIGHT/2, \n  radius = 8,\n  body_type = \"dynamic\",\n  shape = \"circle\",\n})\n\n\nWb.joint_pool[#Wb.joint_pool+1] = Wb.create_joint({\n  name = \"cool_wheel\",\n  type = \"wheel\",\n  collide_connected = true,\n  pool = Wb.object_pool,\n  body1 = Wb.get_body_by_name(\"block1\", Wb.object_pool),\n  body2 = Wb.get_body_by_name(\"block2\", Wb.object_pool),\n  x1 = Wb.get_properties_by_name(\"block1\", Wb.object_pool).cx,\n  y1 = Wb.get_properties_by_name(\"block1\", Wb.object_pool).cy,\n  x2 = Wb.get_properties_by_name(\"block1\", Wb.object_pool).cx,\n  y2 = Wb.get_properties_by_name(\"block2\", Wb.object_pool).cy,\n  ax = 0.5,\n  ay = 0,\n})\n\nWb.get_joint_by_name(\"cool_wheel\"):setMaxMotorTorque(1000)\nWb.get_joint_by_name(\"cool_wheel\"):setMotorSpeed(360)\nWb.get_joint_by_name(\"cool_wheel\"):setMotorEnabled(true)\nWb.get_joint_by_name(\"cool_wheel\"):setSpringFrequency(10)\nWb.get_joint_by_name(\"cool_wheel\"):setSpringDampingRatio(0)\n```\n![image](https://user-images.githubusercontent.com/13181256/180621928-742f811c-e7e1-4fec-ac37-fb06b129e47c.png)\n\n\n## Gear Joint\nConnects two [prismatic](https://love2d.org/wiki/PrismaticJoint) or [revolute](https://love2d.org/wiki/RevoluteJoint) joints. Allows you to force something to behave as interconnected.\n\n### Create\n```lua\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"floor\",\n  x = 0,\n  y = BASE_HEIGHT - 16,\n  w = BASE_WIDTH,\n  h = 16,\n  body_type = \"static\",\n  __scale = true,\n})\n\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"block1\",\n  x = BASE_WIDTH/2 - 18 * 1,\n  y = BASE_HEIGHT/2, \n  w = 16,\n  h = 16,\n  body_type = \"dynamic\",\n  shape = \"rectangle\",\n})\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"block2\",\n  x = BASE_WIDTH/2 + 18 * 1,\n  y = BASE_HEIGHT/2, \n  w = 16,\n  h = 16,\n  body_type = \"dynamic\",\n  shape = \"rectangle\",\n})\n\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"block3\",\n  x = BASE_WIDTH/2 + 18 * 3,\n  y = BASE_HEIGHT/2, \n  w = 16,\n  h = 16,\n  body_type = \"dynamic\",\n  shape = \"rectangle\",\n})\n\nWb.joint_pool[#Wb.joint_pool+1] = Wb.create_joint({\n  name = \"jointa\",\n  type = \"revolute\",\n  collide_connected = true,\n  pool = Wb.object_pool,\n  body1 = Wb.get_body_by_name(\"block1\", Wb.object_pool),\n  body2 = Wb.get_body_by_name(\"block2\", Wb.object_pool),\n  x = Wb.get_properties_by_name(\"block1\").cx + 8 + 10,\n  y = Wb.get_properties_by_name(\"block1\", Wb.object_pool).cy,\n})\n\nWb.joint_pool[#Wb.joint_pool+1] = Wb.create_joint({\n  name = \"jointb\",\n  type = \"revolute\",\n  collide_connected = true,\n  pool = Wb.object_pool,\n  body1 = Wb.get_body_by_name(\"block2\", Wb.object_pool),\n  body2 = Wb.get_body_by_name(\"block3\", Wb.object_pool),\n  x = Wb.get_properties_by_name(\"block2\").cx + 8 + 10,\n  y = Wb.get_properties_by_name(\"block2\", Wb.object_pool).cy,\n})\n\nWb.joint_pool[#Wb.joint_pool + 1] = Wb.create_joint({\n  name = \"linked-jointa-jointb\",\n  type = \"gear\",\n  collide_connected = true,\n  pool = Wb.object_pool,\n  joint1 = Wb.get_joint_by_name(\"jointa\", Wb.joint_pool),\n  joint2 = Wb.get_joint_by_name(\"jointb\"),\n  ratio = -1,\n})\n```\n\n![image](https://user-images.githubusercontent.com/13181256/180622212-8ed8f876-7287-4608-b9c0-f3e33fcd96a5.png)\n\n\n## Prismatic Joint\nConnects two objects like they are on a sliding door. They can slide away a set distance and can slide together. \n![image](https://user-images.githubusercontent.com/13181256/179367311-0d290886-7359-49a4-b228-1f49860a2394.png) -\u003e \n![image](https://user-images.githubusercontent.com/13181256/179367404-602edc1f-1769-4b4b-a507-9453d8c68724.png) -\u003e\n![image](https://user-images.githubusercontent.com/13181256/179367315-72ea521e-9518-48e4-9a1f-140c15655c5c.png)\n\n### Create \n```lua\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"floor\",\n  x = 0,\n  y = BASE_HEIGHT - 16,\n  w = BASE_WIDTH,\n  h = 16,\n  body_type = \"static\",\n  __scale = true,\n})\n\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"block1\",\n  x = BASE_WIDTH/2 - 18 * 1,\n  y = BASE_HEIGHT/2, \n  w = 16,\n  h = 16,\n  body_type = \"dynamic\",\n  shape = \"rectangle\",\n})\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"block2\",\n  x = BASE_WIDTH/2 + 18 * 1,\n  y = BASE_HEIGHT/2, \n  w = 16,\n  h = 16,\n  body_type = \"dynamic\",\n  shape = \"rectangle\",\n})\n\n\nWb.joint_pool[#Wb.joint_pool+1] = Wb.create_joint({\n  name = \"jointa\",\n  type = \"prismatic\",\n  collide_connected = true,\n  pool = Wb.object_pool,\n  body1 = Wb.get_body_by_name(\"block1\", Wb.object_pool),\n  body2 = Wb.get_body_by_name(\"block2\", Wb.object_pool),\n  x1 = Wb.get_properties_by_name(\"block1\").cx,\n  y1 = Wb.get_properties_by_name(\"block1\", Wb.object_pool).cy,\n  x2 = Wb.get_properties_by_name(\"block2\").cx,\n  y2 = Wb.get_properties_by_name(\"block2\", Wb.object_pool).cy,\n  ax = 1,\n  ay = 0,\n})\n\nWb.get_joint_by_name(\"jointa\"):setLowerLimit(24)\nWb.get_joint_by_name(\"jointa\"):setUpperLimit(32)\n```\n![image](https://user-images.githubusercontent.com/13181256/180622642-5ebe022e-478a-41f8-a52a-43f579293257.png)\n\n\n## Mouse Joint\nConnect the object to an x/y position and the object will do it's best to follow it. This can be the mouse.\n\n### Create (Mouse Click)\n```lua\nlocal mousecount = 0 -- Make sure you set this to 0 if you clear the objects loaded.\nfunction love.mousepressed(x,y,button)\n  if button == 1 then \n    local created = Wb.create_mouse_joint({\n      joint_pool = Wb.joint_pool,\n      more_than_one_mouse_joint = true,\n      name = \"mouse\" .. tostring(mousecount)\n    })\n    if created then mousecount = mousecount + 1 end\n  end\n  if button == 2 then \n    local removed, removed_count = Wb.remove_mouse_joint({\n      joint_pool = Wb.joint_pool,\n      name = \"mouse\" .. tostring(mousecount - 1),\n      remove_one = false,\n    })\n    if removed then mousecount = mousecount - removed_count end\n  end -- print(mousecount)\nend\n```\n![love_FdRZSYl9bd](https://user-images.githubusercontent.com/13181256/179367477-86a2d1c8-8be7-40e1-8a41-7da835f87ba9.gif)\n\n### Create (Standard)\n```lua\nlocal followme = {x = 100, y = 100} -- This is what we use as a virtual cursor.\n\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"floor\",\n  x = 0,\n  y = BASE_HEIGHT - 16,\n  w = BASE_WIDTH,\n  h = 16,\n  body_type = \"static\",\n  __scale = true,\n})\n\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"block1\",\n  x = BASE_WIDTH/2 - 18 * 1,\n  y = BASE_HEIGHT/2, \n  w = 16,\n  h = 16,\n  body_type = \"dynamic\",\n  shape = \"rectangle\",\n})\n\nWb.joint_pool[#Wb.joint_pool+1] = Wb.create_joint({\n  name = \"follow_followme\",\n  type = \"mouse\",\n  collide_connected = false,\n  body1 = Wb.get_body_by_name(\"block1\"),\n  x = Wb.get_properties_by_name(\"block1\").cx,\n  y = Wb.get_properties_by_name(\"block1\").cy,\n})\n\n-- Top of file\nlocal t = 0\n-- In love update\nt = t + dt\nfollowme.x = 100 + math.sin(t * 10) * 50\nWb.get_joint_by_name(\"follow_followme\"):setTarget(followme.x, followme.y)\n```\n![love_gUPG8vEYkC](https://user-images.githubusercontent.com/13181256/180623181-8844a8d0-b620-4c23-8ec5-e94108db44ee.gif)\n\n## Pulley Joint\nActs like a pulley system between two objects with a fake rope between them.\n\n### Create\n```lua \nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"roof\",\n  x = 0,\n  y = 0,\n  w = BASE_WIDTH,\n  h = 16,\n  body_type = \"static\",\n  __scale = true,\n})\n\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"block1\",\n  x = BASE_WIDTH/2 - 18 * 1,\n  y = 50, \n  w = 16,\n  h = 16,\n  body_type = \"dynamic\",\n  shape = \"rectangle\",\n})\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"block2\",\n  x = BASE_WIDTH/2 + 18 * 1,\n  y = 50, \n  w = 16,\n  h = 16,\n  body_type = \"dynamic\",\n  shape = \"rectangle\",\n})\n\nWb.joint_pool[#Wb.joint_pool + 1] = Wb.create_joint({\n  name = \"platf\",\n  type = \"pulley\",\n  collide_connected = true,\n  pool = Wb.object_pool,\n  body1 = Wb.get_body_by_name(\"block1\", Wb.object_pool),\n  body2 = Wb.get_body_by_name(\"block2\", Wb.object_pool),\n  x1 = Wb.get_properties_by_name(\"block1\", Wb.object_pool).cx,\n  y1 = Wb.get_properties_by_name(\"block1\", Wb.object_pool).cy-8,\n  x2 = Wb.get_properties_by_name(\"block2\", Wb.object_pool).cx,\n  y2 = Wb.get_properties_by_name(\"block2\", Wb.object_pool).cy-8,\n  ax = 0,\n  ay = 0,\n  gx1 = Wb.get_properties_by_name(\"block1\", Wb.object_pool).cx,\n  gy1 = 16,\n  gx2 = Wb.get_properties_by_name(\"block2\", Wb.object_pool).cx,\n  gy2 = 16,\n  ratio = 1,\n})\n```\n![image](https://user-images.githubusercontent.com/13181256/180623769-57976f54-9dc9-414f-a5bf-73b357c354c4.png)\n\n\n## Friction Joint\nReduces speed between two objects. Really needs a watcher to be useful.\n\n### Create\n```lua\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"floor\",\n  x = 0,\n  y = BASE_HEIGHT - 16,\n  w = BASE_WIDTH,\n  h = 16,\n  body_type = \"static\",\n  __scale = true,\n})\n\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"block1\",\n  x = BASE_WIDTH/2 - 18 * 1,\n  y = 50, \n  w = 16,\n  h = 16,\n  body_type = \"dynamic\",\n  shape = \"rectangle\",\n})\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"block2\",\n  x = BASE_WIDTH/2 - 18 * 1,\n  y = 50, \n  w = 64,\n  h = 16,\n  body_type = \"dynamic\",\n  shape = \"rectangle\",\n})\n\nWb.joint_pool[#Wb.joint_pool + 1] = Wb.create_joint({\n  name = \"therub\",\n  type = \"friction\",\n  collide_connected = true,\n  pool = Wb.object_pool,\n  body1 = Wb.get_body_by_name(\"block1\", Wb.object_pool),\n  body2 = Wb.get_body_by_name(\"block2\", Wb.object_pool),\n  x1 = Wb.get_properties_by_name(\"block1\", Wb.object_pool).cx,\n  y1 = Wb.get_properties_by_name(\"block1\", Wb.object_pool).cy,\n  x2 = Wb.get_properties_by_name(\"block2\", Wb.object_pool).cx,\n  y2 = Wb.get_properties_by_name(\"block2\", Wb.object_pool).cy,\n \n})\n\nWb.get_joint_by_name(\"therub\"):setMaxForce(20)\nWb.get_joint_by_name(\"therub\"):setMaxTorque(200)\n```\n![image](https://user-images.githubusercontent.com/13181256/180624742-3d4f2f13-b1af-4061-acc0-e7c43fbd454b.png)\n\n\n## Motor Joint\nLink two objects and control the relative motion between them. Position and rotation offsets must be specified once the Motor Joint has been created, as well as the maximum motor force and torque that will be be applied to reach the target offsets. \n\n```lua\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"floor\",\n  x = 0,\n  y = BASE_HEIGHT - 16,\n  w = BASE_WIDTH,\n  h = 16,\n  body_type = \"static\",\n  __scale = true,\n})\n\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"block1\",\n  x = BASE_WIDTH/2 - 18 * 1,\n  y = 50, \n  w = 16,\n  h = 16,\n  body_type = \"dynamic\",\n  shape = \"rectangle\",\n})\nWb.object_pool[#Wb.object_pool+1] = Wb.create_simple_object({\n  name = \"block2\",\n  x = BASE_WIDTH/2 - 18 * 2,\n  y = 50, \n  w = 16,\n  h = 16,\n  body_type = \"dynamic\",\n  shape = \"rectangle\",\n})\n\nWb.joint_pool[#Wb.joint_pool + 1] = Wb.create_joint({\n  name = \"motorz\",\n  type = \"motor\",\n  collide_connected = true,\n  correction_factor = 0.5,\n  pool = Wb.object_pool,\n  body1 = Wb.get_body_by_name(\"block1\", Wb.object_pool),\n  body2 = Wb.get_body_by_name(\"block2\", Wb.object_pool),\n})\n\nWb.get_joint_by_name(\"motorz\"):setLinearOffset(5,5)\nWb.get_joint_by_name(\"motorz\"):setAngularOffset(20)\nWb.get_joint_by_name(\"motorz\"):setMaxForce(200)\nWb.get_joint_by_name(\"motorz\"):setMaxTorque(200)\n```\n\n![image](https://user-images.githubusercontent.com/13181256/180624928-136b7884-b87d-4f67-80b1-26d4fae7d8aa.png)\n\n# Changing the Update Loop\n## Add Callback Rules\nMaking changes to a [World](https://love2d.org/wiki/World) is not allowed inside of the beginContact, endContact, preSolve, and postSolve callback functions, as BOX2D locks the world during these callbacks.\n\n## Adding Rules\nYou add it from the callback type, name of the rule and a function to add.\n```lua\nWb.add_rule(\"begin\", \"test_rule_1\", function (a, b, coll)\n  print(\"begin\", a, b, coll) -- Print Callback\nend)\n\nWb.add_rule(\"end\", \"test_rule_2\", function (a, b, coll)\n  print(\"end\", a, b, coll) -- Print Callback\nend)\n\nWb.add_rule(\"pre\", \"test_rule_3\", function (a, b, coll)\n  print(\"pre\", a, b, coll) -- Print Callback\nend)\n\nWb.add_rule(\"post\", \"test_rule_4\", function (a, b, coll, normalimpulse, tangentimpulse)\n  print(\"post\", a, b, coll, normalimpulse, tangentimpulse) -- Print Callback\nend)\n```\n\n## Removing Rules\nYou remove it from the callback type and the name of the rule.\n```lua\nWb.remove_rule(\"begin\", \"test_rule_1\")\nWb.remove_rule(\"end\", \"test_rule_2\")\nWb.remove_rule(\"pre\", \"test_rule_3\")\nWb.remove_rule(\"post\", \"test_rule_4\")\n```\n\n## Do something once before the update of the world.\nIf you need to do something once before the world updates, you can create a pre-update. This will run once.\n```lua\n--Wb.add_pre_update(rule_name, rule_function)\nWb.add_pre_update(\"printer\", function(dt) print(\"Hi!\") end)\n```\n\n## Do something every update.\nIf you need to do something once before the world updates, do the following.\n```lua\n--Wb.add_do_every_update(rule_name, rule_function)\nWb.add_do_every_update(\"printer\", function(dt) print(\"Hi!\") end)\n\n-- Remove\n--Wb.remove_do_every_update(rule_name)\n.remove_do_every_update(\"printer\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsysl-dev%2Fwooden-blocks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsysl-dev%2Fwooden-blocks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsysl-dev%2Fwooden-blocks/lists"}