{"id":13524978,"url":"https://github.com/JosephShering/adorbs","last_synced_at":"2025-04-01T04:30:35.441Z","repository":{"id":101355124,"uuid":"74608996","full_name":"JosephShering/adorbs","owner":"JosephShering","description":"LÖVE (love2d) entity framework","archived":false,"fork":false,"pushed_at":"2020-02-25T23:06:14.000Z","size":19,"stargazers_count":30,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-02T06:17:11.590Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JosephShering.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-11-23T19:48:36.000Z","updated_at":"2024-03-28T05:34:29.000Z","dependencies_parsed_at":"2023-07-28T01:15:07.308Z","dependency_job_id":null,"html_url":"https://github.com/JosephShering/adorbs","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JosephShering%2Fadorbs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JosephShering%2Fadorbs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JosephShering%2Fadorbs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JosephShering%2Fadorbs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JosephShering","download_url":"https://codeload.github.com/JosephShering/adorbs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222698192,"owners_count":17024878,"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":[],"created_at":"2024-08-01T06:01:15.071Z","updated_at":"2024-11-02T09:30:38.572Z","avatar_url":"https://github.com/JosephShering.png","language":"Lua","funding_links":[],"categories":["Entity"],"sub_categories":[],"readme":"# (Totes) Adorbs\n\nAdorbs is a functional entity framework for LÖVE. The goal was to provide a\nminimal entity framework sdk with a centralized game state.\n\n\n## Getting Started\n\nBelow is an example of a minimal ECS setup in adorbs.\n```lua\nlocal engine, system, entity, component = require 'adorbs' ()\n\nfunction love.load()\n    entity.create('player', {\n        'characterController', -- components are defined inline, and can be empty, as long as they are a string\n        transform = { x = 15, y = 0 }\n    })\n\n    system.create(\n        'systemName',\n        {'characterController', 'transform'},\n        function(delta, characterController, transform) -- called on each entity that matches components\n            print(transform.x) -- should print out 15\n        end\n    )\nend\n\nfunction love.draw()\n    engine.process()\nend\n```\n\nIf you're looking to move past the pare minimum I generally lay my projects out like so:\n\n```\nfolders\n -\u003e components\n -\u003e entities\n -\u003e systems\n```\n\nI populate those folders with my a respective ECS lua module that return a function, here is an example.\n\n##### Component\n```lua\n-- newTransform.lua\nreturn function(x, y, scale, rotation)\n    return { x = x, y = y, scale = scale, rotation = rotation}\nend\n```\n\n##### Entity\n```lua\nreturn function(spriteSheetLoc, x, y, speed)\n    entity.create('player', {\n        characterController = newCharacterController(speed),\n        transform = newTransform(x, y)\n    })\nend\n```\n\n##### System\n```lua\nreturn function()\n    system.create(\n        'animator',\n        {'animation', 'transform'},\n        function(dt, animation, transform)\n            local currentAnimation = animation.animations[animation.current]\n\n            if currentAnimation == nil then\n                error('You called an animation (' .. animation.current .. ') that does\\'nt exist!')\n                return\n            end\n\n            currentAnimation:update(dt)\n            currentAnimation:draw(animation.image, transform.x, transform.y)\n        end\n    )\nend\n```\n\nThen in your main.lua or scene file you just `require` what you need and they get added to the state automatically.\n\n```lua\n-- overworld.lua\n\nlocal scene = {}\nrequire 'systems/map' ()\nrequire 'systems/inputController' ()\nrequire 'systems/animator' ()\n\nfunction scene:enter()\n    require 'entities/map' ('maps/test') --you can make the functions accept arguments\n    require 'entities/player' ('assets/animplayers.png', 20, 20, 40) \nend\n\nfunction scene:draw(dt)\n    engine.process()\nend\n\nreturn scene\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJosephShering%2Fadorbs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJosephShering%2Fadorbs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJosephShering%2Fadorbs/lists"}