{"id":13805246,"url":"https://github.com/mohamedLT/V_ecs","last_synced_at":"2025-05-13T19:30:32.414Z","repository":{"id":65931764,"uuid":"532648550","full_name":"mohamedLT/V_ecs","owner":"mohamedLT","description":"Entity component system for Vlang","archived":false,"fork":false,"pushed_at":"2023-04-07T20:22:17.000Z","size":8,"stargazers_count":17,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-18T21:47:04.307Z","etag":null,"topics":["ecs","v","vlang"],"latest_commit_sha":null,"homepage":"","language":"V","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/mohamedLT.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":"2022-09-04T20:19:09.000Z","updated_at":"2024-07-23T11:43:15.000Z","dependencies_parsed_at":"2024-05-03T03:01:42.140Z","dependency_job_id":"72bdae27-7f5d-4d49-bb19-7f8c3a447f07","html_url":"https://github.com/mohamedLT/V_ecs","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/mohamedLT%2FV_ecs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohamedLT%2FV_ecs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohamedLT%2FV_ecs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohamedLT%2FV_ecs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mohamedLT","download_url":"https://codeload.github.com/mohamedLT/V_ecs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254012923,"owners_count":21999334,"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":["ecs","v","vlang"],"created_at":"2024-08-04T01:00:59.095Z","updated_at":"2025-05-13T19:30:32.113Z","avatar_url":"https://github.com/mohamedLT.png","language":"V","funding_links":[],"categories":["Libraries"],"sub_categories":["Game development"],"readme":"V ecs is an Entity component System library for V that have a simplistic yet powerful design \n# What is ecs :\nECS is a programming pattern that is mostly used in games \n  - E: Entities which are in most cases just an id \n  - C: Component and thay are simple structs \n  - S: Systems and they are functions that use or change compenents \n# Usage :\nV ecs have a very simple desing you basically have to create a struct and a function that use the data in that struct \nHere is an example \n\n```\n\nimport gg\nimport gx\nimport mohamedlt.vecs as ecs\n\nconst (\n\twin_width  = 600\n\twin_height = 300\n)\n\nstruct App {\nmut:\n\tgg    \u0026gg.Context\n\timage gg.Image\n  // the world object is what makes everthing work \n\tworld ecs.World\n}\n\n// a Position Component \nstruct Pos {\n\tecs.Comp\nmut:\n\tx f32\n\ty f32\n}\n// a Color Component\nstruct Color {\n\tecs.Comp\n\tcolor gx.Color\n}\n// A Resource Can be anything from pictures to simple data \nstruct Number{\n\tecs.Resource\n\tval int\n}\n\nfn main() {\n\tmut app := \u0026App{\n\t\tgg: 0\n\t}\n  // add entity takes a list of the component you need in it \n\tapp.world.add_entity([Pos{x:0,y:20},Color{color:gx.gray}])\n  // add system takes a function name and a list of compenets that must be in an entity to apply this system to \n\tapp.world.add_system(app.draw,[Pos{},Color{}])\n  // same as above but just gives a mut entity \n\tapp.world.add_system_mut(frame,[Pos{},Color{}])\n  // add resource to the world \n\tapp.world.add_resource(Number{val:2,name:'numb'})\n\tapp.gg = gg.new_context(\n\t\tbg_color: gx.white\n\t\twidth: win_width\n\t\theight: win_height\n\t\tcreate_window: true\n\t\twindow_title: 'Rectangles'\n\t\tframe_fn: update\n\t\tuser_data:app\n\t)\n\tapp.gg.run()\n}\n\nfn update(mut app App){\n  // world.step needs to be called every frame or whenever you want to update the world \n\tapp.world.step()\n}\n// any system needs to accept a mut entity or an unmut one and a ResourceManger \nfn(app \u0026App) draw(e ecs.Entity,mut r ecs.ResourceManger){\n\tapp.gg.begin()\n  // Entity.get_comp return the component of that entity\n\tp := e.get_comp\u003cPos\u003e()or {panic(\"\")}\n\tc:= e.get_comp\u003cColor\u003e()or {panic(\"\")}\n  // ResourceManger.get_resource takes a resource name and returns it \n\tspeed := r.get_resource\u003cNumber\u003e('numb')or {panic(\"\")}\n\tprintln(speed.val)\n\tapp.gg.draw_rect_filled(p.x,p.y,20,20,c.color)\n\n\tapp.gg.end()\n}\n// this is a system that takes a mut entity and moves it \nfn  frame(mut  e ecs.Entity,mut r ecs.ResourceManger){\n\tmut pos := e.get_comp\u003cPos\u003e() or {panic('')}\n\tpos.x++\n}\n```\n# Notes:\n- A compenet must embed ecs.Comp or have a active field \n- A Resource must embed ecs.Resource or have a name field \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FmohamedLT%2FV_ecs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FmohamedLT%2FV_ecs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FmohamedLT%2FV_ecs/lists"}