pygame-topdownengine 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. pygame_topdownengine-0.0.1/.github/workflows/release.yml +72 -0
  2. pygame_topdownengine-0.0.1/.gitignore +3 -0
  3. pygame_topdownengine-0.0.1/LICENSE +21 -0
  4. pygame_topdownengine-0.0.1/PKG-INFO +40 -0
  5. pygame_topdownengine-0.0.1/README.md +20 -0
  6. pygame_topdownengine-0.0.1/examples/LICENSE +121 -0
  7. pygame_topdownengine-0.0.1/examples/basic_usage.py +78 -0
  8. pygame_topdownengine-0.0.1/pygame_topdownengine.egg-info/PKG-INFO +40 -0
  9. pygame_topdownengine-0.0.1/pygame_topdownengine.egg-info/SOURCES.txt +31 -0
  10. pygame_topdownengine-0.0.1/pygame_topdownengine.egg-info/dependency_links.txt +1 -0
  11. pygame_topdownengine-0.0.1/pygame_topdownengine.egg-info/requires.txt +1 -0
  12. pygame_topdownengine-0.0.1/pygame_topdownengine.egg-info/top_level.txt +4 -0
  13. pygame_topdownengine-0.0.1/pyproject.toml +37 -0
  14. pygame_topdownengine-0.0.1/setup.cfg +4 -0
  15. pygame_topdownengine-0.0.1/tests/conftest.py +40 -0
  16. pygame_topdownengine-0.0.1/tests/test_math.py +25 -0
  17. pygame_topdownengine-0.0.1/tests/test_physics.py +57 -0
  18. pygame_topdownengine-0.0.1/topdownengine/__init__.py +10 -0
  19. pygame_topdownengine-0.0.1/topdownengine/asset_paths.py +7 -0
  20. pygame_topdownengine-0.0.1/topdownengine/assets/example-player/idle.png +0 -0
  21. pygame_topdownengine-0.0.1/topdownengine/assets/example-player/walk.png +0 -0
  22. pygame_topdownengine-0.0.1/topdownengine/assets/shadows/16x8.png +0 -0
  23. pygame_topdownengine-0.0.1/topdownengine/assets/shadows/32x16.png +0 -0
  24. pygame_topdownengine-0.0.1/topdownengine/assets/shadows/8x4.png +0 -0
  25. pygame_topdownengine-0.0.1/topdownengine/controls.py +109 -0
  26. pygame_topdownengine-0.0.1/topdownengine/env_object.py +33 -0
  27. pygame_topdownengine-0.0.1/topdownengine/game.py +75 -0
  28. pygame_topdownengine-0.0.1/topdownengine/game_object.py +269 -0
  29. pygame_topdownengine-0.0.1/topdownengine/math.py +27 -0
  30. pygame_topdownengine-0.0.1/topdownengine/mobile_obj/__init__.py +53 -0
  31. pygame_topdownengine-0.0.1/topdownengine/mobile_obj/controller.py +61 -0
  32. pygame_topdownengine-0.0.1/topdownengine/py.typed +0 -0
  33. pygame_topdownengine-0.0.1/topdownengine/visual_utils.py +138 -0
@@ -0,0 +1,72 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+
10
+ # ── Job 0: Build distributions ────────────────────
11
+ release-build:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+
16
+ - uses: actions/setup-python@v5
17
+ with:
18
+ python-version: "3.x"
19
+
20
+ - name: Build release distributions
21
+ run: |
22
+ python -m pip install build
23
+ python -m build
24
+
25
+ - name: Upload distributions
26
+ uses: actions/upload-artifact@v4
27
+ with:
28
+ name: release-dists
29
+ path: dist/
30
+
31
+ # ── Job 1: Publish to TestPyPI ────────────────────
32
+ test-pypi-publish:
33
+ runs-on: ubuntu-latest
34
+ needs: release-build
35
+ permissions:
36
+ id-token: write
37
+ environment:
38
+ name: testpypi
39
+ url: https://test.pypi.org/p/pygame-topdownengine
40
+ steps:
41
+ - name: Retrieve release distributions
42
+ uses: actions/download-artifact@v4
43
+ with:
44
+ name: release-dists
45
+ path: dist/
46
+
47
+ - name: Publish to TestPyPI
48
+ uses: pypa/gh-action-pypi-publish@release/v1
49
+ with:
50
+ repository-url: https://test.pypi.org/legacy/
51
+ packages-dir: dist/
52
+
53
+ # ── Job 2: Publish to PyPI ────────────────────────
54
+ pypi-publish:
55
+ runs-on: ubuntu-latest
56
+ needs: test-pypi-publish
57
+ permissions:
58
+ id-token: write
59
+ environment:
60
+ name: pypi
61
+ url: https://pypi.org/p/pygame-topdownengine
62
+ steps:
63
+ - name: Retrieve release distributions
64
+ uses: actions/download-artifact@v4
65
+ with:
66
+ name: release-dists
67
+ path: dist/
68
+
69
+ - name: Publish to PyPI
70
+ uses: pypa/gh-action-pypi-publish@release/v1
71
+ with:
72
+ packages-dir: dist/
@@ -0,0 +1,3 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shaurya Sharma
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,40 @@
1
+ Metadata-Version: 2.4
2
+ Name: pygame-topdownengine
3
+ Version: 0.0.1
4
+ Author: Shaurya Sharma
5
+ License-Expression: MIT
6
+ Classifier: Development Status :: 3 - Alpha
7
+ Classifier: Programming Language :: Python
8
+ Classifier: Programming Language :: Python :: 3.12
9
+ Classifier: Topic :: Games/Entertainment
10
+ Classifier: Operating System :: Microsoft :: Windows
11
+ Classifier: Operating System :: POSIX
12
+ Classifier: Operating System :: Unix
13
+ Classifier: Operating System :: MacOS
14
+ Classifier: Typing :: Typed
15
+ Requires-Python: >=3.12.10
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: pygame-ce>=2.5.7
19
+ Dynamic: license-file
20
+
21
+ # pygame-topdownengine
22
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue)](https://opensource.org)
23
+
24
+ pygame-topdownengine is a 2.5D engine for top-down games. It is designed to be highly modular, with most core systems being located in the easily extendible GameObject class. It is built on top of the pygame-ce package, which you can find here: https://github.com/pygame-community/pygame-ce/tree/main.
25
+
26
+ ## Features
27
+ - GameObject class that contains all of the core systems.
28
+ - Built-in MobileObj class for anything that moves.
29
+ - Option to use either pixel-perfect or subpixel rendering.
30
+ - Dynamic scale-setting for all GameObjects.
31
+ - Robust 3D collision detection.
32
+
33
+ ## Installation
34
+ In order to install pygame-topdownengine, make sure Python and pip are both installed and in PATH. Then, run this command into your terminal:<br>
35
+ `pip install pygame-topdownengine`
36
+
37
+ ## License
38
+ This library is distributed under the MIT license, which can be found in the root of this repository under the `LICENSE` file.
39
+
40
+ The source files located in the `examples` subfolder are licensed under the Creative Commons Zero 1.0 Universal license, which can be found inside of `examples/LICENSE`.
@@ -0,0 +1,20 @@
1
+ # pygame-topdownengine
2
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue)](https://opensource.org)
3
+
4
+ pygame-topdownengine is a 2.5D engine for top-down games. It is designed to be highly modular, with most core systems being located in the easily extendible GameObject class. It is built on top of the pygame-ce package, which you can find here: https://github.com/pygame-community/pygame-ce/tree/main.
5
+
6
+ ## Features
7
+ - GameObject class that contains all of the core systems.
8
+ - Built-in MobileObj class for anything that moves.
9
+ - Option to use either pixel-perfect or subpixel rendering.
10
+ - Dynamic scale-setting for all GameObjects.
11
+ - Robust 3D collision detection.
12
+
13
+ ## Installation
14
+ In order to install pygame-topdownengine, make sure Python and pip are both installed and in PATH. Then, run this command into your terminal:<br>
15
+ `pip install pygame-topdownengine`
16
+
17
+ ## License
18
+ This library is distributed under the MIT license, which can be found in the root of this repository under the `LICENSE` file.
19
+
20
+ The source files located in the `examples` subfolder are licensed under the Creative Commons Zero 1.0 Universal license, which can be found inside of `examples/LICENSE`.
@@ -0,0 +1,121 @@
1
+ Creative Commons Legal Code
2
+
3
+ CC0 1.0 Universal
4
+
5
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6
+ LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9
+ REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10
+ PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11
+ THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12
+ HEREUNDER.
13
+
14
+ Statement of Purpose
15
+
16
+ The laws of most jurisdictions throughout the world automatically confer
17
+ exclusive Copyright and Related Rights (defined below) upon the creator
18
+ and subsequent owner(s) (each and all, an "owner") of an original work of
19
+ authorship and/or a database (each, a "Work").
20
+
21
+ Certain owners wish to permanently relinquish those rights to a Work for
22
+ the purpose of contributing to a commons of creative, cultural and
23
+ scientific works ("Commons") that the public can reliably and without fear
24
+ of later claims of infringement build upon, modify, incorporate in other
25
+ works, reuse and redistribute as freely as possible in any form whatsoever
26
+ and for any purposes, including without limitation commercial purposes.
27
+ These owners may contribute to the Commons to promote the ideal of a free
28
+ culture and the further production of creative, cultural and scientific
29
+ works, or to gain reputation or greater distribution for their Work in
30
+ part through the use and efforts of others.
31
+
32
+ For these and/or other purposes and motivations, and without any
33
+ expectation of additional consideration or compensation, the person
34
+ associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35
+ is an owner of Copyright and Related Rights in the Work, voluntarily
36
+ elects to apply CC0 to the Work and publicly distribute the Work under its
37
+ terms, with knowledge of his or her Copyright and Related Rights in the
38
+ Work and the meaning and intended legal effect of CC0 on those rights.
39
+
40
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
41
+ protected by copyright and related or neighboring rights ("Copyright and
42
+ Related Rights"). Copyright and Related Rights include, but are not
43
+ limited to, the following:
44
+
45
+ i. the right to reproduce, adapt, distribute, perform, display,
46
+ communicate, and translate a Work;
47
+ ii. moral rights retained by the original author(s) and/or performer(s);
48
+ iii. publicity and privacy rights pertaining to a person's image or
49
+ likeness depicted in a Work;
50
+ iv. rights protecting against unfair competition in regards to a Work,
51
+ subject to the limitations in paragraph 4(a), below;
52
+ v. rights protecting the extraction, dissemination, use and reuse of data
53
+ in a Work;
54
+ vi. database rights (such as those arising under Directive 96/9/EC of the
55
+ European Parliament and of the Council of 11 March 1996 on the legal
56
+ protection of databases, and under any national implementation
57
+ thereof, including any amended or successor version of such
58
+ directive); and
59
+ vii. other similar, equivalent or corresponding rights throughout the
60
+ world based on applicable law or treaty, and any national
61
+ implementations thereof.
62
+
63
+ 2. Waiver. To the greatest extent permitted by, but not in contravention
64
+ of, applicable law, Affirmer hereby overtly, fully, permanently,
65
+ irrevocably and unconditionally waives, abandons, and surrenders all of
66
+ Affirmer's Copyright and Related Rights and associated claims and causes
67
+ of action, whether now known or unknown (including existing as well as
68
+ future claims and causes of action), in the Work (i) in all territories
69
+ worldwide, (ii) for the maximum duration provided by applicable law or
70
+ treaty (including future time extensions), (iii) in any current or future
71
+ medium and for any number of copies, and (iv) for any purpose whatsoever,
72
+ including without limitation commercial, advertising or promotional
73
+ purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74
+ member of the public at large and to the detriment of Affirmer's heirs and
75
+ successors, fully intending that such Waiver shall not be subject to
76
+ revocation, rescission, cancellation, termination, or any other legal or
77
+ equitable action to disrupt the quiet enjoyment of the Work by the public
78
+ as contemplated by Affirmer's express Statement of Purpose.
79
+
80
+ 3. Public License Fallback. Should any part of the Waiver for any reason
81
+ be judged legally invalid or ineffective under applicable law, then the
82
+ Waiver shall be preserved to the maximum extent permitted taking into
83
+ account Affirmer's express Statement of Purpose. In addition, to the
84
+ extent the Waiver is so judged Affirmer hereby grants to each affected
85
+ person a royalty-free, non transferable, non sublicensable, non exclusive,
86
+ irrevocable and unconditional license to exercise Affirmer's Copyright and
87
+ Related Rights in the Work (i) in all territories worldwide, (ii) for the
88
+ maximum duration provided by applicable law or treaty (including future
89
+ time extensions), (iii) in any current or future medium and for any number
90
+ of copies, and (iv) for any purpose whatsoever, including without
91
+ limitation commercial, advertising or promotional purposes (the
92
+ "License"). The License shall be deemed effective as of the date CC0 was
93
+ applied by Affirmer to the Work. Should any part of the License for any
94
+ reason be judged legally invalid or ineffective under applicable law, such
95
+ partial invalidity or ineffectiveness shall not invalidate the remainder
96
+ of the License, and in such case Affirmer hereby affirms that he or she
97
+ will not (i) exercise any of his or her remaining Copyright and Related
98
+ Rights in the Work or (ii) assert any associated claims and causes of
99
+ action with respect to the Work, in either case contrary to Affirmer's
100
+ express Statement of Purpose.
101
+
102
+ 4. Limitations and Disclaimers.
103
+
104
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
105
+ surrendered, licensed or otherwise affected by this document.
106
+ b. Affirmer offers the Work as-is and makes no representations or
107
+ warranties of any kind concerning the Work, express, implied,
108
+ statutory or otherwise, including without limitation warranties of
109
+ title, merchantability, fitness for a particular purpose, non
110
+ infringement, or the absence of latent or other defects, accuracy, or
111
+ the present or absence of errors, whether or not discoverable, all to
112
+ the greatest extent permissible under applicable law.
113
+ c. Affirmer disclaims responsibility for clearing rights of other persons
114
+ that may apply to the Work or any use thereof, including without
115
+ limitation any person's Copyright and Related Rights in the Work.
116
+ Further, Affirmer disclaims responsibility for obtaining any necessary
117
+ consents, permissions or other rights required for any use of the
118
+ Work.
119
+ d. Affirmer understands and acknowledges that Creative Commons is not a
120
+ party to this document and has no duty or obligation with respect to
121
+ this CC0 or use of the Work.
@@ -0,0 +1,78 @@
1
+ import topdownengine as tde
2
+ from topdownengine.mobile_obj.controller import KeyboardInputController, MovementAIController
3
+ from topdownengine.asset_paths import ASSETS_DIR
4
+ from topdownengine.math import scale_rect
5
+ import pygame as pg
6
+
7
+ # Define an instance of the Game class
8
+ game = tde.Game(
9
+ screen_width=900,
10
+ screen_height=650,
11
+ window_title="pygame-topdownengine Basic Usage Example"
12
+ )
13
+
14
+ # Define a MobileObj to be the Player
15
+ player = tde.MobileObj(
16
+ controller=KeyboardInputController(),
17
+ animation_paths={
18
+ 'idle': ASSETS_DIR / 'example-player' / 'idle.png',
19
+ 'walk': ASSETS_DIR / 'example-player' / 'walk.png'
20
+ },
21
+ frame_size=(16, 16),
22
+ directional_anims=True
23
+ )
24
+
25
+ # Define a MobileObj to follow the Player
26
+ enemy = tde.MobileObj(
27
+ controller=MovementAIController(target_mobile_obj=player),
28
+ animation_paths={
29
+ 'idle': ASSETS_DIR / 'example-player' / 'idle.png',
30
+ 'walk': ASSETS_DIR / 'example-player' / 'walk.png'
31
+ },
32
+ frame_size=(16, 16),
33
+ directional_anims=True
34
+ )
35
+
36
+ # Define an env_obj
37
+ env_obj = tde.EnvObject(frame_size=(32, 32), colliders=[pg.Rect(0, 0, 32, 32)])
38
+ env_obj.position = pg.Vector2(100, 100)
39
+ env_obj.obj_shadow = '32x16'
40
+
41
+ # Add them to the game object group
42
+ game.game_object_group.add(player)
43
+ game.game_object_group.add(env_obj)
44
+ game.game_object_group.add(enemy)
45
+
46
+ # Rescale GameObjects to have a SCALE of 3 (this makes them more visible)
47
+ tde.GameObject.set_scale(3, game)
48
+
49
+ # GameObj automatically generates a four frame "flashing animation."
50
+ # In order to disable it, this line of code makes it use only the first frame,
51
+ # which is solid red.
52
+ env_obj.animations = {'idle': [env_obj.animations['idle'][0]]}
53
+
54
+ # You can add subpixel rendering by uncommenting the below line of code
55
+ # tde.GameObject.SUBPIXEL = True
56
+
57
+ # Debug Rendering
58
+ # original_draw = game.render
59
+ # def new_render():
60
+ # original_draw()
61
+ # pg.draw.rect(
62
+ # game.screen,
63
+ # (0, 0, 255),
64
+ # scale_rect(mobile_obj.hitboxes[0], mobile_obj.SCALE),
65
+ # 1
66
+ # )
67
+ # pg.draw.rect(
68
+ # game.screen,
69
+ # (0, 0, 255),
70
+ # scale_rect(env_obj.hitboxes[0], env_obj.SCALE),
71
+ # 1
72
+ # )
73
+ # pg.display.flip()
74
+
75
+ # game.render = new_render
76
+
77
+ # Run the game
78
+ game.run()
@@ -0,0 +1,40 @@
1
+ Metadata-Version: 2.4
2
+ Name: pygame-topdownengine
3
+ Version: 0.0.1
4
+ Author: Shaurya Sharma
5
+ License-Expression: MIT
6
+ Classifier: Development Status :: 3 - Alpha
7
+ Classifier: Programming Language :: Python
8
+ Classifier: Programming Language :: Python :: 3.12
9
+ Classifier: Topic :: Games/Entertainment
10
+ Classifier: Operating System :: Microsoft :: Windows
11
+ Classifier: Operating System :: POSIX
12
+ Classifier: Operating System :: Unix
13
+ Classifier: Operating System :: MacOS
14
+ Classifier: Typing :: Typed
15
+ Requires-Python: >=3.12.10
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: pygame-ce>=2.5.7
19
+ Dynamic: license-file
20
+
21
+ # pygame-topdownengine
22
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue)](https://opensource.org)
23
+
24
+ pygame-topdownengine is a 2.5D engine for top-down games. It is designed to be highly modular, with most core systems being located in the easily extendible GameObject class. It is built on top of the pygame-ce package, which you can find here: https://github.com/pygame-community/pygame-ce/tree/main.
25
+
26
+ ## Features
27
+ - GameObject class that contains all of the core systems.
28
+ - Built-in MobileObj class for anything that moves.
29
+ - Option to use either pixel-perfect or subpixel rendering.
30
+ - Dynamic scale-setting for all GameObjects.
31
+ - Robust 3D collision detection.
32
+
33
+ ## Installation
34
+ In order to install pygame-topdownengine, make sure Python and pip are both installed and in PATH. Then, run this command into your terminal:<br>
35
+ `pip install pygame-topdownengine`
36
+
37
+ ## License
38
+ This library is distributed under the MIT license, which can be found in the root of this repository under the `LICENSE` file.
39
+
40
+ The source files located in the `examples` subfolder are licensed under the Creative Commons Zero 1.0 Universal license, which can be found inside of `examples/LICENSE`.
@@ -0,0 +1,31 @@
1
+ .gitignore
2
+ LICENSE
3
+ README.md
4
+ pyproject.toml
5
+ .github/workflows/release.yml
6
+ examples/LICENSE
7
+ examples/basic_usage.py
8
+ pygame_topdownengine.egg-info/PKG-INFO
9
+ pygame_topdownengine.egg-info/SOURCES.txt
10
+ pygame_topdownengine.egg-info/dependency_links.txt
11
+ pygame_topdownengine.egg-info/requires.txt
12
+ pygame_topdownengine.egg-info/top_level.txt
13
+ tests/conftest.py
14
+ tests/test_math.py
15
+ tests/test_physics.py
16
+ topdownengine/__init__.py
17
+ topdownengine/asset_paths.py
18
+ topdownengine/controls.py
19
+ topdownengine/env_object.py
20
+ topdownengine/game.py
21
+ topdownengine/game_object.py
22
+ topdownengine/math.py
23
+ topdownengine/py.typed
24
+ topdownengine/visual_utils.py
25
+ topdownengine/assets/example-player/idle.png
26
+ topdownengine/assets/example-player/walk.png
27
+ topdownengine/assets/shadows/16x8.png
28
+ topdownengine/assets/shadows/32x16.png
29
+ topdownengine/assets/shadows/8x4.png
30
+ topdownengine/mobile_obj/__init__.py
31
+ topdownengine/mobile_obj/controller.py
@@ -0,0 +1,4 @@
1
+ dist
2
+ examples
3
+ tests
4
+ topdownengine
@@ -0,0 +1,37 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0.0", "setuptools-scm>=8.0.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "pygame-topdownengine"
7
+ version = "0.0.1"
8
+ authors = [
9
+ { name = "Shaurya Sharma" }
10
+ ]
11
+ requires-python = ">=3.12.10"
12
+ dependencies = [
13
+ "pygame-ce>=2.5.7",
14
+ ]
15
+ readme = "README.md"
16
+ license = "MIT"
17
+ license-files = ["LICENSE"]
18
+ classifiers = [
19
+ "Development Status :: 3 - Alpha",
20
+ "Programming Language :: Python",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Topic :: Games/Entertainment",
23
+ "Operating System :: Microsoft :: Windows",
24
+ "Operating System :: POSIX",
25
+ "Operating System :: Unix",
26
+ "Operating System :: MacOS",
27
+ "Typing :: Typed"
28
+ ]
29
+
30
+ [tool.setuptools]
31
+ packages = { find = {} }
32
+ include-package-data = true
33
+
34
+ [tool.setuptools.package-data]
35
+ "*" = ["py.typed", "assets/**/*"]
36
+
37
+ [tool.setuptools_scm]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,40 @@
1
+ # Copyright (c) 2026 Shaurya Sharma
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ import pygame as pg
5
+ import pytest
6
+ import topdownengine as tde
7
+ from topdownengine.mobile_obj.controller import KeyboardInputController
8
+ from topdownengine.asset_paths import ASSETS_DIR
9
+ from topdownengine.controls import MoreKeysPressed
10
+
11
+ # Fixtures
12
+ @pytest.fixture
13
+ def game():
14
+ game = tde.Game(1, 1)
15
+ print('Initializing game instance.')
16
+ yield game
17
+ pg.quit()
18
+
19
+ @pytest.fixture
20
+ def mobile_obj():
21
+ return tde.MobileObj(
22
+ controller=KeyboardInputController(),
23
+ animation_paths={
24
+ 'idle': ASSETS_DIR / 'example-player' / 'idle.png',
25
+ 'walk': ASSETS_DIR / 'example-player' / 'walk.png'
26
+ },
27
+ frame_size=(16, 16),
28
+ directional_anims=True
29
+ )
30
+
31
+ # This code "monkey patches" pygame-ce to replace get_pressed with a custom
32
+ # function that allows us to add/remove fake keys to the stream by
33
+ # adding/removing them from the FAKED_KEYS set.
34
+ FAKED_KEYS = set()
35
+ original_get_pressed = pg.key.get_pressed
36
+
37
+ def fake_get_pressed():
38
+ return MoreKeysPressed(original_get_pressed(), FAKED_KEYS)
39
+
40
+ pg.key.get_pressed = fake_get_pressed
@@ -0,0 +1,25 @@
1
+ # Copyright (c) 2026 Shaurya Sharma
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ from topdownengine import math as tde_math
5
+ import pytest
6
+
7
+ LERP_TEST_ARGS = [
8
+ [5, 8], # P->P
9
+ [1, -7], # P->N
10
+ [5, 0], # P->0
11
+ [-8, 5], # N->P
12
+ [-5, -10], # N->N
13
+ [-7, 0], # N->0
14
+ [0, 7], # 0->P
15
+ [0, -6], # 0->N
16
+ [0, 0], # 0->0
17
+ ]
18
+
19
+ @pytest.mark.parametrize("start, end", LERP_TEST_ARGS)
20
+ def test_lerp_with_t_0_equals_start(start, end):
21
+ assert tde_math.lerp(start, end, 0) == start
22
+
23
+ @pytest.mark.parametrize("start, end", LERP_TEST_ARGS)
24
+ def test_lerp_with_t_1_equals_end(start, end):
25
+ assert tde_math.lerp(start, end, 1) == end
@@ -0,0 +1,57 @@
1
+ # Copyright (c) 2026 Shaurya Sharma
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ import os
5
+
6
+ # Set dummy drivers before importing pygame
7
+ os.environ["SDL_VIDEODRIVER"] = "dummy"
8
+ os.environ["SDL_AUDIODRIVER"] = "dummy"
9
+
10
+ import topdownengine as tde
11
+ import pytest
12
+ import pygame as pg
13
+ from conftest import FAKED_KEYS
14
+
15
+ # Jump Tests
16
+ def test_can_jump_while_grounded(game: tde.Game, mobile_obj: tde.MobileObj):
17
+ mobile_obj.elevation = mobile_obj.z = 0
18
+ mobile_obj.jump()
19
+ assert mobile_obj.z_vel == mobile_obj.jump_vel
20
+
21
+ def test_cannot_jump_while_airborne(game: tde.Game, mobile_obj: tde.MobileObj):
22
+ mobile_obj.elevation = 0
23
+ mobile_obj.z = 10
24
+ mobile_obj.jump()
25
+ assert mobile_obj.z_vel != mobile_obj.jump_vel
26
+
27
+ # 2D Movement Tests
28
+ MOVEMENT_TEST_ARGS = [
29
+ pg.Vector2(1, 0), # Right
30
+ pg.Vector2(0, 1), # Down
31
+ pg.Vector2(-1, 0), # Left
32
+ pg.Vector2(0, -1), # Up
33
+ pg.Vector2(1, 1), # Down-Right
34
+ pg.Vector2(1, -1), # Up-Right
35
+ pg.Vector2(-1, 1), # Down-Left
36
+ pg.Vector2(-1, -1) # Up-Left
37
+ ]
38
+ @pytest.mark.parametrize("dir", MOVEMENT_TEST_ARGS)
39
+ def test_movement(game: tde.Game, mobile_obj: tde.MobileObj, dir: pg.Vector2):
40
+ def step(key, condition):
41
+ FAKED_KEYS.clear()
42
+ FAKED_KEYS.add(key)
43
+ game.handle_events()
44
+ mobile_obj.update(60, game)
45
+ assert eval(condition)
46
+
47
+ if dir.x == 1:
48
+ step(pg.K_d, 'mobile_obj.velocity.x > 0')
49
+
50
+ elif dir.x == -1:
51
+ step(pg.K_a, 'mobile_obj.velocity.x < 0')
52
+
53
+ if dir.y == 1:
54
+ step(pg.K_s, 'mobile_obj.velocity.y > 0')
55
+
56
+ elif dir.y == -1:
57
+ step(pg.K_w, 'mobile_obj.velocity.y < 0')
@@ -0,0 +1,10 @@
1
+ # Copyright (c) 2026 Shaurya Sharma
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ """pygame-topdownengine is a game engine built on top of the pygame-ce
5
+ framework. It allows for the quick creation of 2.5D top-down games."""
6
+
7
+ from .game import Game
8
+ from .game_object import GameObject
9
+ from .mobile_obj import MobileObj
10
+ from .env_object import EnvObject
@@ -0,0 +1,7 @@
1
+ # Copyright (c) 2026 Shaurya Sharma
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ from pathlib import Path
5
+
6
+ PACKAGE_ROOT = Path(__file__).resolve().parent
7
+ ASSETS_DIR = PACKAGE_ROOT / "assets"