{"id":17590762,"url":"https://github.com/setanarut/anim","last_synced_at":"2026-03-06T04:03:47.727Z","repository":{"id":257790160,"uuid":"860599228","full_name":"setanarut/anim","owner":"setanarut","description":"Animation player for Ebitengine v2","archived":false,"fork":false,"pushed_at":"2025-03-16T04:32:43.000Z","size":39,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-29T23:12:55.907Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/setanarut.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,"zenodo":null}},"created_at":"2024-09-20T18:36:19.000Z","updated_at":"2025-03-23T09:38:32.000Z","dependencies_parsed_at":"2025-01-21T23:20:54.414Z","dependency_job_id":"e287fde9-7605-40a0-b152-0824c63ce7c0","html_url":"https://github.com/setanarut/anim","commit_stats":null,"previous_names":["setanarut/anim"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/setanarut/anim","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/setanarut%2Fanim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/setanarut%2Fanim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/setanarut%2Fanim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/setanarut%2Fanim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/setanarut","download_url":"https://codeload.github.com/setanarut/anim/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/setanarut%2Fanim/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30161345,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T22:39:40.138Z","status":"online","status_checked_at":"2026-03-06T02:00:08.268Z","response_time":250,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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-22T04:24:35.173Z","updated_at":"2026-03-06T04:03:47.702Z","avatar_url":"https://github.com/setanarut.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![GoDoc](https://godoc.org/github.com/setanarut/anim?status.svg)](https://pkg.go.dev/github.com/setanarut/anim)\n\n# Anim\n\n![demo](https://github.com/user-attachments/assets/15fb4ef9-00a6-412d-af5f-67ff9fa1fb4c)\n\nAnim is an easy to use animation player package for Ebitengine v2\n\n```Go\nimport \"github.com/setanarut/anim\"\n```\n\n## Tutorial\n\nLet's declare a global variable for the animation player\n\n```Go\nvar animPlayer *anim.AnimationPlayer\n```\n\nMake new animation player from sprite atlas\n\n![runner](https://github.com/user-attachments/assets/54871498-ae7b-4107-adf4-e292aaff47e7)\n\n```Go\nspriteSheet := anim.Atlas{\n\tName:  \"Default\",\n\tImage: ebiten.NewImageFromImage(img),\n}\nanimPlayer = anim.NewAnimationPlayer(spriteSheet)\n```\n\nLet's specify the coordinates of the animations for the player states.\nThe figure shows the coordinates for \"run\" state.\n\n![diag](https://github.com/user-attachments/assets/316be3e7-102f-4d3f-b126-637cda387253)\n\n\n```Go\nanimPlayer.NewAnim(\"idle\", 0, 0, 32, 32, 5, false, false, 5)\nanimPlayer.NewAnim(\"run\", 0, 32, 32, 32, 8, false, false, 12)\nanimPlayer.NewAnim(\"jump\", 0, 32*2, 32, 32, 4, false, false, 15)\n```\n\nLet's set the initial animation state.\n\n```Go\nanimPlayer.SetAnim(\"idle)\n```\n\nUpdate animation player\n\n```Go\nfunc (g *Game) Update() error {\n\tanimPlayer.Update()\n```\n\nLet's update the states according to the character's movement.\n\n```Go\nif ebiten.IsKeyPressed(ebiten.KeySpace) {\n\tanimPlayer.SetAnim(\"jump\")\n} else if ebiten.IsKeyPressed(ebiten.KeyD) {\n\tanimPlayer.SetAnim(\"run\")\n} else if ebiten.IsKeyPressed(ebiten.KeyA) {\n\tanimPlayer.SetAnim(\"run\")\n\t// FlipX\n\tDIO.GeoM.Scale(-1, 1)\n\t// Align to zero\n\tDIO.GeoM.Translate(float64(animPlayer.CurrentFrame.Bounds().Dx()), 0)\n} else {\n\tanimPlayer.SetAnim(\"idle\")\n}\n```\n\nFinally let's draw Animation player\n\n```Go\nfunc (g *Game) Draw(screen *ebiten.Image) {\n\tscreen.DrawImage(animPlayer.CurrentFrame, DIO)\n```\n\n## Examples\n\n### Simple demo\n\nRun [demo](./examples/demo/) on your local machine\n\n```zsh\ngo run github.com/setanarut/anim/examples/demo@latest\n```\n### Multiple sprite sheet example\n\nExample of alternative sprite sheets with exactly the same coordinates.  \nRun [atlases](./examples/atlases/) on your local machine;\n\n```zsh\ngo run github.com/setanarut/anim/examples/atlases@latest\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsetanarut%2Fanim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsetanarut%2Fanim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsetanarut%2Fanim/lists"}