Jank Engine
Python game engine using Pyglet and Pymunk.
Installation
Install with pip:
python -m pip install -U jank
Install development version:
python -m pip install -U git+https://github.com/LennyPhoenix/Jank-Engine.git
Trello Roadmap
Basic Example
import jank # Import the engine
class Application(jank.Application):
PHYSICS_STEPS = 5 # Turn this up to increase simulation accuracy.
PLAYER_SPEED = 200
PLAYER_JUMP = 500
def __init__(self):
# Initialise the application
super().__init__(debug_mode=True, show_fps=True)
# Set the space's gravity
self.physics_space.gravity = (0, -1000)
# Create controls dictionary
self.controls = {
"left": False,
"right": False
}
# Create the floor
self.floor = jank.Entity(
position=(0, -325),
body_type=jank.Entity.STATIC,
collider=jank.colliders.Rect(
width=950,
height=50
)
)
self.floor.space = self.physics_space
# Create the player object. Note that the Entity class can be subclassed.
self.player = jank.Entity(
position=(0, 0),
collider=jank.colliders.Rect(
width=100,
height=100
)
)
self.player.space = self.physics_space
# Called every 1/120 of a second. (Note this can occasionally be inaccurate.)
def on_fixed_update(self, dt: float):
# Step the physics simulation forwards.
for _ in range(self.PHYSICS_STEPS):
self.physics_space.step(dt/self.PHYSICS_STEPS)
# Set the player's X velocity.
vx = 0
if self.controls["left"]:
vx -= self.PLAYER_SPEED
if self.controls["right"]:
vx += self.PLAYER_SPEED
self.player.velocity = (vx, self.player.velocity.y)
# Jump when the W key is pressed and the player is grounded.
def on_key_press(self, button, modifiers):
if button == jank.key.W and self.player.grounded:
self.player.body.apply_impulse_at_local_point(
(0, self.PLAYER_JUMP)
)
# Called as frequently as possible.
def on_update(self, dt: float):
# Update controls dict
self.controls = {
"left": self.key_handler[jank.key.A],
"right": self.key_handler[jank.key.D]
}
# Instantiate and run the application.
if __name__ == "__main__":
application = Application()
application.run()
Metadata
Release files for jank 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| jank-0.1.1.tar.gz | 17.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jank-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 41.8 kB
Release files / jank-0.1.1.tar.gz
| Download URL | jank-0.1.1.tar.gz |
|---|---|
| Size | 17.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2e3d3665d171fa299bdae7c1edd65ec2edafbc0b0bca571c0e67f6a7c59f83d4
|
|
BLAKE2b-256 checksum How to use checksums |
9a601cacf7c9d64a0ffec60d59fa95993630041de6aa872a19aecf1baa455f55
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
|
Release files / jank-0.1.1-py3-none-any.whl
| Download URL | jank-0.1.1-py3-none-any.whl |
|---|---|
| Size | 24.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
88b1431c46e5f4c794b89f6777d9fbdae6708b524ed3c7cb60ac4292a08dff5c
|
|
BLAKE2b-256 checksum How to use checksums |
5d1813f11c79263b082e334fb43d6adc8b44676b7bbfac1b5ced13aea11c935c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
|