Skip to main content
Version: 0.0.1

rayquiro.engine

rayquiro.engine is RayQuiro's built-in scene and mini-game framework.

It is designed for:

  • 3D scenes
  • small arcade-style games
  • animated demos
  • interactive visuals

Import

import rayquiro.engine as engine;

The alias raytolfas.engine is also accepted in 0.0.1.

Data Conventions

Color

Colors are arrays:

[r, g, b, a]

Example:

[98, 204, 255, 255]

Vector2

2D vectors:

[x, y]

Vector3

3D vectors:

[x, y, z]

API Reference

engine.init(width, height, title)

Starts the engine window.

engine.shutdown()

Closes the engine runtime.

engine.should_close()

Returns true when the window should close.

engine.begin()

Starts a frame.

engine.end()

Ends a frame.

engine.clear(color)

Clears the frame with a color.

engine.set_camera(position, target, up, fov)

Sets the 3D camera.

Example:

engine.set_camera([0, 14, 14], [0, 0, -2], [0, 1, 0], 45);

engine.target_fps(fps)

Sets the desired frame rate.

engine.frame_time()

Returns the current frame time.

This is typically used for movement and update logic.

engine.key_down(keyCode)

Checks whether a key is currently pressed.

Example:

if (engine.key_down(65)) {
print("A is down");
}

engine.draw_grid(slices, spacing)

Draws a helper grid.

engine.draw_cube(position, size, color)

Draws a cube.

size is a Vector3 array:

engine.draw_cube([0, 0.5, 0], [1, 1, 1], [84, 165, 255, 255]);

engine.draw_plane(position, size2d, color)

Draws a plane.

engine.draw_sphere(position, radius, color)

Draws a sphere.

engine.draw_text(text, x, y, fontSize, color)

Draws text in screen space.

engine.draw_fps(x, y)

Draws an FPS counter.

Main Loop Pattern

import rayquiro.engine as engine;

engine.init(1280, 720, "RayQuiro Engine Demo");
engine.target_fps(60);
engine.set_camera([6, 6, 6], [0, 0, 0], [0, 1, 0], 45);

while (!engine.should_close()) {
var dt = engine.frame_time();

engine.begin();
engine.clear([11, 18, 28, 255]);
engine.draw_grid(20, 1);
engine.draw_cube([0, 0.5, 0], [1, 1, 1], [84, 165, 255, 255]);
engine.draw_text("RayQuiro Engine", 18, 18, 24, [232, 239, 247, 255]);
engine.draw_fps(18, 50);
engine.end();
}

engine.shutdown();

Mini Game Example

The repository examples/main.rq uses:

  • engine.key_down(...)
  • engine.frame_time()
  • engine.draw_plane(...)
  • engine.draw_cube(...)
  • engine.draw_sphere(...)
  • engine.draw_text(...)

That example is a good reference for a complete mini-game loop.

Notes

  • The engine is Windows-first in the current release path.
  • engine.shutdown() should be called after the main loop.
  • For movement, use engine.frame_time() rather than assuming a fixed frame duration.