rayquiro.engine
This content is for v1.0. Switch to the latest version for up-to-date documentation.
The rayquiro.engine module is statically compiled into RayQuiro. It provides windowing, hardware-accelerated 2D/3D graphics (via Vulkan or Raylib), sound/music playback, texture loading, font rendering, and keyboard/mouse/gamepad input.
import "rayquiro.engine";1. Window & Lifecycle Methods
Section titled “1. Window & Lifecycle Methods”| Method | Signature | Description |
|---|---|---|
engine.init | engine.init(width, height, title) | Initializes rendering window and OpenGL/Vulkan context. |
engine.shouldClose | engine.shouldClose() | Returns true if the window close button or Alt+F4 was pressed. |
engine.close | engine.close() | Frees engine resources and destroys the window. |
engine.setFps | engine.setFps(target_fps) | Locks frame rate (e.g. 60 or 144 FPS). |
engine.getFps | engine.getFps() | Returns current frames per second counter. |
engine.getFrameTime | engine.getFrameTime() | Delta time (dt) between frames in seconds. |
engine.beginDraw | engine.beginDraw() | Prepares the screen buffer for drawing. |
engine.endDraw | engine.endDraw() | Flips double-buffers and presents the frame. |
engine.clear | engine.clear(r, g, b) | Clears the background to an RGB color (0..255). |
2. 2D Drawing Primitives
Section titled “2. 2D Drawing Primitives”| Method | Signature | Description |
|---|---|---|
engine.drawRect | engine.drawRect(x, y, w, h, r, g, b) | Draws a solid filled rectangle. |
engine.drawRectLines | engine.drawRectLines(x, y, w, h, r, g, b) | Draws an outlined rectangle. |
engine.drawCircle | engine.drawCircle(cx, cy, radius, r, g, b) | Draws a solid filled circle. |
engine.drawLine | engine.drawLine(x1, y1, x2, y2, r, g, b) | Draws a line segment between two points. |
engine.drawText | engine.drawText(text, x, y, size, r, g, b) | Renders text at coordinates with font size. |
3. Input Handling
Section titled “3. Input Handling”Keyboard Input
Section titled “Keyboard Input”if (engine.isKeyDown(262)) { player_x = player_x + speed * dt;}if (engine.isKeyPressed(32)) { player_vy = -350.0;}Mouse Input
Section titled “Mouse Input”var mouse_pos = engine.getMousePosition();var left_clicked = engine.isMouseButtonPressed(0);4. Audio & Textures
Section titled “4. Audio & Textures”var sprite = engine.loadTexture("assets/player.png");engine.drawTexture(sprite, 100, 150);engine.drawTextureEx(sprite, 100, 150, 45.0, 2.0);
var jump_sfx = engine.loadSound("assets/jump.wav");engine.playSound(jump_sfx);
var bgm = engine.loadMusic("assets/theme.ogg");engine.playMusic(bgm);engine.updateMusic(bgm);5. Complete Game Example
Section titled “5. Complete Game Example”import "rayquiro.engine";
engine.init(800, 600, "RayQuiro Pong");engine.setFps(60);
var ball_x = 400.0;var ball_y = 300.0;var speed_x = 250.0;var speed_y = 200.0;
while (!engine.shouldClose()) { var dt = engine.getFrameTime();
ball_x = ball_x + speed_x * dt; ball_y = ball_y + speed_y * dt;
if (ball_x < 10 || ball_x > 790) { speed_x = -speed_x; } if (ball_y < 10 || ball_y > 590) { speed_y = -speed_y; }
engine.beginDraw(); engine.clear(20, 24, 32);
engine.drawCircle(ball_x, ball_y, 12, 255, 100, 100); engine.drawText("FPS: " + str(engine.getFps()), 10, 10, 20, 200, 200, 200);
engine.endDraw();}
engine.close();Audio System (audio.*)
Section titled “Audio System (audio.*)”RayQuiro includes high-performance audio playback powered by Raylib:
| Function | Signature | Description |
|---|---|---|
audio.init | audio.init() | Initializes the audio device. |
audio.load_sound | audio.load_sound(path) | Loads a short sound effect into memory. |
audio.play | audio.play(sound) | Plays a loaded sound effect. |
audio.stop | audio.stop(sound) | Stops playing a sound effect. |
audio.set_volume | audio.set_volume(sound, vol) | Sets volume for a sound effect (0.0 to 1.0). |
audio.load_music | audio.load_music(path) | Streams a background music track from file. |
audio.play_music | audio.play_music(music) | Starts music streaming. |
audio.update_music | audio.update_music(music) | Updates music stream buffers (call each frame). |
audio.stop_music | audio.stop_music(music) | Stops background music playback. |
audio.init();
var jumpSound = audio.load_sound("assets/jump.wav");audio.play(jumpSound);
var bgm = audio.load_music("assets/theme.ogg");audio.play_music(bgm);