commit 70332388e80917fe5a5331b585354272f14e99e5 Author: Waylon S. Walker Date: Sat Jan 28 10:46:05 2023 -0600 init diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..9cde24d --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2023-present Waylon S. Walker + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..523342b --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# Cave Survival + +[![PyPI - Version](https://img.shields.io/pypi/v/cave-survival.svg)](https://pypi.org/project/cave-survival) +[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/cave-survival.svg)](https://pypi.org/project/cave-survival) + +----- + +**Table of Contents** + +- [Installation](#installation) +- [License](#license) + +## Installation + +```console +pip install cave-survival +``` + +## License + +`cave-survival` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license. diff --git a/cave_survival/__about__.py b/cave_survival/__about__.py new file mode 100644 index 0000000..a79c91e --- /dev/null +++ b/cave_survival/__about__.py @@ -0,0 +1,5 @@ +# SPDX-FileCopyrightText: 2023-present Waylon S. Walker +# +# SPDX-License-Identifier: MIT +__version__ = "0.0.1" +name = "Cave Survival" diff --git a/cave_survival/__init__.py b/cave_survival/__init__.py new file mode 100644 index 0000000..2a9f0e4 --- /dev/null +++ b/cave_survival/__init__.py @@ -0,0 +1,3 @@ +# SPDX-FileCopyrightText: 2023-present Waylon S. Walker +# +# SPDX-License-Identifier: MIT diff --git a/cave_survival/__main__.py b/cave_survival/__main__.py new file mode 100644 index 0000000..d016e82 --- /dev/null +++ b/cave_survival/__main__.py @@ -0,0 +1,9 @@ +# SPDX-FileCopyrightText: 2023-present Waylon S. Walker +# +# SPDX-License-Identifier: MIT +import sys + +if __name__ == '__main__': + from .cli import cave_survival + + sys.exit(cave_survival()) diff --git a/cave_survival/__pycache__/__about__.cpython-310.pyc b/cave_survival/__pycache__/__about__.cpython-310.pyc new file mode 100644 index 0000000..6e5904e Binary files /dev/null and b/cave_survival/__pycache__/__about__.cpython-310.pyc differ diff --git a/cave_survival/__pycache__/__init__.cpython-310.pyc b/cave_survival/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..5498c89 Binary files /dev/null and b/cave_survival/__pycache__/__init__.cpython-310.pyc differ diff --git a/cave_survival/__pycache__/console.cpython-310.pyc b/cave_survival/__pycache__/console.cpython-310.pyc new file mode 100644 index 0000000..0d06315 Binary files /dev/null and b/cave_survival/__pycache__/console.cpython-310.pyc differ diff --git a/cave_survival/__pycache__/run.cpython-310.pyc b/cave_survival/__pycache__/run.cpython-310.pyc new file mode 100644 index 0000000..bdf7bbc Binary files /dev/null and b/cave_survival/__pycache__/run.cpython-310.pyc differ diff --git a/cave_survival/assets/stev/1.png b/cave_survival/assets/stev/1.png new file mode 100644 index 0000000..29255ee Binary files /dev/null and b/cave_survival/assets/stev/1.png differ diff --git a/cave_survival/assets/stev/2.png b/cave_survival/assets/stev/2.png new file mode 100644 index 0000000..4a0b55c Binary files /dev/null and b/cave_survival/assets/stev/2.png differ diff --git a/cave_survival/cli/__init__.py b/cave_survival/cli/__init__.py new file mode 100644 index 0000000..8c70154 --- /dev/null +++ b/cave_survival/cli/__init__.py @@ -0,0 +1,42 @@ +# SPDX-FileCopyrightText: 2023-present Waylon S. Walker +# +# SPDX-License-Identifier: MIT +import debugpy +import typer + +from cave_survival.console import console +from cave_survival.run import run + +from ..__about__ import __version__, name + + +def version_callback(value: bool) -> None: + if value: + console.print(f"{__version__}") + raise typer.Exit() + + +app = typer.Typer( + name=name, + help="A cave survival game", +) + + +@app.callback(invoke_without_command=True) +def main( + version: bool = typer.Option( + False, + "--version", + callback=version_callback, # is_eager=True + ), + debug: bool = typer.Option(None, "--debug", help="start with debug mode running"), +) -> None: + if debug: + print("debugging") + debugpy.listen(("localhost", 5678)) + print("waiting...") + debugpy.wait_for_client() + + run() + # Do other global stuff, handle other global options here + return diff --git a/cave_survival/cli/__pycache__/__init__.cpython-310.pyc b/cave_survival/cli/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..f98bda4 Binary files /dev/null and b/cave_survival/cli/__pycache__/__init__.cpython-310.pyc differ diff --git a/cave_survival/console.py b/cave_survival/console.py new file mode 100644 index 0000000..a9463af --- /dev/null +++ b/cave_survival/console.py @@ -0,0 +1,3 @@ +from rich.console import Console + +console = Console() diff --git a/cave_survival/run.py b/cave_survival/run.py new file mode 100644 index 0000000..f7cbcfe --- /dev/null +++ b/cave_survival/run.py @@ -0,0 +1,78 @@ +import pygame + + +def run(): + # Initialize Pygame + pygame.init() + + # Set the window size and caption + size = (700, 500) + caption = "Pygame Image Movement" + screen = pygame.display.set_mode(size) + pygame.display.set_caption(caption) + + # Load an image and get its rectangle + image1 = pygame.image.load("cave_survival/assets/stev/1.png") + image2 = pygame.image.load("cave_survival/assets/stev/2.png") + image_rect = image1.get_rect() + + # Set the initial position of the image + image_rect.x = 0 + image_rect.y = 0 + movement_speed = 0.5 + + # Set the animation speed + animation_speed = 0.005 + + # Set the animation frame + animation_frame = 0 + + # Set the movement speed + movement_speed = 0.5 + + # Main game loop + running = True + while running: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + running = False + + # Get the current key presses + pressed = pygame.key.get_pressed() + + # Move the image based on the key presses + if pressed[pygame.K_w]: + image_rect.y -= movement_speed + if pressed[pygame.K_a]: + image_rect.x -= movement_speed + if pressed[pygame.K_s]: + image_rect.y += movement_speed + if pressed[pygame.K_d]: + image_rect.x += movement_speed + + # Animate the image if the player is moving + if ( + pressed[pygame.K_w] or + pressed[pygame.K_a] or + pressed[pygame.K_s] or + pressed[pygame.K_d] + ): + animation_frame += animation_speed + if animation_frame >= 2: + animation_frame = 0 + + image_rect.x += movement_speed + 1 + + # Draw the image on the screen + screen.fill((0, 0, 0)) + if animation_frame < 1: + screen.blit(image1, image_rect) + else: + screen.blit(image2, image_rect) + else: + screen.fill((0, 0, 0)) + screen.blit(image1, image_rect) + pygame.display.flip() + + # Clean up + pygame.quit() diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..4b3ac5c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,69 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "cave-survival" +description = 'survive in a cave game' +readme = "README.md" +requires-python = ">=3.7" +license = "MIT" +keywords = [] +authors = [ + { name = "Waylon S. Walker", email = "waylon@waylonwalker.com" }, +] +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", +] +dependencies = [ + "debugpy", + "pygame", + "typer", + "rich", +] +dynamic = ["version"] + +[project.urls] +Documentation = "https://github.com/unknown/cave-survival#readme" +Issues = "https://github.com/unknown/cave-survival/issues" +Source = "https://github.com/unknown/cave-survival" + +[project.scripts] +cave-survival = "cave_survival.cli:app" + +[tool.hatch.version] +path = "cave_survival/__about__.py" + +[tool.hatch.envs.default] +dependencies = [ + "pytest", + "pytest-cov", +] +[tool.hatch.envs.default.scripts] +cov = "pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=cave_survival --cov=tests {args}" +no-cov = "cov --no-cov {args}" + +[[tool.hatch.envs.test.matrix]] +python = ["37", "38", "39", "310", "311"] + +[tool.coverage.run] +branch = true +parallel = true +omit = [ + "cave_survival/__about__.py", +] + +[tool.coverage.report] +exclude_lines = [ + "no cov", + "if __name__ == .__main__.:", + "if TYPE_CHECKING:", +] diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..2a9f0e4 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1,3 @@ +# SPDX-FileCopyrightText: 2023-present Waylon S. Walker +# +# SPDX-License-Identifier: MIT