KivEnt by Kovak

KivEnt

A 2d Game Engine for Kivy

Download as .zip Download as .tar.gz View on GitHub

High Performance Kivy Games

KivEnt is a collection of Cython accelerated widgets for the Kivy Framework designed to make it easier to create performant 2d games. The main goal for KivEnt was to be able to render many hundreds or even thousands of sprites to the screen without the user having to deal with any of the complexities involved in using OpenGL. Every renderer in KivEnt batches the drawing of its entities into a single draw call, and the assembly for the call is done entirely in a Cython optimized loop with all data being pulled from underlying C structures; KivEnt's renderers spend essentially no time on python overhead, freeing up precious time for your gameloop. All testing is currently performed on an Asus Transformer TF101, which is a Tegra2 device. KivEnt is able to maintain 60 fps with several hundred sprites on screen, and several hundred objects active in the Cymunk space on the Transformer.

KivEnt has grown to include physics and collision detection, provided by Chipmunk2d (through cymunk), and a custom particle engine designed to be compatible with the .pex file format produced by editors such as Particle Panda. Plans for the near future include an efficient and generalized projectile system, as many games that go for a 'bullet-hell' style cannot afford to perform these calculations in Python, and an AI system for steering behaviors, for similar calculation intensive reasons. Although not difficult to build yourself, a default Animation system will be coming as well.

Let's Talk More About Performance

I have built KivEnt to target 60 fps on relatively old Android hardware (Tegra2) with several hundred objects in scene at a time. I think this is more than enough to create the majority of 2d games that target this type of hardware. That being said, KivEnt is a Game Engine for Python, and focuses on being easy to use and quick to develop with over pushing the limits of technology. For some real numbers from my test app:

Of the .016 seconds we've got to get everything done and maintain 60 fps, roughly .005 of the frame time is spent on Kivy's drawing internals, .002 on handling touch input, .003 on KivEnt's internals to update the physics world, update particles, and render everything. This leaves .006 seconds for your game logic. It may not seem like that much, but there is plenty of time to get things done, and double the time KivEnt's critical systems take. Plus, if you do need to go faster than Python will allow, you can switch your code to Cython and every built in Component has already been implemented as a Cython Extension Class, allowing you to easily access and write to the underlying C data in Cython by appending a '_' to the Component's attribute name.

Getting Started

KivEnt has just reached its first public release and the project is really in need of some early adopter feedback :) That being said, it has been in active development for over a year and I do not expect the basic API for rendering, physics, or particle systems to change that much at this point. You can find the documentation here. For many games that just want to display rectangular sprites and make use of circle and box collisions, I think you will find that KivEnt can already save you much time. You can find the bare minimum application (some of the system loads are extraneous but intended to demonstrate setting up these systems until more tutorials can be produced) to render something to screen here. A more comprehensive run down can be found on the wiki.

What Type of Game is KivEnt For?

The engine has really been built to favor action heavy, pixel art games that use 2d physics. Even if you don't need physics, if you have a large number of interactable objects, or a need for polygon collision detection, the speed and efficiency of Chipmunk is unbeatable for the low, low price of not writing a performant collision detection library yourself. If you are only displaying a handful of sprites to your screen, or you have a fairly abstract game like 2048, KivEnt might not do enough for you over just using Kivy itself to justify the added complexity. If you plan on building a semi-demanding 2d game in Python, and you don't want to get bogged down in the technical details, I hope you will consider trying KivEnt.

Contact Info:

You can contact me at kovac1066@gmail.com or find me in Kivy's irc channel where I am kovak. On reddit, I'm JKovac.