{"id":23785327,"url":"https://github.com/deadprogram/ghost-castle","last_synced_at":"2026-05-20T12:11:22.939Z","repository":{"id":270215673,"uuid":"909658065","full_name":"deadprogram/ghost-castle","owner":"deadprogram","description":"Simple roguelike game written using TinyGo with TinyRogue on Firefly Zero","archived":false,"fork":false,"pushed_at":"2024-12-30T15:27:06.000Z","size":35,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-21T10:29:32.929Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://fireflyzero.com/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deadprogram.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":"2024-12-29T12:01:02.000Z","updated_at":"2025-01-14T20:31:41.000Z","dependencies_parsed_at":"2024-12-29T13:25:20.664Z","dependency_job_id":"0968d307-d0d0-48bd-8668-8105ef982dcd","html_url":"https://github.com/deadprogram/ghost-castle","commit_stats":null,"previous_names":["deadprogram/ghost-castle"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/deadprogram/ghost-castle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deadprogram%2Fghost-castle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deadprogram%2Fghost-castle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deadprogram%2Fghost-castle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deadprogram%2Fghost-castle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deadprogram","download_url":"https://codeload.github.com/deadprogram/ghost-castle/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deadprogram%2Fghost-castle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":283847072,"owners_count":26904700,"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","status":"online","status_checked_at":"2025-11-11T02:00:06.610Z","response_time":65,"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":"2025-01-01T13:16:20.498Z","updated_at":"2025-11-11T12:04:41.418Z","avatar_url":"https://github.com/deadprogram.png","language":"Go","funding_links":[],"categories":["Gaming"],"sub_categories":["Instrumentation and control with sensors and actuators"],"readme":"# Ghost Castle\n\n\u003cimg src=\"./images/ghost.png\" alt=\"ghost screenshot\" width=\"480\"/\u003e\n\nSir Scaredy has made a wrong turn and ended up in Ghost Castle. There is no escape now! They will have to fight to survive ever increasing numbers of ghosts appearing.\n\n\u003cimg src=\"./images/ghost-combat.png\" alt=\"ghost combat screenshot\" width=\"480\"/\u003e\n\nThis is a simple [roguelike game](https://en.wikipedia.org/wiki/Roguelike) written using [TinyGo](https://tinygo.org/) with the [TinyRogue framework](https://github.com/deadprogram/tinyrogue) for [Firefly Zero](https://fireflyzero.com/).\n\nThis repo shows how to make a complete game.\n\n## Building\n\nTo build:\n\n```shell\nfirefly_cli build\n```\n\nTo run:\n\n```\nfirefly-emulator\n```\n\n## Code architecture\n\n### How the game functions\n\nThe main program has 3 primary functions.\n\nThe `boot()` function is where the TinyRogue setup for the game happens, by calling the `setupGame()` function.\n\nThe `update()` function is used to manage the state of the game. It controls the game rules and behavior. This function will be called many times per second. This is where the program checks to see if the player has pressed any buttons, and controls the logic about if the player has been attacked by a ghost, the score of the game, etc. Most of this logic is handled by calling the `game.Update()` function so it can be handed by the TinyRogue game engine.\n\nThe `render()` function is called to display the game graphics. It controls how things look on the screen, such as drawing the graphics for the  player, the map, and any ghosts that made have appeared. The function is called only when the screen needs to be refreshed, which is less often than the `update()` function that controls the game play. Most of this logic is handled by calling the `game.Render()` function so it can be handed by the TinyRogue game engine, in a similar way to how the `update()` function is handled.\n\n### Game modes\n\nThe game has three different modes:\n\n- `start` - before a new game has started\n- `play` - while the game is being played\n- `gameover` - after the game has ended\n\nAs such, there is an `updateStart()` function and a `renderStart()` function for the `start` mode.\n\nLikewise, there is a  an `updateGameover()` function and a `renderGameover()` function for the `gameover` mode.\n\nThe `play` mode is of special note, since what it mostly does is call the `game.Update()` functions of the `Game` that is the main entry point for the TinyRogue engine.\n\n### Game characters\n\nThe game has 2 different characters that are involved with the game play. One is the `Adventurer` that the player is controlling. The `Adventurer` type embeds the `tinyrogue.Player` type so it can use the predefined functionality for display and movement.\n\nThe other is the `Ghost` type that represents the creatures that the player has to battle. The `Ghost` type embeds the `tinyrogue.Creature` type so it can also use the predefined functionality.\n\n### Game action\n\nThe game action is what controls what happens when the `Adventurer` and `Ghost` get into contact. This game uses a `CombatAction` with a pretty minimal set of rules for attack and defense.\n\nThere is a `Combatant` interface defined, that has a type already defined so that the `Adventurer` and `Ghost` can embed it and pick up the standard functionality defined for the `CombatAction`.\n\n## Architecture diagram\n\nThis diagram shows the relationship between the different game functions, game modes, and the game characters.\n\n```mermaid\n\nflowchart TD\n    subgraph main\n    A[Main]\n    A --\u003e U{update}\n    A --\u003e R{render}\n    end\n    subgraph start\n    U --\u003e|update| US[updateStart]\n    R --\u003e|render| RS[renderStart]\n    end\n    subgraph play\n    U --\u003e|update| UP[game.Update]\n    R --\u003e|render| RP[game.Render]\n    end\n    subgraph gameover\n    U --\u003e|update| UG[updateGameover]\n    R --\u003e|render| RO[renderGameover]\n    end\n    subgraph tinyrogue\n    subgraph characters\n    ADV(adventurer) --\u003e PLAYER(player)\n    CREATURES[creatures] --\u003e G1(ghost 1)\n    CREATURES --\u003e G2(ghost 2)\n    CREATURES --\u003e G3(ghost 3)\n    CREATURES --\u003e GN(ghost n...)\n    end\n    subgraph levels\n    LEVELS(levels) --\u003e L1(level 1)\n    LEVELS --\u003e L2(level 2)\n    LEVELS --\u003e L3(level 3)\n    LEVELS --\u003e LN(level n...)\n    end\n    end\n    US --\u003e characters\n    UP --\u003e characters\n    RP --\u003e characters\n    UG --\u003e characters\n    \n    US --\u003e levels\n    UP --\u003e levels\n    RP --\u003e levels\n    UG --\u003e levels\n```\n\n## Credits\n\nUses graphics from https://kenney.nl/assets/tiny-dungeon\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeadprogram%2Fghost-castle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeadprogram%2Fghost-castle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeadprogram%2Fghost-castle/lists"}