Game Systems

Most of these Classes have cdefed functions that cannot be read by Sphinx. Read the source if you want to find out more about using them.

Python GameSystems

This is the base for creating a GameSystem usable from python. It will store the components in a python list and allow dynamic control of your components data as it is just a python object. These type of GameSystem do not store their memory as contiguously as the more optimized game systems but are perfectly suitable for prototyping or game systems that simply do not do that much processing.

class kivent_core.systems.gamesystem.GameSystem(**kwargs)

GameSystem is the part of your game that holds the logic to operate on the data of your Entity’s components. It will also manage assembling, cleaning up, storing, and destroying the components holding system data. The basic GameSystem keeps track of Component, which is a regular Python object supporting all the dynamic nature of python but without many static optimizations. The basic setup is that we will create a Component object and release them for garbage collection when the entity is done. We will avoid resizing the components list by reusing space in the list (a component will be cleared to None when removed and an internal free list will provide these spaces before growing the list).

Attributes:

system_id (StringProperty): Name of this gamesystem, used to name entity component attribute, and refer to system.

system_index (NumericProperty): The integer index of the GameSystem in the SystemManager array. Corresponds to where in the entity array you will find this system’s component_index.

updateable (BooleanProperty): Boolean to let gameworld know whether or not to run an update tick on this gamesystem. Defaults to False

paused (BooleanProperty): Boolean used to determine whether or not this system should be updated on the current tick, if updateable is True

gameworld (ObjectProperty): Reference to the gameworld object, usually bound in kv

gameview (StringProperty): Name of the GameView this system will be rendered too. If set to None the system will instead be rendered to GameWorld’s canvas. The default value is None

update_time (NumericProperty): The ‘tick’ rate of this system’s update. Defaults to 1./60. or 60 FPS

components (list): a list of the components currently active. If the list contains None at an index that component has been recently released for GC and a free list is being maintained internally. Skip these values during processing.

frame_time (float): Leftover time from the last update, not consumed yet.

do_allocation (BooleanProperty): Determines whether GameWorld should run the allocate function of the GameSystem during GameWorld allocation.

do_components (BooleanProperty): Indicates whether the GameSystem will actually have components and thus have a slot reserved for storing the component in the EntityManager array.

zones (ListProperty): Determines which zones will be present in the GameSystem’s memory allocation. Unused in the default GameSystem implementation.

allocate(self, Buffer master_buffer, dict reserve_spec)

Override this function if your GameSystem desires to make static allocation of some data to be kept for the lifetime of the GameSystem.

Args:

master_buffer (Buffer): The buffer that this system will allocate itself from.

reserve_spec (dict): A key value pairing of zone name (str) to be allocated and desired counts for number of entities in that zone.

clear_component(self, component_index)

Override this function if we must cleanup the component in some way before destroying or reusing it.

copy_component(self, unsigned int entity_id, unsigned int component_index)
create_component(self, unsigned int entity_id, str zone, args)

Typically called by GameWorld automatically as part of creating an Entity. If you would like to dynamically add a component you should call directly.

Args:

entity_id (unsigned int) : The identity of the Entity to assign this component to.

zone (str) : Not used in the basic GameSystem but used by other systems which use the IndexedMemoryZone.

args (dict) : dictionary of the arguments for component initialization

Return:
component_index (unsigned int) : The identity (location) of the new component.
get_component(self, zone)

This function is used internally to determine whether to add a new spot onto our list or use one of the existing free slots. Typically you will not need to call or work with it directly unless you are designing a custom memory management for your components.

Return:
component_id (unsigned int): The index of the newly generated component.
init_component(self, component_index, entity_id, zone, args)

Override this function to provide custom logic for setting up your component, by default each key, val pair of args will be setattr on the component.

on_add_system(self)

Function called when a system is added during a gameworld state change

on_delete_system(self)

Function called when a system is deleted by gameworld

on_gameview(self, instance, value)

Event that handles the adding of this widget to the appropriate parent if gameview is set.

on_remove_system(self)

Function called when a system is removed during a gameworld state change

remove_component(self, unsigned int component_index)

Typically this will be called automatically by GameWorld. If you want to remove a component without destroying the entity call this function directly. If you want to override the behavior of component cleanup override clear_component instead. Only override this function if you are working directly with the storage of components for your system.

Args:
component_index (unsigned int): the component_id to be removed.
update(self, dt)
Args:
dt (float): time argument passed in by Clock. Should be equivalent to update_time.

Override this function to create your gamesystems update logic typically looks like:

gameworld = self.gameworld
entities = gameworld.entities
for component in self.components:
    #make sure to skip released components.
    if component is not None:
        #If we need other components from the entity let us
        #retrieve it like this:
        entity_id = component.entity_id
        entity = entities[entity_id]
        #Do your system logic per entity here
class kivent_core.systems.gamesystem.Component

A component will keep track of the data for your GameSystems logic. It keeps track of its own identity (index in the components list), and the entity_id of its entity. If the entity_id returned is <unsigned int>-1 the component is not currently attached to an entity

Attributes:
_id (unsigned int): The identity of this component

Cython GameSystems

StaticMemGameSystem and MemComponent are the basis for all built in GameSystems. They are cythonic classes that store their data in raw C arrays allocated using the custom memory management designed for pooling and contiguous processing found in the memory_handlers modules.

class kivent_core.systems.staticmemgamesystem.StaticMemGameSystem

The StaticMemGameSystem keeps a statically allocated array of C structs as its components. The allocation is split out into several different ‘zones’. This is done to help you ensure all entities of a certain type are processed roughly in order. The StaticMemGameSystem’s components will also be pooled. All components will be created once and reused as often as possible. It will not be possibleto create more components in a zone than specified by the zone configuration. This class should not be used directly but instead inherited from to create your own GameSystem that makes use of the static, memory pooling features. This class should never be inherited from in Python as you will need Cython/C level access to various attributes and the components.

Attributes:

size_of_component_block (int): Internally the memory will be broken down into blocks of size_of_component_block kibibytes. Defaults to 4.

type_size (int): Number of bytes for the type. Typically you will set this with sizeof(YourCStruct).

component_type (MemComponent): The object that will make your C structcomponent’s data accessible from python. Should inherit from MemComponent.

processor (BooleanProperty): If set to True, the system will allocate a helper object ZonedAggregator to make it easier to batch process all the system’s components in your update function. Defaults to False.

system_names (ListProperty): Names of the other component systems to be bound by the ZonedAggregator, this should be a list of other StaticMemGameSystem system_id that you will need the component data from during your update function

do_allocation (BooleanProperty): Defaults to True for StaticMemGameSystem as we expect an allocation phase.

components (IndexedMemoryZone): Instead of the simple python list, components are stored in the more complex IndexedMemoryZone which supports both direct C access to the underlying struct arrays and python level access to the component_type objects that wrap the C data.

allocate(self, Buffer master_buffer, dict reserve_spec)

Allocates an IndexedMemoryZone from the buffer provided following the zone_name, count pairings in reserve_spec. The IndexedMemoryZone will be stored internally on the C extension imz_components attribute, it is accessible in python through the components property. If processor is True a ZonedAggregator will also be allocated. This stores void pointers to the various components of the entity based on the system_names provides in system_names. This makes it easier to retrieve various component data for processing.

Args:

master_buffer (Buffer): The buffer that this syscdtem will allocate itself from.

reserve_spec (dict): A key value pairing of zone name (str) to be allocated and desired counts for number of entities in that zone.

clear_component(self, unsigned int component_index)

Not implemented for StaticMemGameSystem, override when subclassing. Use this function to setup the clearing of a component’s values for recycling

clear_entities(self)
get_component(self, str zone)

Overrides GameSystem’s default get_component, using IndexedMemoryZone to handle component data instead. clear_component will be called prior to returning the new index of the component ensuring no junk data is present.

Return:
unsigned int: The index of the newly generated component.
get_size_estimate(self, dict reserve_spec)

Returns an estimated size, safe to call before calling allocate. Used internally by GameWorld to estimate if enough memory is available to support the GameSystem

Return:
int: estimated size in bytes of the system’s allocations.
get_system_size(self)

Returns the actual size being taken up by system data. Does not include python objects, just the various underlying arrays holding raw component data, and other memories allocated by this GameSystem. Must be called after allocate.

Return:
int: size in bytes of the system’s allocations.
init_component(self, unsigned int component_index, unsigned int entity_id, args)

Not implemented for StaticMemGameSystem, override when subclassing. Use this function to setup the initialization of a component’s values.

remove_component(self, unsigned int component_index)

Overrides the default behavior of GameSystem, passing data handling duties to the IndexedMemoryZone. clear_component will be called prior to calling free_slot on the MemoryZone.

class kivent_core.systems.staticmemgamesystem.MemComponent

The base for a cdef extension that will work with the MemoryBlock memory management system. The data do not live inside the MemComponent, it just provide a python accessible interface for working with the raw C structs holding the data. Will store a pointer to the actual data, and the index of the slot. All of the Python accessible C optimized components (and the Entity class) inherit from this class.

Attributes: (Cython Access Only)

pointer (void*): Pointer to the location in the provided memory_block that this component’s data resides in.

_id (unsigned int): Index of this component in the overall component memory. Will usually be locate in MemoryBlock + offset of MemoryBlock in the MemoryPool.

Aggregators

The Aggregator classes make it easier to write the logic for a GameSystem’s update loop. Rather than having to fetch the components yourself from each GameSystem MemoryBlock, you can instead expend a little more memory and store an array of pointers to the appropriate components for your processing.

This expends a little more memory, and adds a layer of indirection but makes it significantly easier to write the update loop in cython.

class kivent_core.systems.staticmemgamesystem.ZonedAggregator

ZonedAggregator provides a shortcut for processing data from several components. A single contiguous array of void pointers is allocated, respecting the zoning of memory for the IndexedMemoryZone. It is not accessible from Python, this class is meant to be used only from Cython and allow you to deal directly with pointers to memory. Unintended uses could result in dangling pointers. You will be responsible for correctly casting the result while executing the system logic. If you remove a component from your entity that is being tracked by the Aggregator, you must remove and readd the entity to the Aggregator or it will have a bad reference.

Attributes (Cython Access Only):

count (unsigned int): The number of systems being tracked by this aggregator.

total (unsigned int): The number of entitys data can be collected from summing all zones. The actual number of pointers being tracked is total * count

entity_block_index (dict): Stores the actual location of the entity in the Aggregator as keyed by the entity_id.

system_names (list): The systems that components will be retrieved from per entity.

memory_block (ZonedBlock): The actual container of the pointer data. Access via memory_block.data

gameworld (object): Reference to the GameWorld for access to entities and system_manager.

class kivent_core.systems.staticmemgamesystem.ComponentPointerAggregator

ComponentPointerAggregator provides a shortcut for processing data from several components. A single contiguous array of void pointers is allocated. It is not accessible from Python, this class is meant to be used only from Cython and allow you to deal directly with pointers to memory. Unintended uses could result in dangling pointers. You will be responsible for correctly casting the result while executing the system logic. If you remove a component from your entity that is being tracked by the Aggregator, you must remove and readd the entity to the Aggregator or it will have a bad reference.

Attributes (Cython Access Only):

count (unsigned int): The number of systems being tracked by this aggregator.

total (unsigned int): The number of entitys data can be collected from summing all zones. The actual number of pointers being tracked is total * count

entity_block_index (dict): Stores the actual location of the entity in the Aggregator as keyed by the entity_id.

system_names (list): The systems that components will be retrieved from per entity.

memory_block (MemoryBlock): The actual container of the pointer data. Access via memory_block.data

gameworld (object): Reference to the GameWorld for access to entities and system_manager.

Position Systems

class kivent_core.systems.position_systems.PositionComponent2D

The component associated with PositionSystem2D.

Attributes:

entity_id (unsigned int): The entity_id this component is currently associated with. Will be <unsigned int>-1 if the component is unattached.

x (float): The x position of the center of the entity.

y (float): The y position of the center of the entity.

pos (tuple): A tuple of the (x, y) position.

class kivent_core.systems.position_systems.PositionSystem2D

PositionSystem2D abstracts 2 dimensional position data out into its own system so that all other GameSystem can interact with the position of an Entity without having to know specifically about dependent systems such as the CymunkPhysics system or any other method of determining the actual position. This GameSystem does no processing of its own, just holding data.

clear_component(self, unsigned int component_index)
init_component(self, unsigned int component_index, unsigned int entity_id, str zone, args)

A PositionComponent2D is initialized with an args tuple of (x, y).

Rotate Systems

class kivent_core.systems.rotate_systems.RotateComponent2D

The component associated with RotateSystem2D.

Attributes:

entity_id (unsigned int): The entity_id this component is currently associated with. Will be <unsigned int>-1 if the component is unattached.

r (float): The rotation around center of the entity.

class kivent_core.systems.rotate_systems.RotateSystem2D

RotateSystem2D abstracts 2 dimensional rotation data out into its own system so that all other GameSystem can interact with the rotation of an Entity without having to know specifically about dependent systems such as the CymunkPhysics system or any other method of determining the actual rotation. This GameSystem does no processing of its own, just holding data.

Typically other GameSystems will interpret this rotation as being a rotation around the center of the entity.

clear_component(self, unsigned int component_index)
init_component(self, unsigned int component_index, unsigned int entity_id, str zone, float r)

A RotateComponent2D is always initialized with a single float representing a rotation in degrees.

Scale Systems

class kivent_core.systems.scale_systems.ScaleComponent2D

The component associated with ScaleSystem2D.

Attributes:

entity_id (unsigned int): The entity_id this component is currently associated with. Will be <unsigned int>-1 if the component is unattached.

s (float): The arithmetic average of the x scale and y scale, when set the x scale and y scale will be set to the value provided. Useful if you want uniform scaling in both axes.

sx (float): The x axis scaling of the entity.

sy (float): The y axis scaling of the entity.

class kivent_core.systems.scale_systems.ScaleSystem2D

ScaleSystem2D abstracts 2 dimensional scale data out into its own system so that all other GameSystem can interact with the scale factor of an Entity without having to know specifically about dependent systems actually controlling the scale. This GameSystem does no processing of its own, just holding data.

clear_component(self, unsigned int component_index)
init_component(self, unsigned int component_index, unsigned int entity_id, str zone, args)

A ScaleComponent2D can be initialized with either a separate scaling factor for x axis and y axis or a single scaling factor for both. If args is a tuple sx will be args[0] and sy will be args[1], otherwise sx = sy = args.

Color Systems

class kivent_core.systems.color_systems.ColorComponent

The component associated with ColorSystem.

Attributes:

entity_id (unsigned int): The entity_id this component is currently associated with. Will be <unsigned int>-1 if the component is unattached.

r (unsigned char): The red channel, 0 to 255.

g (unsigned char): The green channel, 0 to 255.

b (unsigned char): The blue channel, 0 to 255.

a (unsigned char): The alpha channel, 0 to 255.

rgba (tuple): 4-tuple of unsigned ints (r,g,b,a)

rgb (tuple): 3-tuple of unsigned ints (r,g,b)

class kivent_core.systems.color_systems.ColorSystem

ColorSystem abstracts color data out into its own system so that all other GameSystem can interact with the color of an Entity without having to know about whatever system is controlling the actual color the entity. It is suitable for controlling a color that is applied over the whole model of an entity tinting its texture or coloring every vertex.

This GameSystem does no processing of its own, just holding data.

clear_component(self, unsigned int component_index)
init_component(self, unsigned int component_index, unsigned int entity_id, str zone, args)

A color component is always initialized with a tuple (r, g, b, a).

Rendering Systems

class kivent_core.systems.renderers.RenderComponent

The component associated with various renderers including: Renderer and RotateRenderer. Designed for 2d sprites, but potentially useful for other types of models as well. If not using for sprites, ignore width, height, and texture_key properties as they are designed for convenience when working with textured quads. Prefer instead to modify the properties of the vert_mesh directly.

Attributes:

entity_id (unsigned int): The entity_id this component is currently associated with. Will be <unsigned int>-1 if the component is unattached.

width (float): The width of the sprite.

height (float): The height of the sprite.

batch_id (unsigned int): The batch the entity is assigned to. Read Only. If the entity is not currently batched will be <unsigned int>-1.

attribute_count (unsigned int): The number of attributes in the vertex format for the model.

texture_key (str): The name of the texture for this component. If there is no texture None will be returned.

render (bool): Whether or not this entity should actually be rendered.

vertex_count (unsigned int): The number of vertices in the current model (the vert_mesh). You should not modify the number of vertices while an entity is batched.

index_count (unsigned int): The number of indices in the current model (the vert_mesh). You should not modify the number of indices while an entity is batched.

vert_mesh (VertMesh): The actual VertMesh object containing the model information for this component.

class kivent_core.systems.renderers.Renderer(**kwargs)

Processing Depends On: PositionSystem2D, Renderer

The basic KivEnt renderer draws with the VertexFormat4F:

ctypedef struct VertexFormat4F:
    GLfloat[2] pos
    GLfloat[2] uvs

Entities will be batched into groups of up to maximum_vertices, if they can share the source of texture. This GameSystem is only dependent on its own component and the PositionComponent2D.

If you want a static renderer, set frame_count to 1 and updateable to false.

Attributes:

shader_source (StringProperty): Path to the .glsl to be used, do include ‘.glsl’ in the name. You must ensure that your shader matches your vertex format or you will have problems.

maximum_vertices (NumericProperty): The maximum number of vertices that will be placed in a batch.

attribute_count (NumericProperty): The number of attributes each vertex will contain. Computed automatically inside calculate_vertex_format.

vertex_format (dict): describes format of data sent to shaders, generated automatically based on do_rotate, do_scale, do_color

blend_factor_source (NumericProperty): Sets the Blend Source. for a visual exploration of this concept visit : http://www.andersriggelsen.dk/glblendfunc.php Options Include: GL_SRC_ALPHA, GL_ONE, GL_ZERO, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA, GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR

blend_factor_dest (NumericProperty): Sets the Blend Dest. See blend_factor_sourc for more details.

reset_blend_factor_source (NumericProperty): The blend source will be reset to this after drawing this canvas. See blend_factor_source for more details.

reset_blend_factor_dest (NumericProperty): The blend dest will be reset to this after drawing this canvas. See blend_factor_source for more details.

smallest_vertex_count (NumericProperty, should be int): Used to estimate the number of entities that can fit in each batch at max, batch ComponentPointerAggregator will then be size_of_batches // smallest_vertex_count * vertex_format_size.

max_batches (NumericProperty, should be int): The maximum number of space to reserve for this renderer. Will be max_batches * frame_count * size_of_batches.

size_of_batches (NumericProperty): Size in kibibytes of each batch.

vertex_format_size (NumericProperty): The size in bytes of the vertex_format to be used. Will typically be the result of calling sizeof on the struct being used.

frame_count (NumericProperty, should be int): The number of frames to multibuffer.

force_update (BooleanProperty): Set force_update if you want to be sure an Entity is drawn immediately upon being added instead of waiting for the next update tick. Useful if you want to have a static renderer, or if you are adding and removing an Entity every frame.

static_rendering (BooleanProperty): Set static_rendering to True, if you do not want to redraw every Entity every frame. Usually used in combination with force_update = True.

update_trigger (function): Invoke update_trigger if you want to force the renderer to redraw a frame. force_update = True will call update_trigger automatically on batching and unbatching of an Entity.

Attributes: (Cython Access Only)

attribute_count (unsigned int): The number of attributes in the VertMesh format for this renderer. Defaults to 4 (x, y, u, v).

batch_manager (BatchManager): The BatchManager that is responsible for actually submitting vertex data to the GPU.

allocate(self, Buffer master_buffer, dict reserve_spec)
batch_entity(self, unsigned int entity_id)

Python accessible function for batching the entity, the real work is done in the cdefed _batch_entity.

Args:
entity_id (unsigned int): The id of the entity to unbatch.
clear_component(self, unsigned int component_index)
get_size_estimate(self, dict reserve_spec)
get_system_size(self)
init_component(self, unsigned int component_index, unsigned int entity_id, str zone_name, args)

A RenderComponent is initialized with an args dict with many optional values.

Optional Args:

texture (str): If ‘texture’ is in args, the appropriate texture will be loaded from managers.resource_managers.texture_manager. #change to model_key vert_mesh_key (str): If ‘vert_mesh_key’ is in args, the associated model from managers.resource_managers.model_manager will be loaded. Otherwise, it will be assumed we are rendering a sprite and the appropriate model for that sprite will either be generated or loaded from the model_manager if it already exists. If this occurs the models name will be str(attribute_count) + texture_key.

size (tuple): If size is provided and there is no ‘vert_mesh_key’ and the sprite has not been loaded before the size of the newly generated sprite VertMesh will be set to (width, height).

render (bool): If ‘render’ is in args, the components render attribute will be set to the provided, otherwise it defaults to True.

Keep in mind that all RenderComponent will share the same VertMesh if they have the same vert_mesh_key or load the same sprite.

on_shader_source(self, instance, value)

Event that sets the canvas.shader.source property when the shader_source property is set

remove_component(self, unsigned int component_index)
unbatch_entity(self, unsigned int entity_id)

Python accessible function for unbatching the entity, the real work is done in the cdefed _unbatch_entity.

Args:
entity_id (unsigned int): The id of the entity to unbatch.
update(self, force_update, dt)

Update function where all drawing of entities is performed. Override this method if you would like to create a renderer with customized behavior. The basic logic is that we iterate through each batch getting the entities in that batch, then iterate through the vertices in the RenderComponent.vert_mesh, copying every vertex into the batches data and combining it with data from other components.

Args:
dt (float): The time elapsed since last update, not usually used in rendering but passed in to maintain a consistent API.
class kivent_core.systems.renderers.RotateRenderer

Processing Depends On: PositionSystem2D, RotateSystem2D, RotateRenderer

The renderer draws with the VertexFormat7F:

ctypedef struct VertexFormat7F:
    GLfloat[2] pos
    GLfloat[2] uvs
    GLfloat rot
    GLfloat[2] center

This renderer draws every entity with rotation data suitable for use with entities using the CymunkPhysics GameSystems.

update(self, force_update, dt)
class kivent_core.systems.renderers.ColorRenderer

Processing Depends On: PositionSystem2D, ColorSystem, ColorRenderer

The renderer draws with the VertexFormat8F:

ctypedef struct VertexFormat8F:
    GLfloat[2] pos
    GLfloat[2] uvs
    GLubyte[4] v_color
update(self, force_update, dt)
class kivent_core.systems.renderers.RotateColorRenderer

Processing Depends On: PositionSystem2D, RotateSystem2D, ColorSystem, RotateColorRenderer

The renderer draws with the VertexFormat7F4UB:

ctypedef struct VertexFormat7F:
    GLfloat[2] pos
    GLfloat[2] uvs
    GLfloat rot
    GLfloat[2] center
    GLubyte[4] v_color

This renderer draws every entity with rotation data suitable for use with entities using the CymunkPhysics GameSystems.

update(self, force_update, dt)
class kivent_core.systems.renderers.PolyRenderer

Processing Depends On: PositionSystem2D, PolyRenderer

The renderer draws with the VertexFormat2F4UB:

ctypedef struct VertexFormat2F4UB:
    GLfloat[2] pos
    GLubyte[4] v_color
update(self, force_update, dt)
class kivent_core.systems.renderers.ColorPolyRenderer

Processing Depends On: PositionSystem2D, ColorSystem, ColorPolyRenderer

The renderer draws with the VertexFormat2F4UB:

ctypedef struct VertexFormat2F4UB:
    GLfloat[2] pos
    GLubyte[4] v_color
update(self, force_update, dt)
class kivent_core.systems.renderers.ScaledPolyRenderer

Processing Depends On: PositionSystem2D, PolyRenderer

The renderer draws with the VertexFormat2F4UB:

ctypedef struct VertexFormat2F4UB:
    GLfloat[2] pos
    GLubyte[4] v_color
update(self, force_update, dt)

Controlling the Viewing Area

class kivent_core.systems.gameview.GameView(**kwargs)

GameView provides a simple camera system that will control the rendering view of any other GameSystem that has had the gameview property set GameSystem that have a gameview will be added to the GameView canvas instead of the GameWorld canvas.

Attributes:

do_scroll_lock (BooleanProperty): If True the scrolling will be locked to the bounds of the GameWorld’s currentmap.

camera_pos (ListProperty): Current position of the camera

camera_scale (NumericProperty): Current scale of the camera. The scale is equal to the amount of the game world that will be shown compared to the physical size of the GameView, therefore 2x will show twice as much of your gameworld, appearing ‘zoomed out’, while .5 will show half as much of the gameworld, appearing ‘zoomed in’.

camera_rotate (NumericProperty): Current angle in radians by which the camera is rotated clockwise with respect to the world x-axis. Every time this value is updated, the rotation takes place about the center of the screen.

focus_entity (BooleanProperty): If True the camera will follow the entity set in entity_to_focus

do_scroll (BooleanProperty): If True touches will scroll the camera

entity_to_focus (NumericProperty): Entity entity_id for the camera to focus on if focus_entity is True.

camera_speed_multiplier (NumericProperty): Time it will take camera to reach focused entity, Speed will be 1.0/camera_speed_multiplier seconds to close the distance

render_system_order (ListProperty): List of system_id in the desired order of rendering last to first. GameSystem with system_id not in render_system_order will be inserted at position 0.

move_speed_multiplier (NumericProperty): Multiplier to further control the speed of touch dragging of camera. Example Usage: Bind to the size of your gameview divided by the size of the window to ensure that apparent dragging speed stays consistent.

do_touch_zoom (BooleanProperty): If True the camera will zoom with 2 finger touch interaction.

scale_min (NumericProperty): The minimum scale factor that will be allowed when touch zoom is being used. This will be the most ‘zoomed in’ your camera will be allowed to go. This limit do not apply when manually manipulated camera_scale.

scale_max (NumericProperty): The maximum scale factor that will be allowed when touch zoom is being used. This will be the most ‘zoomed out’ your camera will be allowed to go. This limit do not apply when manually manipulated camera_scale.

add_widget(self, widget)
collide_point(self, x, y)
convert_from_screen_to_world(self, pos)

Converts the coordinates of pos from screen space to camera space

convert_to_rotated_space(self, point, invert=False)

Convert a point from normal to rotated space and back using the invert parameter

get_camera_center(self)

Returns the current center point of the cameras view

get_camera_centered(self, map_size, camera_size, camera_scale)
lock_scroll(self, float distance_x, float distance_y)
look_at(self, pos)

Set the camera to be focused at pos.

on_entity_to_focus(self, instance, value)
on_size(self, instance, value)
on_touch_down(self, touch)
on_touch_move(self, touch)
on_touch_up(self, touch)
remove_widget(self, widget)
update(self, dt)
update_render_state(self)

Used internally by gameview to update the projection matrix to properly reflect the settings for camera_size, camera_pos, and the pos and size of gameview.

class kivent_core.systems.gamemap.GameMap

GameMap is a basic implementation of a map size for your GameWorld that limits the scrolling of GameView typically a GameMap does not actually have any entities, it simply holds some data and logic for use by other GameSystems

Attributes:

map_size (ListProperty): Sets the size of this map, used to determine scrolling bounds. If the map size is smaller than the window it will be centered inside the window.

margins (ListProperty): The amount of scrolling beyond the size of the map in x, y directions to be allowed. If the map is smaller than the window. This value is calculated automatically.

default_margins (ListProperty): The amount of margin if the map is larger than the window, defaults to (0, 0) which means no scrolling beyond edge of GameMap.