prototype release

This commit is contained in:
Lilith Schier 2026-10-05 22:31:33 +02:00
parent 5794f50856
commit 3197ae9e6f
9 changed files with 543 additions and 572 deletions

1
.gitignore vendored
View file

@ -5,3 +5,4 @@
zig-out/
zig-pkg/
bin/
build/

View file

@ -21,6 +21,9 @@ pub fn build(b: *Build) !void {
if (optimize == .Debug or tracy_enable) {
odin_exec.addArg("-debug");
}
if (optimize == .ReleaseFast) {
odin_exec.addArg("-disable-assert");
}
if (tracy_enable) {
odin_exec.addArg("-define:TRACY_ENABLE=true");
odin_exec.addArg(b.fmt("-define:TRACY_CALLSTACK={}", .{tracy_callstack}));

37
build_web.sh Executable file
View file

@ -0,0 +1,37 @@
#!/bin/bash -eu
# Point this to where you installed emscripten. Optional on systems that already
# have `emcc` in the path.
EMSCRIPTEN_SDK_DIR="$HOME/repos/emsdk"
OUT_DIR="build/web"
mkdir -p $OUT_DIR
export EMSDK_QUIET=1
[[ -f "$EMSCRIPTEN_SDK_DIR/emsdk_env.sh" ]] && . "$EMSCRIPTEN_SDK_DIR/emsdk_env.sh"
# Note RAYLIB_WASM_LIB=env.o -- env.o is an internal WASM object file. You can
# see how RAYLIB_WASM_LIB is used inside <odin>/vendor/raylib/raylib.odin.
#
# The emcc call will be fed the actual raylib library file. That stuff will end
# up in env.o
#
# Note that there is a rayGUI equivalent: -define:RAYGUI_WASM_LIB=env.o
odin build src/main_web -target:js_wasm32 -build-mode:obj -define:RAYLIB_WASM_LIB=env.o -define:RAYGUI_WASM_LIB=env.o -out:$OUT_DIR/game.wasm.obj
ODIN_PATH=$(odin root)
cp $ODIN_PATH/core/sys/wasm/js/odin.js $OUT_DIR
files="$OUT_DIR/game.wasm.obj ${ODIN_PATH}/vendor/raylib/wasm/libraylib.web.a ${ODIN_PATH}/vendor/raylib/wasm/libraygui.a"
# index_template.html contains the javascript code that calls the procedures in
# source/main_web/main_web.odin
flags="-sEXPORTED_RUNTIME_METHODS=['HEAPF32'] -sUSE_GLFW=3 -sWASM_BIGINT -sWARN_ON_UNDEFINED_SYMBOLS=0 -sASSERTIONS --shell-file src/main_web/index_template.html"
# For debugging: Add `-g` to `emcc` (gives better error callstack in chrome)
emcc -o $OUT_DIR/index.html $files $flags
rm $OUT_DIR/game.wasm.obj
echo "Web build created in ${OUT_DIR}"

Binary file not shown.

25
src/assets/sdf.gl100.glsl Normal file
View file

@ -0,0 +1,25 @@
#version 100
precision mediump float;
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
// NOTE: Add your custom variables here
const float smoothing = 1.0/8.0;
void main()
{
// Texel color fetching from texture sampler
// NOTE: Calculate alpha using signed distance field (SDF)
float distance = texture2D(texture0, fragTexCoord).a;
float alpha = smoothstep(0.5 - smoothing, 0.5 + smoothing, distance);
// Calculate final fragment color
gl_FragColor = vec4(fragColor.rgb, fragColor.a*alpha);
}

26
src/assets/sdf.gl330.glsl Normal file
View file

@ -0,0 +1,26 @@
#version 330
// Input vertex attributes (from vertex shader)
in vec2 fragTexCoord;
in vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
// Output fragment color
out vec4 finalColor;
// NOTE: Add your custom variables here
void main()
{
// Texel color fetching from texture sampler
// NOTE: Calculate alpha using signed distance field (SDF)
float distanceFromOutline = texture(texture0, fragTexCoord).a - 0.5;
float distanceChangePerFragment = length(vec2(dFdx(distanceFromOutline), dFdy(distanceFromOutline)));
float alpha = smoothstep(-distanceChangePerFragment, distanceChangePerFragment, distanceFromOutline);
// Calculate final fragment color
finalColor = vec4(fragColor.rgb, fragColor.a*alpha);
}

View file

@ -80,3 +80,65 @@ CARDS := [Card_Handle(TAROT_COUNT)]Card {
{.Wand, 13},
{.Wand, 14},
}
card_full_name :: proc(card: Card) -> (name: string) {
suit_name: string
switch card.suit {
case .Major:
switch card.number {
case 0:
return "The Fool"
case 1:
return "The Magician"
case 2:
return "The High Priestess"
case 3:
return "The Empress"
case 4:
return "The Emperor"
case 5:
return "The Hierophant"
case 6:
return "The Lovers"
case 7:
return "The Chariot"
case 8:
return "Strength"
case 9:
return "The Hermit"
case 10:
return "Wheel of Fortune"
case 11:
return "Justice"
case 12:
return "The Hanged Man"
case 13:
return "Death"
case 14:
return "Temperance"
case 15:
return "The Devil"
case 16:
return "The Tower"
case 17:
return "The Star"
case 18:
return "The Moon"
case 19:
return "The Sun"
case 20:
return "Judgment"
case 21:
return "The World"
}
case .Chalice:
suit_name = "of Chalices"
case .Coin:
suit_name = "of Coins"
case .Sword:
suit_name = "of Swords"
case .Wand:
suit_name = "of Wands"
}
return name
}

File diff suppressed because it is too large Load diff

View file

@ -4,9 +4,9 @@
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Odin + Raylib on the web</title>
<meta name="title" content="Odin + Raylib on the web">
<meta name="description" content="Make games using Odin + Raylib that work in the browser">
<title>Fortune's Foundation</title>
<meta name="title" content="Fortune's Foundation">
<meta name="description" content="A clone of an excellent solitaire designed by Zachtronics!">
<meta name="viewport" content="width=device-width">
<style>