{"id":16966574,"url":"https://github.com/erelado/py-snake","last_synced_at":"2025-03-21T17:40:34.808Z","repository":{"id":130985563,"uuid":"603410851","full_name":"erelado/py-snake","owner":"erelado","description":"Implementation for a snake game, with apples and walls, and using 'Tkinter' library for visualization.","archived":false,"fork":false,"pushed_at":"2023-02-18T12:40:50.000Z","size":47,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-26T12:41:28.528Z","etag":null,"topics":["apples","parseargs","python","python-3","python-snake","python-snake-game","python3","snake","snake-game","snake-game-python","snake-python","tkinter","tkinter-game","tkinter-graphic-interface","tkinter-gui","walls"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/erelado.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-02-18T12:32:48.000Z","updated_at":"2023-02-18T12:45:07.000Z","dependencies_parsed_at":"2023-04-22T12:24:22.171Z","dependency_job_id":null,"html_url":"https://github.com/erelado/py-snake","commit_stats":null,"previous_names":["erelado/py-snake"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erelado%2Fpy-snake","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erelado%2Fpy-snake/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erelado%2Fpy-snake/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erelado%2Fpy-snake/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erelado","download_url":"https://codeload.github.com/erelado/py-snake/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244842298,"owners_count":20519596,"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":["apples","parseargs","python","python-3","python-snake","python-snake-game","python3","snake","snake-game","snake-game-python","snake-python","tkinter","tkinter-game","tkinter-graphic-interface","tkinter-gui","walls"],"created_at":"2024-10-14T00:06:17.253Z","updated_at":"2025-03-21T17:40:34.780Z","avatar_url":"https://github.com/erelado.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Project Preview Image](https://github.com/E-RELevant/py-snake/blob/main/media/preview.png)\r\n\r\n# py-snake (GUI)\r\n\r\n## 📙 About the project\r\n\r\nAn implementation of the 'Snake' game.\r\n\r\nSnake is a sub-genre of action video game where the player maneuvers the end of a growing line, often themed as a snake. The player must keep the snake from colliding with both other obstacles and itself, which gets harder as the snake lengthens. [Read more](\u003chttps://en.wikipedia.org/wiki/Snake_(video_game_genre)\u003e).\r\n\r\n### ⚙️ Game settings\r\n\r\n- `Snake` is represented by three black links.\r\n- `Apple` is represented by one, static green link.\r\n- `Wall` is represented by three blue vertical or horizontal links, moves in a certain direction at half the speed of the snake.\r\n\r\nIn the beginning of the game, the snake's head is located in the center of the screen facing upward. Until the required amount is reached, an apple (in green color) and a wall (in blue color) are added.\r\n\r\n### ▶️ Interactions\r\n\r\nThe following diagram illustrates the interactions between the game's objects and their effects\r\n\r\n![Alt text](./media/py-snake-diagram.svg)\r\n\r\n#### Snake eats an apple\r\n\r\n- In the round in which the snake ate the apple, the player receives a score equal to the square root of the snake's length.\r\n  - As an example, a snake whose length at the beginning of the current round is 8 will receive the score of ⌊√8⌋ = 2.\r\n- Starting from the round after eating the apple, the snake's length will gradually increase by 3 links.\r\n- A new apple is added in its place the next round.\r\n\r\n#### A wall goes beyond the boundaries of the board\r\n\r\n- A new wall is added in its place the next round.\r\n\r\n#### A wall colliding with an apple\r\n\r\n- A new apple is added in its place the next round.\r\n\r\n#### A wall colliding with the snake's body\r\n\r\n- The snake's tail will be cut off at the point of collision.\r\n\r\n#### Snake's head is outside the board's boundaries, colliding with a wall or itself\r\n\r\n- Game over.\r\n\r\n## 🚩 Getting started\r\n\r\nrun:\r\n\r\n```shell\r\n\u003e python game_display.py --help\r\n\r\nusage: game_display.py [-h] [-x WIDTH] [-y HEIGHT] [-s SEED] [-a APPLES] [-d]\r\n                       [-w WALLS] [-r ROUNDS] [-t DELAY] [-v]\r\n\r\nRuns the \"Snake\" game. Closes the program automatically when disqualified.\r\n\r\noptional arguments:\r\n  -h, --help            show this help message and exit\r\n  -x WIDTH, --width WIDTH\r\n                        args.width: Game board width\r\n  -y HEIGHT, --height HEIGHT\r\n                        args.height: Game board height\r\n  -s SEED, --seed SEED  Seed for random number generator (not passed to game loop)\r\n  -a APPLES, --apples APPLES\r\n                        args.apples: Number of apples\r\n  -d, --debug           args.debug: Debug mode with no snake\r\n  -w WALLS, --walls WALLS\r\n                        args.walls: Number of walls\r\n  -r ROUNDS, --rounds ROUNDS\r\n                        args.rounds: Number of rounds\r\n  -t DELAY, --delay DELAY\r\n                        Delay between rounds in milliseconds (not passed to game loop)\r\n  -v, --verbose         Print helpful debugging information (not passed to game loop, can be used multiple times)\r\n```\r\n\r\n### 🔎 Examples\r\n\r\n```shell\r\n\u003e  python game_display.py\r\n```\r\n\r\n```shell\r\n# A board with a width of 30, a height of 40, 4 apples, and 1 wall\r\n\u003e python game_display.py --width 30 --height 40 --apples 4 --walls 1\r\n```\r\n\r\n```shell\r\n# A board with a width of 50, a height of 60, 5 apples, 2 walls, and 500 rounds\r\n\u003e python game_display.py -x 50 -y 60 -a 5 -w 2 -r 500\r\n```\r\n\r\nThe program uses `tkinter`, Python's standard GUI package. If you do not\r\nalready have `tkinter`, you can install it with:\r\n\r\n```shell\r\n\u003e pip install -r requirements.txt\r\n```\r\n\r\n## 💻 Built with\r\n\r\nThe game was built in `Python 3.9`, using the `tkinter` package (\"Tk interface\") GUI toolkit.\r\n\r\nDesigned and tested on Windows 11.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferelado%2Fpy-snake","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferelado%2Fpy-snake","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferelado%2Fpy-snake/lists"}