81 lines
2.6 KiB
Python
81 lines
2.6 KiB
Python
def get_game_template_hint(request_text: str) -> str:
|
|
lowered = request_text.lower()
|
|
if "three.js" in lowered or "threejs" in lowered or "webgl" in lowered or "3d" in lowered:
|
|
return THREE_JS_TEMPLATE_HINT
|
|
if "phaser" in lowered:
|
|
return PHASER_TEMPLATE_HINT
|
|
if "canvas" in lowered or "snake" in lowered or "pong" in lowered or "tetris" in lowered:
|
|
return CANVAS_TEMPLATE_HINT
|
|
return ""
|
|
|
|
|
|
CANVAS_TEMPLATE_HINT = """
|
|
Starter template guidance for a plain canvas game:
|
|
|
|
index.html
|
|
- Create a centered app shell with:
|
|
- a header area for title and score
|
|
- a main game canvas
|
|
- a mobile controls section with large directional/action buttons
|
|
- a restart button
|
|
|
|
style.css
|
|
- Use a responsive layout that stacks nicely on mobile.
|
|
- Keep the canvas visible without horizontal scrolling.
|
|
- Add `touch-action: none;` for interactive game controls.
|
|
- Use clear visual contrast and large tap targets.
|
|
|
|
script.js
|
|
- Create explicit game state variables.
|
|
- Create a `resizeGame()` function if canvas sizing matters.
|
|
- Create a `startGame()` / `resetGame()` flow.
|
|
- Create a `gameLoop()` driven by `requestAnimationFrame` or a timed tick.
|
|
- Add keyboard listeners and touch/click listeners.
|
|
- Keep gameplay fully self-contained without external assets.
|
|
"""
|
|
|
|
|
|
THREE_JS_TEMPLATE_HINT = """
|
|
Starter template guidance for a Three.js browser game:
|
|
|
|
index.html
|
|
- Include a UI overlay for score, status, and restart.
|
|
- Load Three.js with a browser-safe CDN module import in script.js.
|
|
|
|
style.css
|
|
- Full-viewport scene layout.
|
|
- Overlay HUD pinned above the renderer.
|
|
- Mobile-safe action buttons if touch input is needed.
|
|
|
|
script.js
|
|
- Set up:
|
|
- scene
|
|
- perspective camera
|
|
- renderer sized to the viewport
|
|
- ambient + directional light
|
|
- resize handler
|
|
- animation loop
|
|
- Keep geometry lightweight for mobile.
|
|
- Use simple primitives and colors instead of relying on asset pipelines.
|
|
- Implement gameplay logic on top of the render loop, not just a visual demo.
|
|
"""
|
|
|
|
|
|
PHASER_TEMPLATE_HINT = """
|
|
Starter template guidance for a Phaser game:
|
|
|
|
index.html
|
|
- Include a HUD area for score and status.
|
|
- Load Phaser from a browser-ready CDN.
|
|
|
|
style.css
|
|
- Center the game canvas and ensure it scales on mobile.
|
|
- Add large touch-friendly controls when needed.
|
|
|
|
script.js
|
|
- Use a Phaser config with `type`, `width`, `height`, `parent`, `backgroundColor`, and scaling rules.
|
|
- Create at least one scene with `preload`, `create`, and `update`.
|
|
- Use primitive graphics or generated shapes if no external assets are required.
|
|
- Add restart behavior and visible score/status updates outside or inside the Phaser scene.
|
|
"""
|