0.1.0-1-alpha.2

This commit is contained in:
2026-09-16 23:28:33 +02:00
parent 2ad0c5a379
commit 9256e9e2d5
24 changed files with 762 additions and 14 deletions

10
Tauri/README.md Normal file
View File

@@ -0,0 +1,10 @@
<!-- file: Tauri/README.md -->
<!-- version: 1 -->
# Tauri
Cette arborescence contient les frontends statiques des variantes Desktop Tauri.
Le backend Rust reste une crate sous `crates/apps/`, conformément à la règle du workspace Cargo unique.
Les fichiers générés par `wasm-bindgen` ne sont pas versionnés.

View File

@@ -0,0 +1,17 @@
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Reflex POC Tauri</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<main id="app">
<canvas id="game" aria-label="Reflex POC"></canvas>
<output id="score">Score : 0</output>
<output id="runtime">Tauri · WebView · WASM</output>
</main>
<script type="module" src="./main.js"></script>
</body>
</html>

View File

@@ -0,0 +1,76 @@
// file: Tauri/game-reflex-poc/frontend/main.js
// version: 1
import init, { ReflexWasmGame } from "./game_reflex_poc_tauri.js";
const FRAME_MS = 16;
function color(red, green, blue) {
return `rgb(${red} ${green} ${blue})`;
}
function resizeCanvas(canvas) {
const ratio = window.devicePixelRatio || 1;
const width = Math.max(1, Math.floor(canvas.clientWidth * ratio));
const height = Math.max(1, Math.floor(canvas.clientHeight * ratio));
if (canvas.width !== width || canvas.height !== height) {
canvas.width = width;
canvas.height = height;
}
}
function render(game, canvas, context, score) {
resizeCanvas(canvas);
context.fillStyle = color(game.background_red(), game.background_green(), game.background_blue());
context.fillRect(0, 0, canvas.width, canvas.height);
const count = game.rectangle_count();
for (let index = 0; index < count; index += 1) {
context.fillStyle = color(game.rectangle_red(index), game.rectangle_green(index), game.rectangle_blue(index));
context.fillRect(
game.rectangle_x(index) * canvas.width,
game.rectangle_y(index) * canvas.height,
game.rectangle_width(index) * canvas.width,
game.rectangle_height(index) * canvas.height,
);
}
score.value = `Score : ${game.score()}`;
}
async function start() {
await init();
const canvas = document.querySelector("#game");
const score = document.querySelector("#score");
const context = canvas.getContext("2d");
if (!(canvas instanceof HTMLCanvasElement) || !(score instanceof HTMLOutputElement) || context === null) {
throw new Error("Reflex Tauri frontend DOM is incomplete");
}
const game = new ReflexWasmGame();
canvas.addEventListener("pointerdown", (event) => {
const bounds = canvas.getBoundingClientRect();
const x = (event.clientX - bounds.left) / bounds.width;
const y = (event.clientY - bounds.top) / bounds.height;
game.pointer_down(x, y);
render(game, canvas, context, score);
});
let previous = performance.now();
function frame(now) {
while (now - previous >= FRAME_MS) {
game.tick();
previous += FRAME_MS;
}
render(game, canvas, context, score);
window.requestAnimationFrame(frame);
}
render(game, canvas, context, score);
window.requestAnimationFrame(frame);
}
start().catch((error) => {
console.error("Reflex Tauri WASM startup failed", error);
});

View File

@@ -0,0 +1,45 @@
/* file: Tauri/game-reflex-poc/frontend/style.css */
/* version: 1 */
html,
body {
margin: 0;
width: 100%;
height: 100%;
overflow: hidden;
background: rgb(18 18 24);
font-family: sans-serif;
}
#app {
position: relative;
width: 100%;
height: 100%;
}
#game {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
#score,
#runtime {
position: absolute;
left: 12px;
padding: 6px 8px;
border-radius: 4px;
background: rgb(0 0 0 / 55%);
color: white;
pointer-events: none;
}
#score {
top: 12px;
}
#runtime {
bottom: 12px;
font-size: 12px;
}