{"id":16213958,"url":"https://github.com/nezvers/defold_true-tile-collision","last_synced_at":"2025-03-19T09:31:09.723Z","repository":{"id":107585768,"uuid":"188874676","full_name":"nezvers/Defold_true-tile-collision","owner":"nezvers","description":"Collision system that doesn't use collision shapes.","archived":false,"fork":false,"pushed_at":"2023-07-14T08:38:22.000Z","size":25,"stargazers_count":16,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T17:46:56.833Z","etag":null,"topics":["2d","collision","defold","physics","tile-collision","tilemap"],"latest_commit_sha":null,"homepage":"","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/nezvers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2019-05-27T16:13:15.000Z","updated_at":"2024-05-06T05:10:36.000Z","dependencies_parsed_at":"2024-10-27T20:29:44.986Z","dependency_job_id":"a7ed988b-cadb-40f7-9d4e-9f71142f8455","html_url":"https://github.com/nezvers/Defold_true-tile-collision","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nezvers%2FDefold_true-tile-collision","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nezvers%2FDefold_true-tile-collision/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nezvers%2FDefold_true-tile-collision/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nezvers%2FDefold_true-tile-collision/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nezvers","download_url":"https://codeload.github.com/nezvers/Defold_true-tile-collision/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243982141,"owners_count":20378605,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["2d","collision","defold","physics","tile-collision","tilemap"],"created_at":"2024-10-10T11:09:13.372Z","updated_at":"2025-03-19T09:31:09.718Z","avatar_url":"https://github.com/nezvers.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# true-tile-collision\nCollision system for Defold that doesn't use collision shapes.\nCheck out [\"example project\"](https://github.com/nezvers/DefoldPublicExamples).\nIt's still in development but it contain everything you need for platformer game and easy to put together top-down game\n\n# Easy to use!\n## Prepare player\n```lua\nrequire \"true_tile_collision.true_tile_collision\"                                   -- [1]\n\nfunction init(self)\n    msg.post(\".\", \"acquire_input_focus\")\t\t\t\t--Enable inputs for player\n\n    init_physics(self, msg.url(), \"/background#tilemap\", \"collision\", 16, 2, 5, 0.2)    -- [2]\n    set_hitbox(self, 5, -5, 15, -1)                                                 -- [3]\nend\n\nfunction final(self)\n    msg.post(\".\", \"release_input_focus\")\t--Disable input upon deletion of the object\nend\n\nfunction update(self, dt)\n    --PHYSICS\n    physics_update_platformer_block(self, dt)                                       -- [4]\n    \n    --SPRITE - simple flip\n    if not self.on_ledge and not self.wallsliding then\n        if self.xinput==1 then\n            sprite.set_hflip(\"#sprite\", false)\n        elseif self.xinput==-1 then\n            sprite.set_hflip(\"#sprite\", true)\n        end\n    end\nend\n\nfunction on_input(self, action_id, action)\n    -- save all buttons in one variable using bitwise\n    if action_id == hash(\"up\") then\n        button_up(self)\n    elseif action_id == hash(\"down\")   then\n        button_down(self)\n    elseif action_id == hash(\"left\")   then\n        button_left(self)\n    elseif action_id == hash(\"right\")  then\n        button_right(self)\n    elseif action_id == hash(\"jump\")   then\n        button_jump(self)\n    elseif action_id == hash(\"action\") then --**\n        button_action(self)\n    elseif action_id == hash(\"start\")  then --**\n        button_start(self)\n    end\n    --** not used for True Tile collision but are there if you want to expand\nend\n```\n1. Reference the TrueTileCollision LUA module\n2. Creates all necessary variables inside object. Need to pass (self, URL, collisionTilemap, collisionLayer, tileSize, maxHorizontalSpeed, jumpSpeed, gravity) By default use values pixels per frame (60fps)\n3. Hitbox size (self, right, left, top, bottom) Distance from origin point to sides.\n4. Update physics. Built-in:  \nphysics_update_platformer_block;  \nphysics_update_platformer_slopes;  \nphysics_update_topdown;  \nphysics_update_walker.\n\nPlease look into init_physics() function because there you'll find needed flags and triggers for your objects (Abilities, States, triggers) to trigger sprite animations/ sounds or create your own AI behaviour.\n\n## Prepare tiles\nTiles doesn't need collision shapes. Collision happens using tile IDs from tilesource.  \nSuggested method would be to have tilemap with at least 2 layers where one of them is invisible and used for placing solid tiles, or use separate tilemap with dedicated tilesource (if you have more than one tilesources).  \nIf you don't have dedicated tilesource or IDs doesn't match the default values, all you need to do is call set_tiles function.\n```lua\nfunction set_tiles(tile1, tile2, tile3, tile4, tile5, tile6, tile7, tile8)\n\tsolid1\t= tile1\t\t--solid block\n\tsolid2\t= tile2\t\t--slope 45 righ\n\tsolid3\t= tile3\t\t--slope 45 left\n\tsolid4\t= tile4\t\t--slope 22.5 right 1/2\n\tsolid5\t= tile5\t\t--slope 22.5 right 2/2\n\tsolid6\t= tile6\t\t--slope 22.5 left 1/2\n\tsolid7\t= tile7\t\t--slope 22.5 left 2/2\n\tplat\t= tile8\t\t--Jumpthrough platform\nend\n```\nValues are IDs in tilesource used for collision. IDs in tilesource are counted from left to right and top to down, starting from 1.\n\n## Create your own _physics_update_\nSince dependancy LUA modules are read only, you can create module that refer to TTC (require \"true_tile_collision.true_tile_collision\") and create your own physics updates (for players and enemies) by using modular system from TTC.  \nFor reference you can use TTC built-in physics updates and many physics functions that's coded inside TTC.\n\n# HAPPY GAMEDEV\n## Cheers, _NeZvers_\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnezvers%2Fdefold_true-tile-collision","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnezvers%2Fdefold_true-tile-collision","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnezvers%2Fdefold_true-tile-collision/lists"}