LeafCat79 commited on
Commit
a3feb0f
·
verified ·
1 Parent(s): 9f46932

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -11
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. Track keyboard input using a Set and keydown/keyup event listeners, NEVER document.key. "
246
- "2. Implement real gravity: add 0.5 to velY each frame, reset velY=0 on platform landing. "
247
- "3. Implement real jump: only when grounded, set velY=-12. "
248
- "4. Use new Image() with src='sprite_NAME.png' for every visual asset, max 3 sprites. "
249
- "5. Draw images with ctx.drawImage(img, x, y, w, h). "
 
 
 
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. Track keyboard input using a Set and keydown/keyup event listeners, NEVER document.key. "
258
- "2. Implement real gravity: add 0.5 to velY each frame, reset velY=0 on platform landing. "
259
- "3. Implement real jump: only when grounded, set velY=-12. "
260
- "4. Never use image files. Draw everything with canvas shapes and colors. "
 
 
 
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