Commit graph

4 commits

Author SHA1 Message Date
045b625655 opacity + animation fixes 2026-02-03 12:18:21 -05:00
67aa413a78 Replace stb_truetype with FreeType for proper text outline rendering
- Add -sUSE_FREETYPE=1 to Emscripten build flags
- Extend Font class with FT_Library, FT_Face, and FT_Stroker handles
- Rewrite FontAtlas to use FreeType with on-demand stroked glyph loading
- Text outlines now use FT_Stroker for vector-based stroking before
  rasterization, eliminating gaps at corners with thick outlines
- Use glTexSubImage2D for incremental atlas updates (major perf fix)
- Disable canvas border in shell.html per Emscripten docs (alignment fix)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 16:45:10 -05:00
1be2714240 Add Python REPL widget for WebGL build
Features:
- JSFiddle-style code editor panel alongside game canvas
- Run button (or Ctrl+Enter) executes Python code
- Reset button reloads game.py
- Tab key inserts 4 spaces for proper indentation
- Shows >>> prompt with code preview
- Displays repr of last expression (like Python REPL)
- Error highlighting in red, success in green
- Canvas focus handling with visual indicator

C++ exports (callable from JavaScript):
- run_python_string(code) - simple execution
- run_python_string_with_output(code) - captures stdout/stderr + expr repr
- reset_python_environment() - reloads game.py

JavaScript API available in console:
- runPython(code) - execute Python and get output
- resetGame() - reset to initial state
- FS.readFile/writeFile - access virtual filesystem

Also fixes canvas focus issues on page load.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 15:31:18 -05:00
bc7046180a Add Emscripten shell and pre-JS for browser compatibility
- src/shell.html: Custom HTML shell with crisp pixel CSS
  (image-rendering: pixelated) and zoom prevention on canvas
- src/emscripten_pre.js: Patches browser quirks that cause crashes:
  - Intercepts resize/scroll events to ensure e.detail is always 0
  - Wraps window properties (innerWidth, outerWidth, etc.) to
    always return integers, fixing browser zoom crashes
- CMakeLists.txt: Output as .html, include shell and pre-js files

The pre-JS fix addresses "attempt to write non-integer (undefined)
into integer heap" errors that occurred when users zoomed the browser
via Ctrl+scroll or browser menu.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 14:36:22 -05:00