Skip to content

Tame — 2D Graphics Library

import "tame" gives you a thin, fast wrapper over a vendored raylib: a window, a frame loop, drawing, input, audio and persistence. It links only when your program imports "tame" or calls a tm_* built-in — ordinary programs stay dependency-free.

Every function below has an English name and a Turkish alias (where one exists); both compile to the same call.

FunctionDescription
window(w, h, title): boolOpen a window (call once, before the loop).
running(): boolfalse once the user closes the window — your loop condition.
close_window()Close the window (after the loop).
set_fps(n)Target frame rate (e.g. 60).
frame_begin() / frame_end()Wrap everything you draw in a frame.
frame_time(): floatSeconds since last frame (delta time — multiply movement by this).
elapsed(): floatSeconds since the program started (monotonic).
get_fps(): intCurrent measured frame rate.
screen_width(): int / screen_height(): intWindow size in pixels.

For mobile/full-screen scaling, the view bounds report the real drawable area: view_left() / view_right() / view_top() / view_bottom() (TR: ekran_sol/sag/ust/alt). Anchor on-screen controls to these so they hug the true screen edges on Android.

FunctionDescription
clear(color)Fill the whole frame with a color.
rect(x, y, w, h, color)Filled rectangle.
rect_lines(x, y, w, h, color)Rectangle outline.
circle(x, y, radius, color)Filled circle.
line(x1, y1, x2, y2, color)Line.
triangle(x1, y1, x2, y2, x3, y3, color)Filled triangle.
pixel(x, y, color)Single pixel.
text(s, x, y, size, color)Draw text (default font).
measure_text(s, size): intPixel width of a string — for centering.

Colors are packed integers. Build them with rgb(r, g, b) or rgba(r, g, b, a) (each channel 0–255), or use a named constant:

WHITE BLACK GRAY DARKGRAY RED MAROON GREEN LIME BLUE SKYBLUE
GOLD YELLOW ORANGE PINK PURPLE VIOLET BEIGE BROWN MAGENTA

Keyboard — key names are strings like "LEFT", "RIGHT", "UP", "DOWN", "SPACE", "ENTER", "ESCAPE", "A""Z":

FunctionDescription
key_down(k): boolHeld right now.
key_pressed(k): boolWent down this frame (single fire).
key_released(k): boolWent up this frame.

Mouse: mouse_x(), mouse_y(), mouse_down(b), mouse_pressed(b), mouse_wheel().

Touch (mobile) — TR aliases dokunma_*:

FunctionDescription
touch_count(): intNumber of active fingers.
touch_x(i): int / touch_y(i): intPosition of finger i.
touched(): boolAny finger down?

On Android, touch coordinates are already scaled into your game’s world space, so touch_x/y line up with what you draw.

Gamepad: gamepad_available(id), gamepad_name(id), gamepad_down(id, btn), gamepad_pressed(id, btn), gamepad_axis(id, axis).

Tilt / accelerometer (Android) — TR aliases egim_*: accel_x(), accel_y(), accel_z(), accel_available(). Desktop returns zeros, so guard with accel_available().

No asset files required — synth a tone on the fly:

FunctionDescription
beep(freq, ms) (TR bip)Play a freq Hz sine for ms milliseconds.
tone(freq, ms, vol) (TR ton)Same, but with a 0..1 volume — for background music under sound effects.

Or load real audio files:

FunctionDescription
load_sound(path): int / play_sound(s) / stop_sound(s) / sound_volume(s, v)Short sound effects.
load_music(path): int / play_music(m) / stop_music(m) / music_volume(m, v)Streaming music.
FunctionDescription
load_texture(path): intLoad an image.
draw_texture(tex, x, y)Draw it.
draw_texture_ex(tex, x, y, scale, rotation)Scaled / rotated.
texture_width(tex): int / texture_height(tex): intDimensions.
unload_texture(tex)Free it.
load_font(path, size): intLoad a TTF at a size.
text_font(f, s, x, y, size, color)Draw text with a loaded font.

Bundle assets into the web/Android build with TULPAR_WEB_ASSETS=<dir> — see Building & Publishing.

FunctionDescription
save_data(name, text): bool (TR kayit_yaz)Write a small string (high scores, settings). Persists across launches on every platform.
load_data(name): str (TR kayit_oku)Read it back ("" if missing).
vibrate(ms) (TR titret)Haptic buzz on Android; a no-op elsewhere.
screenshot(path)Save a PNG of the current frame.

name is a plain file name (e.g. "score"), not a path. On Android it maps to the app’s private storage automatically.

FunctionDescription
rgb(r, g, b): int / rgba(r, g, b, a): intBuild a color.
rect_overlap(x1,y1,w1,h1, x2,y2,w2,h2): boolAABB overlap test.
point_in_rect(px, py, x, y, w, h): boolPoint-in-rectangle test.
clamp(v, lo, hi)Constrain a value to a range.
run(update_fn, draw_fn)Convenience loop: calls update then draw each frame until the window closes (also drives the web animation frame).

Ready for entities, collisions and levels without writing a loop? Move up to the Arcade preset engine.