summaryrefslogtreecommitdiff
path: root/2026/examples/raylib
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2026-05-28 20:16:38 -0400
committerLLLL Colonq <llll@colonq>2026-05-28 20:16:38 -0400
commitfa4d63110a3e12d0242b6e6ddcded74d04480f28 (patch)
tree330e6ccfe650f1fd9143f9db67b481d4c74a2e05 /2026/examples/raylib
Initial commit
Diffstat (limited to '2026/examples/raylib')
l---------2026/examples/raylib/.direnv/flake-profile1
l---------2026/examples/raylib/.direnv/flake-profile-1-link1
-rw-r--r--2026/examples/raylib/.envrc1
-rw-r--r--2026/examples/raylib/.gitignore2
-rwxr-xr-x2026/examples/raylib/build.sh3
-rwxr-xr-x2026/examples/raylib/build_raylib.sh11
-rw-r--r--2026/examples/raylib/main.c33
-rw-r--r--2026/examples/raylib/nix/flake.lock27
-rw-r--r--2026/examples/raylib/nix/flake.nix17
9 files changed, 96 insertions, 0 deletions
diff --git a/2026/examples/raylib/.direnv/flake-profile b/2026/examples/raylib/.direnv/flake-profile
new file mode 120000
index 0000000..0c05709
--- /dev/null
+++ b/2026/examples/raylib/.direnv/flake-profile
@@ -0,0 +1 @@
+flake-profile-1-link \ No newline at end of file
diff --git a/2026/examples/raylib/.direnv/flake-profile-1-link b/2026/examples/raylib/.direnv/flake-profile-1-link
new file mode 120000
index 0000000..8f6f619
--- /dev/null
+++ b/2026/examples/raylib/.direnv/flake-profile-1-link
@@ -0,0 +1 @@
+/nix/store/xska2chszdi2m9qa6cnig39w8aihqqcw-nix-shell-env \ No newline at end of file
diff --git a/2026/examples/raylib/.envrc b/2026/examples/raylib/.envrc
new file mode 100644
index 0000000..9160bb3
--- /dev/null
+++ b/2026/examples/raylib/.envrc
@@ -0,0 +1 @@
+use_flake path:nix \ No newline at end of file
diff --git a/2026/examples/raylib/.gitignore b/2026/examples/raylib/.gitignore
new file mode 100644
index 0000000..ea9ccd0
--- /dev/null
+++ b/2026/examples/raylib/.gitignore
@@ -0,0 +1,2 @@
+libraylib.a
+output/* \ No newline at end of file
diff --git a/2026/examples/raylib/build.sh b/2026/examples/raylib/build.sh
new file mode 100755
index 0000000..f176746
--- /dev/null
+++ b/2026/examples/raylib/build.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+mkdir -p output
+emcc -I./raylib/src libraylib.a -s USE_GLFW=3 -s ASYNCIFY --shell-file ./raylib/src/minshell.html main.c -DPLATFORM_WEB -o output/game.html
diff --git a/2026/examples/raylib/build_raylib.sh b/2026/examples/raylib/build_raylib.sh
new file mode 100755
index 0000000..71aa025
--- /dev/null
+++ b/2026/examples/raylib/build_raylib.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+cd raylib/src/
+emcc -c rcore.c -Os -Wall -DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES2
+emcc -c rshapes.c -Os -Wall -DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES2
+emcc -c rtextures.c -Os -Wall -DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES2
+emcc -c rtext.c -Os -Wall -DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES2
+emcc -c rmodels.c -Os -Wall -DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES2
+emcc -c raudio.c -Os -Wall -DPLATFORM_WEB
+
+emar rcs libraylib.a rcore.o rshapes.o rtextures.o rtext.o rmodels.o raudio.o
+mv libraylib.a ../..
diff --git a/2026/examples/raylib/main.c b/2026/examples/raylib/main.c
new file mode 100644
index 0000000..64091b5
--- /dev/null
+++ b/2026/examples/raylib/main.c
@@ -0,0 +1,33 @@
+#include <raylib.h>
+#include <emscripten.h>
+#include <stdio.h>
+#include <stdbool.h>
+
+int main(int argc, char **argv) {
+ InitWindow(240, 160, "test game raylib mode");
+ SetTargetFPS(60);
+ emscripten_run_script("window.parent.postMessage({op: \"ready\"});");
+ bool started = false;
+ while (!WindowShouldClose()) {
+ if (!started) {
+ double difficulty = EM_ASM_DOUBLE({return window.lcolonqJamStart || -1.0;});
+ printf("difficulty: %f\n", difficulty);
+ if (difficulty > 0.0) {
+ started = true;
+ emscripten_run_script("window.parent.postMessage({op: \"started\"});");
+ printf("started at difficulty: %f\n", difficulty);
+ }
+ } else {
+ if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
+ printf("clicked\n");
+ emscripten_run_script("window.parent.postMessage({op: \"done\", win: true});");
+ return 0;
+ }
+ BeginDrawing();
+ ClearBackground(RED);
+ DrawText("hello gamer", 0, 0, 20, WHITE);
+ EndDrawing();
+ }
+ }
+ return 0;
+}
diff --git a/2026/examples/raylib/nix/flake.lock b/2026/examples/raylib/nix/flake.lock
new file mode 100644
index 0000000..7461ca0
--- /dev/null
+++ b/2026/examples/raylib/nix/flake.lock
@@ -0,0 +1,27 @@
+{
+ "nodes": {
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1779694939,
+ "narHash": "sha256-Ly4j75O8ICaSQx3uxPnwk2x7PMF0XQvn5r0c3yBA7FI=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "f9d8b65950353691ab56561e7c73d2e1063d810b",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixpkgs-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "nixpkgs": "nixpkgs"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/2026/examples/raylib/nix/flake.nix b/2026/examples/raylib/nix/flake.nix
new file mode 100644
index 0000000..d51dd3a
--- /dev/null
+++ b/2026/examples/raylib/nix/flake.nix
@@ -0,0 +1,17 @@
+{
+ inputs = {
+ nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
+ };
+
+ outputs = { self, nixpkgs, ... }@inputs:
+ let
+ system = "x86_64-linux";
+ pkgs = nixpkgs.legacyPackages.${system};
+ in {
+ devShells.x86_64-linux.default = pkgs.mkShell {
+ buildInputs = [
+ pkgs.emscripten
+ ];
+ };
+ };
+}