From 70332388e80917fe5a5331b585354272f14e99e5 Mon Sep 17 00:00:00 2001 From: "Waylon S. Walker" Date: Sat, 28 Jan 2023 10:46:05 -0600 Subject: [PATCH] init --- LICENSE.txt | 9 ++ README.md | 21 +++++ cave_survival/__about__.py | 5 ++ cave_survival/__init__.py | 3 + cave_survival/__main__.py | 9 ++ .../__pycache__/__about__.cpython-310.pyc | Bin 0 -> 198 bytes .../__pycache__/__init__.cpython-310.pyc | Bin 0 -> 149 bytes .../__pycache__/console.cpython-310.pyc | Bin 0 -> 209 bytes cave_survival/__pycache__/run.cpython-310.pyc | Bin 0 -> 1201 bytes cave_survival/assets/stev/1.png | Bin 0 -> 1280 bytes cave_survival/assets/stev/2.png | Bin 0 -> 1309 bytes cave_survival/cli/__init__.py | 42 ++++++++++ .../cli/__pycache__/__init__.cpython-310.pyc | Bin 0 -> 1069 bytes cave_survival/console.py | 3 + cave_survival/run.py | 78 ++++++++++++++++++ pyproject.toml | 69 ++++++++++++++++ tests/__init__.py | 3 + 17 files changed, 242 insertions(+) create mode 100644 LICENSE.txt create mode 100644 README.md create mode 100644 cave_survival/__about__.py create mode 100644 cave_survival/__init__.py create mode 100644 cave_survival/__main__.py create mode 100644 cave_survival/__pycache__/__about__.cpython-310.pyc create mode 100644 cave_survival/__pycache__/__init__.cpython-310.pyc create mode 100644 cave_survival/__pycache__/console.cpython-310.pyc create mode 100644 cave_survival/__pycache__/run.cpython-310.pyc create mode 100644 cave_survival/assets/stev/1.png create mode 100644 cave_survival/assets/stev/2.png create mode 100644 cave_survival/cli/__init__.py create mode 100644 cave_survival/cli/__pycache__/__init__.cpython-310.pyc create mode 100644 cave_survival/console.py create mode 100644 cave_survival/run.py create mode 100644 pyproject.toml create mode 100644 tests/__init__.py 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 0000000000000000000000000000000000000000..6e5904e5bb91d0184197e8ef6afab3a356d2c2d9 GIT binary patch literal 198 zcmd1j<>g`kf(tTdk{1B!#~=7nm1UMC=J;tc-QtdqFH0>d&dkq?kH5u|mzbNnlA(whXaJb_WvQQ$pPQ;* zo>-ZapQoRmS)!i|G(oo*Y66%S59h_lCnn{Wmc+;F6;$5hu*uC&Da}c>1G%f11xTg`kf>+XKl8b@#V-N=!FakLaKwQiMBvKfH88jLFRx%WUgb~Cq3;m4z+*JMY z#LArfJpJ^{68+@FvQ*vT(xS4=vcw!PFCNZ|kI&4@EQycTE2zB1VUwGmQks)$2Qsmk J2}rOo004$DBR>ED literal 0 HcmV?d00001 diff --git a/cave_survival/__pycache__/console.cpython-310.pyc b/cave_survival/__pycache__/console.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0d063154da9010252aaf9d483e94be0200712d9e GIT binary patch literal 209 zcmd1j<>g`kf)}!9lFfkhV-N=!FabFZKwK;aBvKes7;_kM8KW2(8B!UW8KRg{n1UHJ znO_3s7&IAgu{-DI73b%q`e`yp@f2kyXXqtE1d2e$++v6FRx%W^0Qq3zm$`mMer~FM zd17Twex81MW{G}sVp*zgacNOmW?5nmm=}-WLCn)DsJz8tlbfGXnv-hB2sEo0WFQX% G7ZU&xvNSLN literal 0 HcmV?d00001 diff --git a/cave_survival/__pycache__/run.cpython-310.pyc b/cave_survival/__pycache__/run.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bdf7bbce9701a47174efa004be1fa7a4af20e029 GIT binary patch literal 1201 zcmaJ=&1=*^6rZnTXOnc*+7CVH(M9ai3RY08pjL`lEGj}kmbf!r(`K`2l5X8L0T13i zd&_$B;=!BXf8be=IVqlc_auJ3iCL`(PMDY9`@P@1c{4BRPfS<{#;LV;on?;DC+!>@ z1f0t-lPNF)2^=672_ondG zu+A#%5xR=*Te+248xAlNnUn+Z0(gz$5M;A68}Q-dD882&3~kgi^E@J`T`&0~ zz;{ZXS3EEIN#Ofq{o)_}QQ-H+`jY>phy2OYamETkjtc2juQQ(27E#VKF04%>ex^?} z&Lr$vRAnQ@lyLMdfzIAU@vDp!(;3Z-5y2>&EIn3vHh5$80TrB=6f?RLSv@%iU70Pr zf}oERt4-p+fqwg+p<%nzw}xG>Cr_^QyskWXvpYyZ;j`Xh96gQ5PnR4@=#>sh8J3?xst3miP6iwy&d2T8jRd<}qbPWjTuZ zp`WUn@RKO;hAxNg+r7S!uB}nWi&DQID#O=RD;D%U;qop-V%bR*ex&eF8FBz8Q50y! z(qSZBwsv>rj-s1#=-OHw#S+dXTzaFuqm8FcqK!~&-46nnJqY~NW$S?-DYmukr%gw( z#NU;wHm<=;I@hoKMG zXv0OhwW`t=D4quY%h}e$eowY`ykXD}TU|eG>2{s@-LAiz2dU^!OKR6-ZIVIl!f8{0zMr(OQli`V;X%FaH1l literal 0 HcmV?d00001 diff --git a/cave_survival/assets/stev/1.png b/cave_survival/assets/stev/1.png new file mode 100644 index 0000000000000000000000000000000000000000..29255ee25bf9b8d8604d5e6371e7260b58506f01 GIT binary patch literal 1280 zcmV+b1^@bqP)AE$6^me@v=v%)FnQ^Z(4-+rad8w}3l9D) zRvlcNb#-tR1i>E=R~IKm7b)?+q|hS93y=44-aUu+?gNB+nW<)A98fjONX27fHn$=M zU*SVPdJ({Y#7sSrUdX_+zV4};>MqK&y!-yFZY6Irz$X&VGTpF<*NLY$EuHf|ahR1P zh4`F!%%BSrKXP4m`HgeYVS#6cjZA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5fY0GH`~AsPXMTakEQHcY*NY5}z7E+7|#6M)Ratq9pL^)lxW zHV`X-Y0kAd`;H{dtfp(*$0CFT@W`5lnU4nj;(K!UH;%$eOp<2By&Oc6I0H2LV3L=9 zmkcEUuC?uB>nvDjfXsIe&j0|ICwsN#B#NQ9(V&k2K;8{1_b%}tX!JXWXQf1dJUa85 zbe-p@1pt8eubyLidm|=tK}gUXf^TaPz-8d8>FrHrFs8(3U}bgP+ej<^5Q;Nkd*JFG zMCtm<>N=87Z>%xaCAd7@E=6I}aRx5{59ECudA@2r7kPk>O$xE^P8UQ@o|5(hjcpAo0h#0?{ z3!Y2^!{4f1avsM70s}@PR~OB@s)v6XJ~)6y*9b3wHY%hSfOhnC?K{;QK-rY~0Oj2P z!6Yw1n7e{rU`2qt0x{<=n3D0u!PE+Nfv3gy(|12g*LXhF4D26K!m{aXyz7ix?wyO~ zW+fC49$KR~3i0^KwaUx|aP@Pe05Hw1006Mj`%*k8ra2##b{1$Uya0G|N_IVd*)bt~ zmV#of0Mf`^2{aHK+>}@cX5(G;np0A~G(4XPYpNisTXTutRMVNLT}v&1F9hZ6Xw0<$ z1ff|z%DrSWH>EY_$z3APh4%x#uvP${wRgp<0G4~_#m7`rbDy}%VWcJ3NR#Uq-)6+@ TJW@3100000NkvXXu0mjfM*d87 literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..f98bda4691d810bbce476d3504c35c91ba1e984a GIT binary patch literal 1069 zcmY*YOK%e~5MFz|uVnM+6Ocg4bq`7S0TluvxFD4SJ^5m7)^4(8U-EiW67@uT%`bpM zd*sJ(>bhytuD+Kv2@A95#@&3weBE+}&Hs4v9$C&RzoxOD}oA2{S7uGqVJ&ryY!Q*S_ z&^QcG?L>K2=7|8;lvQ?(As^tn&DdPXGR`x`YLbPisI7UJRHC+}P?gLgq${kK_JI)N zHGJh$FlUDJm2rs_{$gAqWGM5JTp6E%1OP{efh9FgZ51-kl(ZUOEeatidGje&0g?{n zz8SI&+s(mvmZxHT8ZMGN8&6|3j>5SZmX(~x&{Pw#e^C;T8H=-6F*Yg|b$|1aC`^(` z7=7$O%~ESckdItMZl%sFcV7*3*}CC3U(T+Szaj? zR9slWMwrR;o~{f&Sf~$qdq*ive(+#n}{I+|@YFx<+j^ zcOp&GW@-PP<>wHbA-SVq%+58#=n`|>a1Fz?&X`vQoRD*{4fEuXdQIJ_hQ!oMa%gmx zmnt6Z0|l+qFjjCh8jV0A4^PS!N@4-(>6U<|K5TMJ8?D)$ z@xiM}8phcZ@Jjtc;<=~=th>m@1j`*r1%0^^%mr$OxZg@Vy;&>ythG~V>=9)LJiB3|gpE;ZM# l=^`KdsE@ZzVq=7necQ4L)*eRWch@2};QhfizQIoa*IzY61ET-{ literal 0 HcmV?d00001 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