{"id":18396829,"url":"https://github.com/kemokemo/ebiten-virtualpad","last_synced_at":"2025-09-22T22:37:55.836Z","repository":{"id":46109167,"uuid":"405532159","full_name":"kemokemo/ebiten-virtualpad","owner":"kemokemo","description":"virtualpad package for ebiten","archived":false,"fork":false,"pushed_at":"2022-11-15T13:11:56.000Z","size":544,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T15:07:51.004Z","etag":null,"topics":["ebiten","ebiten-parts","go","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kemokemo.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}},"created_at":"2021-09-12T02:59:07.000Z","updated_at":"2021-11-14T05:15:26.000Z","dependencies_parsed_at":"2023-01-21T17:35:50.790Z","dependency_job_id":null,"html_url":"https://github.com/kemokemo/ebiten-virtualpad","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kemokemo%2Febiten-virtualpad","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kemokemo%2Febiten-virtualpad/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kemokemo%2Febiten-virtualpad/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kemokemo%2Febiten-virtualpad/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kemokemo","download_url":"https://codeload.github.com/kemokemo/ebiten-virtualpad/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248586236,"owners_count":21128997,"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":["ebiten","ebiten-parts","go","golang"],"created_at":"2024-11-06T02:14:59.033Z","updated_at":"2025-09-22T22:37:50.780Z","avatar_url":"https://github.com/kemokemo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ebiten Virtual Pad\n\nThis is a package for displaying virtual directional keys and trigger buttons on the screen to handle user input.  \nIt is intended to be used in games that use [ebiten](https://ebiten.org/).\n\n## How to use\n\nPlease check [the sample app](https://github.com/kemokemo/ebiten-virtualpad/tree/main/cmd) for more detail.\n\n### Basic\n\nUse the `NewDirectionalPad` and `NewTriggerButton` functions of the vpad package to generate the buttons.\n\n```go\nimport (\n\t\"github.com/hajimehoshi/ebiten/v2\"\n\t\"github.com/hajimehoshi/ebiten/v2/ebitenutil\"\n\tvpad \"github.com/kemokemo/ebiten-virtualpad\"\n)\n\nconst (\n\tscreenWidth  = 480\n\tscreenHeight = 320\n)\n\nfunc NewGame() *Game {\n\tdpad := vpad.NewDirectionalPad(directional_pad, directional_button, vpad.SelectColor)\n\tdpad.SetLocation(10, 180)\n\n\t// vpad.Pressing is continuously triggered while this button is being pressed.\n\taButton := vpad.NewTriggerButton(a_button, vpad.Pressing, vpad.SelectColor)\n\taButton.SetLocation(150, 190)\n\n\t// vpad.JustRelease is triggered when this button is released.\n\tbButton := vpad.NewTriggerButton(b_button, vpad.JustReleased, vpad.SelectColor)\n\tbButton.SetLocation(260, 190)\n\n\t// vpad.JustPress is triggered when this button is pressed.\n\tcButton := vpad.NewTriggerButton(c_button, vpad.JustPressed, vpad.SelectColor)\n\tcButton.SetLocation(370, 190)\n\n\treturn \u0026Game{dpad: dpad, aButton: aButton, bButton: bButton, cButton: cButton}\n}\n\ntype Game struct {\n\tdpad    vpad.DirectionalPad\n\taButton vpad.TriggerButton\n\tbButton vpad.TriggerButton\n\tcButton vpad.TriggerButton\n}\n```\n\n### Get direction and triggered state\n\nUpdate the internal state with the `Update` function, and get the direction or trigger presence with the `GetDirection` or `IsTriggered` function.\n\n```go\nfunc (g *Game) Update() error {\n\tg.dpad.Update()\n\tg.aButton.Update()\n\tg.bButton.Update()\n\tg.cButton.Update()\n\n\treturn nil\n}\n\nfunc (g *Game) Draw(screen *ebiten.Image) {\n\tg.dpad.Draw(screen)\n\td := g.dpad.GetDirection()\n\tswitch d {\n\tcase vpad.Upper:\n\t\tebitenutil.DebugPrintAt(screen, \"Upper direction\", 20, 20)\n\tcase vpad.Lower:\n\t\tebitenutil.DebugPrintAt(screen, \"Lower direction\", 20, 20)\n\tcase vpad.Left:\n\t\tebitenutil.DebugPrintAt(screen, \"Left direction\", 20, 20)\n\tcase vpad.Right:\n\t\tebitenutil.DebugPrintAt(screen, \"Right direction\", 20, 20)\n\t}\n\n\tg.aButton.Draw(screen)\n\tif g.aButton.IsTriggered() {\n\t\tebitenutil.DebugPrintAt(screen, \"A button is being triggered.\", 20, 50)\n\t}\n\n\tg.bButton.Draw(screen)\n\tif g.bButton.IsTriggered() {\n\t\tebitenutil.DebugPrintAt(screen, \"B button is triggered.\", 20, 50)\n\t}\n\n\tg.cButton.Draw(screen)\n\tif g.cButton.IsTriggered() {\n\t\tebitenutil.DebugPrintAt(screen, \"C button is triggered.\", 20, 50)\n\t}\n}\n```\n\n### Various triggers\n\nThe following types of TriggerButtons are currently available.\n\n| Type  | Description  |\n|---|---|\n| JustReleased  | This is triggered only when just released.  |\n|Pressing|This is triggered while this is being pressed.|\n|JustPressed|This is triggered only when just pressed.|\n\n## License\n\nApache-2.0 License\n\n## Author\n\nkemokemo\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkemokemo%2Febiten-virtualpad","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkemokemo%2Febiten-virtualpad","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkemokemo%2Febiten-virtualpad/lists"}