TUI-based game engine in Python. Use this little thing to make awesome games right into your terminal.
All you need to do is install this module as you usual do.
$ pip install kikanLet's cover all essential things you will use for your game.
TODO
This is main component a game is built from. Any interactable object in your game is Entity. Entities use several default methods to use engine's capabilities.
from kikan import engine
from kikan.entity import Entity
from kikan.math import Vector
class Player(Entity):
def on_pre_update(self, dt: float):
...
def on_update(self, dt: float):
...
def on_collision(self, other: Entity):
...
def on_input(self, key: str):
...
p = Player(Vector(0, 0), "P") # position and texture
engine.start() # at the very end of the fileSometimes you want to manage some variables or display something but you don't need a whole entity with the physics and all that stuff. Then use MetaEntity. Such classes don't have to be initialized.
TODO
TODO
TODO
There are two ways to implement this. Signals let you subscribe a function to some kind of event. When that event happens (signal emits), the subscribers are called. If you want something to contain payload then use states. State is a cell with value that you can update and affect functions that depend on this state.
States
hp = State(10) # you have to pass an initial value
class StatManager(MetaEntity):
@hp.affects # subscribe the method to the state
def update_hearts():
render_hearts(hp.get()) # get the current value from the state
hp.set(9) # change the current valueSignals
on_hit = Signal() # define a signal in scope your entities can reach
class Player(Entity):
@on_hit # use it as a decorator to mark subscribers
def dec_hp(self):
self.hp -= 1
p = Player()
class Enemy(Entity):
def on_collision(self, other):
if other is p:
on_hit.emit() # emit the signal to trigger subscribed functionsSo you want to contibute to this package... Let's prepare environment:
- Make a fork and clone the repo.
- Install package as editable.
- Use
toxto test and run other useful scenarios. - (VS Code) Install recommended extensions to follow the code style. Make sure you have installed
mypyin your system if you want to check static typing on save .
What about tools?
- Use
ruffto lint your code - Use
blackto format your code - Use
mypyto check static typing in your code
All this you can do with tox.