Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -241,23 +241,29 @@ def generate_game_code(game_type: str, theme: str, temperature: float, max_new_t
|
|
| 241 |
system_msg = (
|
| 242 |
"You are an expert HTML5 game developer. "
|
| 243 |
"Write a complete, working, single-file HTML5 game using canvas and vanilla JavaScript. "
|
| 244 |
-
"CRITICAL RULES: "
|
| 245 |
-
"1.
|
| 246 |
-
"2.
|
| 247 |
-
"3.
|
| 248 |
-
|
| 249 |
-
"
|
|
|
|
|
|
|
|
|
|
| 250 |
"Output ONLY the raw HTML - no markdown fences, no explanation."
|
| 251 |
)
|
| 252 |
else:
|
| 253 |
system_msg = (
|
| 254 |
"You are an expert HTML5 game developer. "
|
| 255 |
"Write a complete, working, single-file HTML5 game using only canvas 2D drawing. "
|
| 256 |
-
"CRITICAL RULES: "
|
| 257 |
-
"1.
|
| 258 |
-
"2.
|
| 259 |
-
"3.
|
| 260 |
-
|
|
|
|
|
|
|
|
|
|
| 261 |
"Output ONLY the raw HTML - no markdown fences, no explanation."
|
| 262 |
)
|
| 263 |
|
|
|
|
| 241 |
system_msg = (
|
| 242 |
"You are an expert HTML5 game developer. "
|
| 243 |
"Write a complete, working, single-file HTML5 game using canvas and vanilla JavaScript. "
|
| 244 |
+
"CRITICAL RULES - follow every one exactly: "
|
| 245 |
+
"1. Add keydown/keyup listeners on WINDOW not canvas: window.addEventListener('keydown', e => keys.add(e.key)). "
|
| 246 |
+
"2. Gravity: every frame do velY += 0.5 AFTER moving, NOT inside collision. "
|
| 247 |
+
"3. Platform collision: loop ALL platforms, find the one the player is standing on. "
|
| 248 |
+
" Set grounded=true and velY=0 ONLY when found. Set grounded=false BEFORE the loop, not inside else. "
|
| 249 |
+
"4. Jump: if (grounded && (keys.has('ArrowUp') || keys.has('w') || keys.has('W'))) { velY=-12; grounded=false; } "
|
| 250 |
+
"5. Always add a solid ground platform spanning the full canvas width at y=420. "
|
| 251 |
+
"6. Use new Image() with src='sprite_NAME.png' for every visual asset, max 3 sprites. "
|
| 252 |
+
"7. Draw images with ctx.drawImage(img, x, y, w, h). "
|
| 253 |
"Output ONLY the raw HTML - no markdown fences, no explanation."
|
| 254 |
)
|
| 255 |
else:
|
| 256 |
system_msg = (
|
| 257 |
"You are an expert HTML5 game developer. "
|
| 258 |
"Write a complete, working, single-file HTML5 game using only canvas 2D drawing. "
|
| 259 |
+
"CRITICAL RULES - follow every one exactly: "
|
| 260 |
+
"1. Add keydown/keyup listeners on WINDOW not canvas: window.addEventListener('keydown', e => keys.add(e.key)). "
|
| 261 |
+
"2. Gravity: every frame do velY += 0.5 AFTER moving, NOT inside collision. "
|
| 262 |
+
"3. Platform collision: loop ALL platforms, find the one the player is standing on. "
|
| 263 |
+
" Set grounded=true and velY=0 ONLY when found. Set grounded=false BEFORE the loop, not inside else. "
|
| 264 |
+
"4. Jump: if (grounded && (keys.has('ArrowUp') || keys.has('w') || keys.has('W'))) { velY=-12; grounded=false; } "
|
| 265 |
+
"5. Always add a solid ground platform spanning the full canvas width at y=420. "
|
| 266 |
+
"6. Never use image files. Draw everything with canvas shapes and colors. "
|
| 267 |
"Output ONLY the raw HTML - no markdown fences, no explanation."
|
| 268 |
)
|
| 269 |
|