Usage and info
At the moment, this is my pet project and it is still in development. He will participate in other projects when he stops being a bit raw. But I don't think anyone is interested in this, so I'll go to the documentation.
Multi-lang readme - Russian
Opportunities
As it says in the description, it can render .gif, .jpg, and .png. The drawing takes place relative to the coordinates set in the function. It supports asynchronous operation and rendering of several images or GIFs at once.
Functions
initEngine- Initializes the engine, creates a window and a renderer. Please add it to your code before using it.
void initEngine(const char* title, int width, int height);
title: Window title (not used for a window without a frame).width: The width of the window.height: The height of the window.
cleanupEngine- Just cleans up the memory and shuts down, at the end of the code there should be
void cleanupEngine();
renderImage- Renders an image on the screen
void renderImage(const char* imagePath, int x, int y);
ImagePath: The path to the image.x: The X coordinate of the upper-left corner.y: The Y coordinate of the upper-left corner.
renderRectangle- Will draw a rectangle on the screen, but why not
void renderRectangle(int x, int y, int width, int height, unsigned int color);
x: The X coordinate of the upper-left corner.y: The Y coordinate of the upper-left corner.width: The width of the rectangle.height: The height of the rectangle is.color: Color in ARGB format (for example, 0xFF0000 for red).
renderGIF- Displays a GIF on the screen, the same as with the image
void renderGIF(const char* gifPath, int x, int y);
gifPath: The path to the GIF animation.x: The X coordinate of the upper-left corner.y: The Y coordinate of the upper-left corner.
startRenderingThread- Starts a stream for asynchronous rendering of images and GIF animations.
void startRenderingThread();
stopRenderingThread- Stops the stream for asynchronous rendering of images and GIF animations.
void stopRenderingThread();
startRecordingThread- Starts the program to record audio and convert it to text.
void startRecordingThread();
stopRecordingThread-Stops the stream to record audio and convert it to text.
void stopRecordingThread();
Usage examples
Synchronous Operation
In this example, we will initialize the engine, render the image and GIF animation, and then shut down the engine.#include <SDL2/SDL.h>
#include "engine.h"
#include <stdio.h>
int main(int argc, char* argv[]) {
initEngine("2D Character Engine", 800, 600);
if (!window) {
printf("Failed to initialize the game engine!\n");
return -1;
}
// Clearing the screen in black
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
SDL_RenderClear(renderer);
// Draw an image in the center of the screen
renderImage("character.jpg", 350, 250);
// Drawing a cloud and GIF animation
renderImage("cloud.png", 300, 200);
renderGIF("speaking.gif", 350, 250);
// Updating the display
SDL_RenderPresent(renderer);
// Waiting for 5 seconds
SDL_Delay(5000);
cleanupEngine();
return 0;
}
Compilation For Lixux
gcc sync_example.c -o sync_example -L. -lengine -lSDL2 -lSDL2_image -lpthread -lportaudio -lcjson -Wl,-rpath,.
For windows
gcc sync_example.c -o sync_example.exe -L. -lengine -lSDL2 -lSDL2_image -lpthread -lportaudio -lcjson
Variation with Python
import engine
import time
# Initializing the engine
engine.initEngine("2D Character Engine", 800, 600)
# Clearing the screen in black
engine.renderRectangle(0, 0, 800, 600, 0x000000)
# Draw an image in the center of the screen
engine.renderImage("character.jpg", 350, 250)
# Drawing a cloud and GIF animation
engine.renderImage("cloud.png", 300, 200)
engine.renderGIF("speaking.gif", 350, 250)
# Waiting for 5 seconds
of time.sleep(5)
# Clear the screen and shut down the engine
engine.cleanupEngine()
In general, everything is the same.
Asynchronous Operation
In this example, we will initialize the engine, run streams for asynchronous rendering and audio recording, and then shut down the engine.
#include <SDL2/SDL.h>
#include "engine.h"
#include <stdio.h>
int main(int argc, char* argv[]) {
initEngine("2D Character Engine", 800, 600);
if (!window) {
printf("Failed to initialize the game engine!\n");
return -1;
}
SDL_Event event;
int running = 1;
while (running) {
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
running = 0;
}
}
// Clearing the screen in black
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
SDL_RenderClear(renderer);
// Checking for a response
pthread_mutex_lock(&mutex);
if (prompt) {
printf("Prompt: %s\n", prompt);
// Drawing a cloud and GIF animation
renderImage("cloud.png", 300, 200);
renderGIF("speaking.gif", 350, 250);
}
pthread_mutex_unlock(&mutex);
// Draw an image in the center of the screen
renderImage("character.jpg", 350, 250);
// Updating the display
SDL_RenderPresent(renderer);
SDL_Delay(16); // Approximately 60 frames per second
}
cleanupEngine();
return 0;
}
Compilation
It's the same as with the synchronous example.
Variation with Python
import engine
import time
# Initializing the engine
engine.initEngine("2D Character Engine", 800, 600)
# Running streams for rendering and recording audio
engine.startRenderingThread()
engine.startRecordingThread()
try:
while True:
# Clear the screen in black
engine.renderRectangle(0, 0, 800, 600, 0x000000)
# Draw an image in the center of the screen
engine.renderImage("character.jpg", 350, 250)
# Checking for a response
if engine.prompt:
print(f"Prompt: {engine.prompt}")
# Draw a cloud and a GIF animation
engine.renderImage("cloud.png", 300, 200)
engine.renderGIF("speaking.gif", 350, 250)
# Updating the display
time.sleep(0.016) # Approximately 60 frames per second
except KeyboardInterrupt:
pass
finally:
# Stop the threads and shut down the engine
engine.stopRenderingThread()
engine.stopRecordingThread()
engine.cleanupEngine()
Dependencies
Dependencies include both standard headers and some additional ones.
engine.h # is included in the standard delivery
SDL2 - SDL.h, SDL_image.h, SDL2/SDL_gfxPrimitivies
Portaudio
cjson
stdlib
stdbool
string
pthread
Installation for Linux
Debian-based distros
sudo apt-get install libsdl2-dev libsdl2-image-dev libportaudio2 portaudio19-dev libjson-c-dev
Arch-based distros
sudo pacman -S sdl2 sdl2_image portaudio json-c base-devel
Installation for windows
- SDL2: Download the library from SDL2.
- SDL2_image: Download the library from SDL_image.
- PortAudio: Download the library from PortAudio.
- cJSON: Download the library from cJSON.
Cross-platform via vcpkg
vcpkg install sdl2 cjson portaudio
Building into a dynamic library
For Linux
gcc -shared -o libengine.so engine.o -lSDL2 -lSDL2_image -lpthread -lportaudio -lcjson
For Windows (using MinGW):
gcc -c engine.c -o engine.o -DENGINE_EXPORTS
gcc -shared -o engine.dll engine.o -lSDL2 -lSDL2_image -lpthread -lportaudio -lcjson
Variations of the provision
Python library
Available on PyPI - pip install EasyEngineLib
C/C++ header
Copy the src and add the compiler flag to the directory where engine.h is located. For example -
gcc -I~/include/engine example.c -o example.o
Self-assembly of the Python library
If you're messing up and you don't like PyPI, build the library yourself.
python setup.py sdist bdist_wheel
Metadata
Release files for EasyEngine 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| EasyEngine-0.2.1-cp313-cp313-any.whl | CPython 3.13 | CPython 3.13 | any | Details for EasyEngine-0.2.1-cp313-cp313-any.whl |
Release files / EasyEngine-0.2.1-cp313-cp313-any.whl
| Download URL | EasyEngine-0.2.1-cp313-cp313-any.whl |
|---|---|
| Size | 36.9 kB |
| Tags | CPython 3.13 |
|
SHA-256 checksum How to use checksums |
3ef69375e147292742c14c37c4be87703545341a3ee4ab9f98b8b7af3778cdbd
|
|
BLAKE2b-256 checksum How to use checksums |
7f41bca1eb32078f2aa7987aaaa0d0b7feb09a99008897eb38c8b2be93b6b641
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.1
|
Security for EasyEngine 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.