Stack, Snake and Hop re-tessellate rounded rectangles every frame

Abierto
#35 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
55/100
Tipo de issue
Refactorización
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
typescript

Línea de trabajo

Start by reading the drawing code in games/stack/scenes/GameScene.ts, games/snake/scenes/GameScene.ts, and games/hop/scenes/GameScene.ts, then compare it with the sparkTexture example in shared/ui.ts. Run npm run dev and use a Performance trace to check how frame time changes as the Stack board fills or the Snake grows. The issue is done when drawing cost no longer measurably grows with board fill or snake length and the visuals remain unchanged; run npm run typecheck and npm run build.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

help wanted performance severity: medium

Summary

Three games clear a Graphics object and redraw every cell or segment with fillRoundedRect each frame. Phaser's WebGL Graphics renderer tessellates each arc with a fixed step and does not cache geometry, so cost grows with board fill and snake length.

Where

  • games/stack/scenes/GameScene.ts:458-497, games/stack/scenes/GameScene.ts:500-512 (three rounded rects per cell)
  • games/snake/scenes/GameScene.ts:437-452, games/snake/scenes/GameScene.ts:404-412 (two per segment plus three colour objects)
  • games/hop/scenes/GameScene.ts:396-435

Details

Estimated from the Phaser 3.90 source, not measured in a browser:

  • A rounded rect is about 400 points and 400 triangles.
  • Stack with about 100 visible cells: about 300 paths and 120,000 point allocations per frame.
  • Snake at length 50: about 40,000 allocations and triangles per frame.

Impact

Likely GC pauses and dropped frames on phones and low-end laptops, worst when the Stack board is full or the snake is long, which is when timing matters most.

Steps to reproduce

  1. Play Stack until the board is half full, or Snake to length 50.
  2. Record a Performance trace and compare scripting time and minor GC frequency with the start of the run.

Suggested fix

Pre-render one white cell texture with generateTexture (as sparkTexture in shared/ui.ts already does) and draw cells as pooled tinted Images, or stamp into a RenderTexture updated only when the board changes. Cache Snake's gradient colours per length. A cheaper stopgap is fillRect for the glow and highlight layers.

Acceptance criteria

  • Frame time in Stack and Snake does not grow measurably with board fill or snake length
  • Visuals are unchanged

Getting started

  • Relevant files: games/stack/scenes/GameScene.ts, games/snake/scenes/GameScene.ts, games/hop/scenes/GameScene.ts, shared/ui.ts
  • Run locally: npm install, then npm run dev
  • Checks: npm run typecheck and npm run build (there is no test suite yet)
  • Related docs: README.md

Filed by repo-audit/full-audit at b001f5d. Severity: medium. Effort: M. audit-key: performance|games/stack/scenes/GameScene.ts|drawCell

Lenguaje dominante
TypeScript
Estrellas
3
Forks
3
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de TMHSDigital/GH-Arcade

Todos los issues de TMHSDigital/GH-Arcade

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.