GithubHelp home page GithubHelp logo

kaaengine / kaa Goto Github PK

View Code? Open in Web Editor NEW
18.0 7.0 9.0 28.08 MB

KAA - Pythonic game engine for humans.

Home Page: https://kaa.readthedocs.io/

License: MIT License

CMake 0.82% Python 42.62% C++ 2.08% Shell 0.53% Cython 53.94%
python3 gamedev game-engine-2d game-engine

kaa's Introduction

kaa

KAA - Pythonic game engine for humans

Installation

From PyPI:

pip install kaaengine

From repository (with pip):

pip install 'git+https://github.com/kaaengine/kaa'

From cloned repository:

git clone --recursive https://github.com/kaaengine/kaa && cd kaa
python setup.py install

Debug build:

git clone --recursive https://github.com/kaaengine/kaa && cd kaa
python setup.py install --build-type Debug

Documentation

https://kaa.readthedocs.io/

Changelog

See CHANGELOG file.

kaa's People

Contributors

labuzm avatar maniek2332 avatar pawelroman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

kaa's Issues

Setting text node text to whitespace causes a crash

  1. Create new TextNode, add it to scene
  2. on update, set the node text to ' ' (single whitespace character)

Expected: whitespace rendered i.e. node not visible
Actual: engine crashing with

error File "fonts.pxi", line 65, in kaa._kaa.TextNode.text.set
kaa._kaa.KaacoreError: D:\a\1\s\kaacore\src\shapes.cpp:27 !(classify_polygon(this->bounding_points) == PolygonType::convex_ccw) - Invalid shape - expected convex counterclockwise polygon.

Enhance mouse input

Need more input features from mouse:

  1. mouse central button pressed/released
  2. mouse wheel up/down
  3. other mouse buttons (if available)

Transitions for camera

Please add camera transitions, to autoamte stuff like camera going to position (x, y) or camera zooming in / out, or camera rotating or a combination of any of the three.

Method for finding nodes at given x,y position

I want to be able to get a list of nodes under position (x, y).

A classical scenario is someone clicks a mouse and we want to know node(s) that he clicked. There can be many overlapping nodes in that (x, y) so it'd be nice to get a sorted list.

IMPORTANT: enhance the query_shape_overlaps

query_shape_overlaps function needs the same hitbox filtering set of params like hitboxes have

I mean: group, mask and collision_mask

They would represent the property of colliding shape (passed as parameter).

The logic would be identical like with colliding hitboxes.

The default values would also be identical like with hitboxes.

My brain is bleeding every time I call query_shape_overlaps(), knowing that it's trying to match passed shape with every hitbox on the scene! It's killing da performance of my game! Plus it's returning results I'm not even interested in!

Set node lifeteme

When adding a node to scene I should have ability to set a lifetime of this node, after that time elapsed the node should autodelete and be removed from scene.

Also it would be super useful if I had a way to know that deletion is happening (so I can react and do something extra)

Very useful for scenarios like:

  • explosions
  • flying debris (which disappear after 2 seconds, and show small animation when they disappear)
  • etc.

Text node: updating text causing crash

Kaaengine build v. 0.11+75.gbc2555f

Add Text node and on keyboard text event we try to update text node's text. When we do that, engine crashes with

Traceback (most recent call last):
  File "/home/pawel/Dev/gates-of-valhalla/demos/text_typing/main.py", line 34, in <module>
    engine.run(MyScene())
  File "engine.pxi", line 100, in kaa._kaa._Engine.run
kaa._kaa.KaacoreError: /host/kaacore/src/draw_unit.cpp:212 !(draw_unit_it != this->draw_units.end()) - Target draw unit not found, end of draw units vector reached.

Code to replicate the issue:

import logging
from logging import DEBUG

from kaa.fonts import TextNode
from kaa.geometry import Vector
from kaa.engine import Engine

from scenes.base import SceneBase

logging.basicConfig(level=DEBUG, format="%(levelname)s | %(asctime)s | %(module)s:%(lineno)d | %(message)s")


class MyScene(SceneBase):

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.text_node = TextNode(font_size=40, text="", position=Vector(200, 200))
        self.root.add_child(self.text_node)

    def update(self, dt):
        for event in self.input.events():
            if event.keyboard_text:
                self.text_node.text = event.keyboard_text.text


if __name__ == "__main__":

    with Engine(virtual_resolution=Vector(1800, 900)) as engine:

        engine.window.size = Vector(1800, 900)
        engine.window.fullscreen = False
        engine.window.title = "Text typing"
        engine.window.center()
        engine.run(MyScene())

Collision queries

Expose active querying for chipmunk collisions to python layer.

Function should accept a shape (segment, circle, polygon etc.) and return a list of tuples (colliding_node, colliding_hitboxes) where colliding node should be actual node instance that colides and hitboxes should be hitboxes (can be more than one) belonging to that node which collided.

spatial_index.query_point not working correctly for nodes which start hidden and then are shown

  1. Create a node X with a child node Y (both should have some sprites set), make sure that the node has visible=False, i.e. is hidden
  2. Add node X to scene
  3. On update() set visible=True on node X and change it's position (both need to happen during the same frame!). Then let the app run and on any subsequent update run spatial_index.query_point() on a point where node Y is showing up.

Expected: query_point should return the node Y
Actual: query_point does not return the node Y

Attaching an example here: query_point.zip

Steps to replicate:

  1. Press space bar to show previously hidden node
  2. Click on newly shown child node (green area)

Expected - Child node is returned by query_point
Actual - it is not returned!!

spatial index queries return Nodes outside view's rendering area

Steps to replicate:

  1. Have a view that renders stuff only in specific area e.g. 100x100 box in the middle of the screen
  2. Add some nodes to that view in such position that those nodes are outside the view's render area ie. do not appear on the screen
  3. Run scene.spatial_index.query_point on a point OUTSIDE view's render arena, but where the node is.

Expected: node is not get returned (as it is outside view's render area)
Actual: node is returned

Suggestion: add a flag to all spatial query methods to allow to explicitly query for nodes outside of the view's render area. But by default that flag should be disabled - queries should return only the nodes in the render area of the view.

Ray-casting ability

Engine needs ability to query for HitboxNodes intersecting a Segment instance.

Currently it's not possible to efficiently calculate if there is a clean line of fire for a unit in a top-down shooting game.

Playing sound effects in a loop, with ability to interrupt it at any moment

Suppose I have a short sfx file which is designed to be played in a loop - it is a sound of footsteps.

As player moves the character around the screen I want that footsteps sound to be played in a loop. When player stops moving (which can be in the middle of the loop) I want the sfx to stop playing immediately.

Please add support for this use case.

Ability to get node's absolute position, rotation, scale

We need a way to access node's absolute values for all transformations such as position, rotation or scale.

If node is a child (any levels of depth in the tree) those methods should return absolute values of given transformation.

Ability to hide mouse cursor and show custom cursor (as Node)

Suggested API:

Add MouseManager.cursor property. Make it read/write.

Default value is None. None value works like now - shows system cursor.

MouseManager.cursor accepts a Node instance. When setting it to a Node, system cursor is hidden, replaced with image shown by the node. origin_alignment of the node should set the active 'pixel' of the node (the pixel whose position is 'click' position). It should be possible for this node to have transitions, animations and other normal features of a Node.

Expose chipmunk joints to python

This is super big topic.

Currently kaa's tree-like node structure creates an illusion that any given node in the structure can interact physically. However it is not possible, a Hitbox must be directly under BodyNode and must be directly under Space node.

In other words, visual representation of the scene in kaa is a tree-like structure while physical representation of the scene must be a flat list of BodyNodes assigned to Space.

This leads to a problem when we want physical structure to be a chain of connected objects.

The solution to this problem is to create a flat list of BodyNodes connected with chipmunk joints. This is more understandable for programmers.

Kaa users will need to understand that kaa's node tree is applicable only for visual purpose, i.e. when nodes somewhere deep down in the tree won't need hitboxes. If a node deep down the tree structure needs a HitboxNode, it means you should not have used a tree at all! You should have built this object as a series of peer BodyNodes connected with joints.

Kaa engine is crashing when audio device is not present in the system!

Ocurred on windows 10 which suffered from audio device malfunction - apparently no drivers for the sound card or other issue resulting in an issue with no audio device present in the system.

The crash ocurred when trying to load music (calling Music() constructor)

Stack trace of the error:

Traceback (most recent call last):

File "main.py", line 74, in

File "controllers\assets_controller.py", line 20, in init

File "audio.pxi", line 30, in kaa._kaa.Music.init

kaa._kaa.KaacoreError: ......\kaacore\src\audio.cpp:140 !(raw_music != nullptr)

Populate window.size with a value from engine.virtual_resolution

engine.virtual_resolution is always required when starting the whole show.

window.size is not

Currently the default value for window.size is unknown. Looks like hardcoded something but it doesn't make sense. It should initialize with a value identical to engine.virtual_resolution until changed programatically.

do not call the collision handler function for deleted nodes

If any of the colliding body nodes got deleted, don't call the collision handler function.

It leads to error "node already marked for deletion" when node.delete() is being called from within the collision handler and the deleted node collided with two other nodes in the same frame.

Add error handling when creating objects outside engine context

When creating an bject such as Font, Sprite, etc. outside engine context engine crashes silently with no error message. Please add a validation and a meaningful error message.

Instantiating new objects, especially assets happens just once and does not affect game performance so it deserves a proper validations.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.