Skip to content

rayquiro.engine

This content is for v0.2.1. 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";

MethodSignatureDescription
engine.initengine.init(width, height, title)Initializes rendering window and OpenGL/Vulkan context.
engine.shouldCloseengine.shouldClose()Returns true if the window close button or Alt+F4 was pressed.
engine.closeengine.close()Frees engine resources and destroys the window.
engine.setFpsengine.setFps(target_fps)Locks frame rate (e.g. 60 or 144 FPS).
engine.getFpsengine.getFps()Returns current frames per second counter.
engine.getFrameTimeengine.getFrameTime()Delta time (dt) between frames in seconds.
engine.beginDrawengine.beginDraw()Prepares the screen buffer for drawing.
engine.endDrawengine.endDraw()Flips double-buffers and presents the frame.
engine.clearengine.clear(r, g, b)Clears the background to an RGB color (0..255).

MethodSignatureDescription
engine.drawRectengine.drawRect(x, y, w, h, r, g, b)Draws a solid filled rectangle.
engine.drawRectLinesengine.drawRectLines(x, y, w, h, r, g, b)Draws an outlined rectangle.
engine.drawCircleengine.drawCircle(cx, cy, radius, r, g, b)Draws a solid filled circle.
engine.drawLineengine.drawLine(x1, y1, x2, y2, r, g, b)Draws a line segment between two points.
engine.drawTextengine.drawText(text, x, y, size, r, g, b)Renders text at coordinates with font size.

if (engine.isKeyDown(262)) {
player_x = player_x + speed * dt;
}
if (engine.isKeyPressed(32)) {
player_vy = -350.0;
}
var mouse_pos = engine.getMousePosition();
var left_clicked = engine.isMouseButtonPressed(0);

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);

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();