diff options
| author | LLLL Colonq <llll@colonq> | 2026-06-18 16:15:46 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2026-06-18 16:15:46 -0400 |
| commit | c9fc2ca532c5219a087924ece1e38be19c25f006 (patch) | |
| tree | 7c9d8e32617fab6e6179fe70893a3027714ea4e7 /2026/examples/example_raylib | |
| parent | 068f3b9dc0522b03af534479cfa300a720ae86fa (diff) | |
Update
Diffstat (limited to '2026/examples/example_raylib')
| l--------- | 2026/examples/example_raylib/.direnv/flake-profile | 1 | ||||
| l--------- | 2026/examples/example_raylib/.direnv/flake-profile-1-link | 1 | ||||
| -rw-r--r-- | 2026/examples/example_raylib/.envrc | 1 | ||||
| -rw-r--r-- | 2026/examples/example_raylib/.gitignore | 2 | ||||
| -rwxr-xr-x | 2026/examples/example_raylib/build.sh | 4 | ||||
| -rwxr-xr-x | 2026/examples/example_raylib/build_raylib.sh | 11 | ||||
| -rw-r--r-- | 2026/examples/example_raylib/main.c | 33 | ||||
| -rw-r--r-- | 2026/examples/example_raylib/nix/flake.lock | 27 | ||||
| -rw-r--r-- | 2026/examples/example_raylib/nix/flake.nix | 17 | ||||
| m--------- | 2026/examples/example_raylib/raylib | 0 |
10 files changed, 97 insertions, 0 deletions
diff --git a/2026/examples/example_raylib/.direnv/flake-profile b/2026/examples/example_raylib/.direnv/flake-profile new file mode 120000 index 0000000..0c05709 --- /dev/null +++ b/2026/examples/example_raylib/.direnv/flake-profile @@ -0,0 +1 @@ +flake-profile-1-link
\ No newline at end of file diff --git a/2026/examples/example_raylib/.direnv/flake-profile-1-link b/2026/examples/example_raylib/.direnv/flake-profile-1-link new file mode 120000 index 0000000..8f6f619 --- /dev/null +++ b/2026/examples/example_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/example_raylib/.envrc b/2026/examples/example_raylib/.envrc new file mode 100644 index 0000000..9160bb3 --- /dev/null +++ b/2026/examples/example_raylib/.envrc @@ -0,0 +1 @@ +use_flake path:nix
\ No newline at end of file diff --git a/2026/examples/example_raylib/.gitignore b/2026/examples/example_raylib/.gitignore new file mode 100644 index 0000000..ea9ccd0 --- /dev/null +++ b/2026/examples/example_raylib/.gitignore @@ -0,0 +1,2 @@ +libraylib.a +output/*
\ No newline at end of file diff --git a/2026/examples/example_raylib/build.sh b/2026/examples/example_raylib/build.sh new file mode 100755 index 0000000..93411e4 --- /dev/null +++ b/2026/examples/example_raylib/build.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -xeu -o pipefail +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/index.html diff --git a/2026/examples/example_raylib/build_raylib.sh b/2026/examples/example_raylib/build_raylib.sh new file mode 100755 index 0000000..71aa025 --- /dev/null +++ b/2026/examples/example_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/example_raylib/main.c b/2026/examples/example_raylib/main.c new file mode 100644 index 0000000..da9383a --- /dev/null +++ b/2026/examples/example_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: false});"); + started = false; + } + BeginDrawing(); + ClearBackground(RED); + DrawText("hello gamer", 0, 0, 20, WHITE); + EndDrawing(); + } + } + return 0; +} diff --git a/2026/examples/example_raylib/nix/flake.lock b/2026/examples/example_raylib/nix/flake.lock new file mode 100644 index 0000000..7461ca0 --- /dev/null +++ b/2026/examples/example_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/example_raylib/nix/flake.nix b/2026/examples/example_raylib/nix/flake.nix new file mode 100644 index 0000000..d51dd3a --- /dev/null +++ b/2026/examples/example_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 + ]; + }; + }; +} diff --git a/2026/examples/example_raylib/raylib b/2026/examples/example_raylib/raylib new file mode 160000 +Subproject ef8b3e619532fa95a93040c7e7349f55366689b |
