Shkyera Engine
Easy to use, game engine for Python
shkyera::Python Namespace Reference

Typedefs

typedef void(* eventHandler) (py::list)
 

Enumerations

enum  Event : int {
  LOG_INFO , LOG_ERROR , LOG_SUCCESS , LOG_VERBOSE ,
  DRAW_LINE , DRAW_CIRCLE , DRAW_RECTANGLE , DRAW_CLEAR ,
  TOTAL_EVENTS
}
 Enum representing different types of events that can be processed in Python. More...
 
enum  PYTHON_TYPE : int { INT = 0 , FLOAT = 1 , STRING = 2 , TOTAL_TYPES = 3 }
 Enum representing different types that can be used in Python. More...
 

Functions

void setRenderer (std::shared_ptr< Renderer > renderer)
 Set the renderer to be used for drawing in Python. More...
 
template<typename T >
std::vector< T > parsePayload (py::list payload)
 Template function to parse a payload from a Python list into a C++ vector. More...
 
template<Event event>
void processEvent (py::list payload)
 Function to process an event of a specific type. More...
 
template<>
void processEvent< LOG_INFO > (py::list payload)
 
template<>
void processEvent< LOG_ERROR > (py::list payload)
 
template<>
void processEvent< LOG_SUCCESS > (py::list payload)
 
template<>
void processEvent< LOG_VERBOSE > (py::list payload)
 
template<>
void processEvent< DRAW_LINE > (py::list payload)
 
template<>
void processEvent< DRAW_CIRCLE > (py::list payload)
 
template<>
void processEvent< DRAW_RECTANGLE > (py::list payload)
 
template<>
void processEvent< DRAW_CLEAR > (py::list payload)
 
void setInterpreterRenderer (std::shared_ptr< Renderer > renderer)
 Set the renderer to use for the Python interpreter. More...
 
void runEvents ()
 
void setPublicVariables (py::object object, std::shared_ptr< ScriptComponent > script)
 
void initialize ()
 
void runGame ()
 
void startImplicit ()
 
void start ()
 Start the Python interpreter and initialize the Python environment. More...
 
void allowRunning ()
 Allow the Python environment to run. More...
 
void stop ()
 Stop the Python interpreter and finalize the Python environment. More...
 
bool isRunning ()
 Check if the Python environment is running. More...
 
void resetPressedButtons ()
 Resets the set of pressed buttons by the user. More...
 
void addPressedButton (std::string key)
 Add the pressed key to the set, so that the user can interact with it from Python script. More...
 
std::vector< std::pair< std::string, PYTHON_TYPE > > getPublicVariables (std::string scriptName)
 Function to get a list of public variables and their types from a Python script. More...
 

Variables

std::shared_ptr< Renderer_eventRenderer
 
std::mutex runningMutex
 
std::mutex inputMutex
 
std::vector< std::string > _pressedButtons
 
bool _currentlyRunning = false
 
bool _canRun = false
 
py::object _game
 
py::object _eventSystem
 
py::object _inputSystem
 
std::shared_ptr< Renderer_renderer
 
std::array< eventHandler, TOTAL_EVENTS_eventHandlers
 
const std::string MODULE = "src.python.shkyera."
 The Python module prefix for shkyera. More...
 
std::unordered_map< std::string, PYTHON_TYPE_mapPythonTypes = {{"int", INT}, {"float", FLOAT}, {"str", STRING}}
 

Typedef Documentation

◆ eventHandler

typedef void(* shkyera::Python::eventHandler) (py::list)

Enumeration Type Documentation

◆ Event

Enum representing different types of events that can be processed in Python.

Enumerator
LOG_INFO 

Log an informational message.

LOG_ERROR 

Log an error message.

LOG_SUCCESS 

Log a success message.

LOG_VERBOSE 

Log a verbose message.

DRAW_LINE 

Draw a line using the renderer.

DRAW_CIRCLE 

Draw a circle using the renderer.

DRAW_RECTANGLE 

Draw a rectangle using the renderer.

DRAW_CLEAR 

Clear the renderer.

TOTAL_EVENTS 

The total number of events.

◆ PYTHON_TYPE

Enum representing different types that can be used in Python.

Enumerator
INT 

Integer type.

FLOAT 

Float type.

STRING 

String type.

TOTAL_TYPES 

The total number of supported types.

Function Documentation

◆ addPressedButton()

void shkyera::Python::addPressedButton ( std::string  key)

Add the pressed key to the set, so that the user can interact with it from Python script.

Parameters
keyPressed key

◆ allowRunning()

void shkyera::Python::allowRunning ( )

Allow the Python environment to run.

◆ getPublicVariables()

std::vector< std::pair< std::string, PYTHON_TYPE > > shkyera::Python::getPublicVariables ( std::string  scriptName)

Function to get a list of public variables and their types from a Python script.

Parameters
scriptNameThe name of the Python script to inspect.
Returns
A vector of pairs, where each pair contains a variable name and its associated type.

◆ initialize()

void shkyera::Python::initialize ( )

◆ isRunning()

bool shkyera::Python::isRunning ( )

Check if the Python environment is running.

Returns
True if the Python environment is running, false otherwise.

◆ parsePayload()

template<typename T >
std::vector< T > shkyera::Python::parsePayload ( py::list  payload)

Template function to parse a payload from a Python list into a C++ vector.

Parameters
payloadA Python list containing data.
Returns
A C++ vector of the parsed data.

◆ processEvent()

template<Event event>
void shkyera::Python::processEvent ( py::list  payload)

Function to process an event of a specific type.

Parameters
eventThe type of event to process.
payloadA Python list containing event-specific data.

◆ processEvent< DRAW_CIRCLE >()

template<>
void shkyera::Python::processEvent< DRAW_CIRCLE > ( py::list  payload)

◆ processEvent< DRAW_CLEAR >()

template<>
void shkyera::Python::processEvent< DRAW_CLEAR > ( py::list  payload)

◆ processEvent< DRAW_LINE >()

template<>
void shkyera::Python::processEvent< DRAW_LINE > ( py::list  payload)

◆ processEvent< DRAW_RECTANGLE >()

template<>
void shkyera::Python::processEvent< DRAW_RECTANGLE > ( py::list  payload)

◆ processEvent< LOG_ERROR >()

template<>
void shkyera::Python::processEvent< LOG_ERROR > ( py::list  payload)

◆ processEvent< LOG_INFO >()

template<>
void shkyera::Python::processEvent< LOG_INFO > ( py::list  payload)

◆ processEvent< LOG_SUCCESS >()

template<>
void shkyera::Python::processEvent< LOG_SUCCESS > ( py::list  payload)

◆ processEvent< LOG_VERBOSE >()

template<>
void shkyera::Python::processEvent< LOG_VERBOSE > ( py::list  payload)

◆ resetPressedButtons()

void shkyera::Python::resetPressedButtons ( )

Resets the set of pressed buttons by the user.

◆ runEvents()

void shkyera::Python::runEvents ( )

◆ runGame()

void shkyera::Python::runGame ( )

◆ setInterpreterRenderer()

void shkyera::Python::setInterpreterRenderer ( std::shared_ptr< Renderer renderer)

Set the renderer to use for the Python interpreter.

Parameters
rendererA shared pointer to a Renderer object.

◆ setPublicVariables()

void shkyera::Python::setPublicVariables ( py::object  object,
std::shared_ptr< ScriptComponent script 
)

◆ setRenderer()

void shkyera::Python::setRenderer ( std::shared_ptr< Renderer renderer)

Set the renderer to be used for drawing in Python.

Parameters
rendererA shared pointer to the renderer.

◆ start()

void shkyera::Python::start ( )

Start the Python interpreter and initialize the Python environment.

◆ startImplicit()

void shkyera::Python::startImplicit ( )

◆ stop()

void shkyera::Python::stop ( )

Stop the Python interpreter and finalize the Python environment.

Variable Documentation

◆ _canRun

bool shkyera::Python::_canRun = false

◆ _currentlyRunning

bool shkyera::Python::_currentlyRunning = false

◆ _eventHandlers

std::array<eventHandler, TOTAL_EVENTS> shkyera::Python::_eventHandlers

◆ _eventRenderer

std::shared_ptr<Renderer> shkyera::Python::_eventRenderer

◆ _eventSystem

py::object shkyera::Python::_eventSystem

◆ _game

py::object shkyera::Python::_game

◆ _inputSystem

py::object shkyera::Python::_inputSystem

◆ _mapPythonTypes

std::unordered_map<std::string, PYTHON_TYPE> shkyera::Python::_mapPythonTypes = {{"int", INT}, {"float", FLOAT}, {"str", STRING}}

◆ _pressedButtons

std::vector<std::string> shkyera::Python::_pressedButtons

◆ _renderer

std::shared_ptr<Renderer> shkyera::Python::_renderer

◆ inputMutex

std::mutex shkyera::Python::inputMutex

◆ MODULE

const std::string shkyera::Python::MODULE = "src.python.shkyera."

The Python module prefix for shkyera.

◆ runningMutex

std::mutex shkyera::Python::runningMutex