{"id":24092703,"url":"https://github.com/splo/tictactoe","last_synced_at":"2025-02-27T08:28:51.142Z","repository":{"id":103468074,"uuid":"407827266","full_name":"splo/tictactoe","owner":"splo","description":"A simple tic-tac-toe two player game for Windows, macOS and Linux, coded with Rust and Godot.","archived":false,"fork":false,"pushed_at":"2021-10-14T09:46:23.000Z","size":118,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-10T08:39:53.470Z","etag":null,"topics":["example","game","godot","godot-rust","rust","tic-tac-toe"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/splo.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":"2021-09-18T10:20:22.000Z","updated_at":"2022-01-06T22:31:13.000Z","dependencies_parsed_at":"2023-03-05T20:15:42.026Z","dependency_job_id":null,"html_url":"https://github.com/splo/tictactoe","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/splo%2Ftictactoe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/splo%2Ftictactoe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/splo%2Ftictactoe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/splo%2Ftictactoe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/splo","download_url":"https://codeload.github.com/splo/tictactoe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240995346,"owners_count":19890717,"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":["example","game","godot","godot-rust","rust","tic-tac-toe"],"created_at":"2025-01-10T08:36:47.657Z","updated_at":"2025-02-27T08:28:51.133Z","avatar_url":"https://github.com/splo.png","language":"Rust","readme":"# Tic Tac Toe\n\nA simple [tic-tac-toe](https://en.wikipedia.org/wiki/Tic-tac-toe) two player game for Windows, macOS and Linux, with simple graphics and sounds.\n\n![Tic Tac Toe screenshot](tictactoe.png)\n\n## Technical Features\n\n- Made with \u003cimg width=\"32\" height=\"32\" src=\"https://www.rust-lang.org/logos/rust-logo-blk.svg\"\u003e [Rust](https://www.rust-lang.org/) and \u003cimg width=\"32\" height=\"32\" src=\"https://godotengine.org/themes/godotengine/assets/press/icon_color.svg\"\u003e [Godot](https://godotengine.org/) using \u003cimg width=\"32\" height=\"32\" src=\"https://godot-rust.github.io/godot-ferris.svg\"\u003e [godot-rust](https://godot-rust.github.io/) bindings.\n- Strict seperaration between game logic written in Rust and user interface in Godot, as explained in the [game architecture page](https://godot-rust.github.io/book/gdnative-overview/architecture.html#3-rust-game--godot-io-layer) of the [godot-rust book](https://godot-rust.github.io/book/).\n- Deterministic game logic.\n- Unit tests for the core gameplay part.\n- CI that builds to Linux, macOS and Windows (MSVC) and release as zip files on every push with tag named starting with `v`.\n- Scripts that allow to install Godot and its export templates on Linux, macOS and Windows.\n- Designed to be easily copy-pasted to bootstrap new projects.\n\n## Development\n\n### Organization\n\nThe code is split in 3 parts:\n\n- `tictactoe`: a pure Rust library that hosts the core game logic.\n- `tictactoe-gui`: the Godot project that defines all graphics, sounds and UI code, and generates the input actions.\n- `tictactoe-godot`: a Rust library that provides glue code to link the Rust library and the Godot project together.\n\n#### Library `tictactoe`\n\nThis is where all important gameplay code is located.\n\nIt has a single public function:\n\n```rust\nfn update(\u0026mut self, delta: f64, actions: \u0026[Action]) -\u003e Vec\u003cEvent\u003e\n```\n\n- `delta`: how long to advance the simulation.\n- `actions`: actions that should be applied to the simulation.\n- `-\u003e Vec\u003cEvent\u003e`: events that happened during the simulation step.\n\nIt is reasonably well unit tested and the build/run tests loop is very fast since the library has no external dependency.\n\n- Actions can be `PlaceMark` or `Reset`.\n- Events can be `GameStarted`, `GameEnded` or `MarkPlaced`.\n\n#### Library `tictactoe-godot`\n\nIts goal is to:\n\n- Gather relevant input actions from Godot (left mouse clicks).\n- Convert them in `Action` Rust enum values.\n- Pass them to the simulation update of `tictactoe`.\n- Collect returned `Event` Rust enum values and emit related Godot signals.\n\nIn order to determine where the player clicked when placing a mark, the `last_clicked_coordinates` property is called to the first child node. It is expected that Godot fills this property with the right coordinates according to which cell the player clicked.\n\n#### Godot Project `tictactoe-gui`\n\nResponsabilites:\n\n- Render the user interface.\n- Instantiate a game logic Node with the GDNative script attached to it and call the `_physics_process` function.\n- Add a child to this Node with the `last_clicked_coordinates` property.\n- Fill the `last_clicked_coordinates` property when left mouse clicks are detected in the grid.\n- Connect the signals emitted by the game logic node to the relevant functions, so graphics and sounds react to game events.\n\n### Building\n\nThe Godot project assumes the library is built according to the paths in [`tictactoe.gdnlib`](tictactoe-gui\\src\\tictactoe.gdnlib): `target/{target_name}/release/{library_file}`.\n\nThis means the Rust code should be built with the `--target` argument of `cargo`.\n\nThe easiest is to use the `cargo-make` configuration defined in [`Makefile.toml`](Makefile.toml):\n\n```shell\n# Needed the first time:\ncargo install cargo-make\n# Then build a release.\ncargo make build-release\n```\n\nIn order to export the game (which is what the CI [GitHub Actions workflow](.github/workflows/ci.yml) does):\n\n```shell\ncargo make export\n```\n\nThis will:\n\n- Run the tests.\n- Build a release version of the libraries.\n- Install Godot if not installed.\n- Install Godot export templates if not installed.\n- Export the OS version of the game.\n\n## Credits\n\nSound assets from [Kenney Game Assets 3](https://kenney.itch.io/kenney-game-assets-3).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsplo%2Ftictactoe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsplo%2Ftictactoe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsplo%2Ftictactoe/lists"}