An Introduction to KivEnt

Josh edited this page Apr 8, 2017 · 27 revisions

KivEnt is a Game Engine designed for the Kivy Framework

Get Started with KivEnt:


Visit the docs

Short Introduction

With KivEnt, your game will be made up of 4 main types of objects:

  • GameWorld - Orchestrates Entities and GameSystems
  • Entities - Associates Components
  • Components - Holds data for GameSystem
  • GameSystems - Operates/Processes data in Components

The GameWorld

GameWorld is responsible for managing your game, driving the update loop, generating entities, and managing the state of the GameSystem that perform your game logic. Your game will sit entirely in the GameWorld widget and that widget can be placed inside other Kivy widgets as normal, in this way you can embed the game part of your application in a larger Kivy application.


Internally an Entity is literally a contiguous entry of N unsigned integers in an array of unsigned integers. Each of these integers describes the location of the component associated with the GameSystem given that index. When working with your entities in Python it will appear to you as an object. The entity_id of an entity is its position in the overall entity array. When a component is inactive its identity in the array will be -1, which is 4,294,967,295. This means that theoretically there is a limit to the number of entities or components in your game at 4,294,967,295. However, in practice I do not think anyone will hit this limit.


Components are the objects that hold the per-entity data of each system. The built-in components are mostly actually C-level structs, however a python object based on the MemComponent object is provided for python manipulation of your data. Components can always be retrieved by indexing into the components object of a GameSystem. The Entity object provides dot lookup of components by GameSystem name (the system_id StringProperty). When writing a C-level system you will most likely want one of the Aggregator classes (ZonedAggregator or ComponentPointerAggregator) to make it easier to access the data you need in a succinct level.


GameSystems perform all the logic in your game, they operate on the data held inside components. Every GameSystem shares some attributes and functions to make it easier to manage :

  • system_id : a string name used to identify the system throughout your program
  • updateable : boolean determining whether or not your GameWorld should try to update this system when its update tick is called
  • paused : boolean telling GameWorld whether to update this system at this particular time
  • gameworld : Your GameSystem will access all entities and other systems through the gameworld, usually I bind my gameworld to this property inside the kv file.
  • update_time : this is the tick rate at which you want your GameSystem to update defaults to (1./60.) (60 times a second). This allows you to set individual systems to update slower or faster (multiple times an update loop) than the GameWorld update rate. Remainder frame time will be held over and consumed when possible so that your simulation does not "lose" time.
  • components, the object that contains all the Component objects for the GameSystem. Iterate with a memory_handlers.memrange object in python.
  • update function, where the GameSystems per frame logic will occur.
  • create_component function, this is the function that handles turning the initialization logic into the actual game data.
  • remove_component function, this is where we can perform any cleanup needed on component data.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.