feat: add snake game example#718
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a new playable Snake example under examples/snake-game/ with package/tsconfig, a SnakeBoard renderer, SnakeGame state and tick loop (movement, collisions, food, scoring), keyboard input handling, and a main() bootstrap to mount the App. ChangesSnake Game Example
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Hi @shaktipy 👋 ⭐ Star this repo before your PR merges. Why? GSSoC 2026 contributors who star get priority review and points credit. After you star, push any commit (or re-run this check). The Thanks for your contribution to TermUI. |
There was a problem hiding this comment.
🎉 Thanks for your first PR to TermUI, @shaktipy.
Before your PR merges:
- ⭐ Star the repo. Required. The
star-checkjob blocks your merge otherwise. - ✅ All checks green:
build,test,typecheck. - 🏷 PR title follows
type: short description. Example:fix: handle empty list. - 🔗 Link your closing issue in the description.
GSSoC 2026 points come from labels after merge:
gssoc:approved. +50 base points.level:beginner/intermediate/advanced/critical. +20 / +35 / +55 / +80.quality:clean/exceptional. x 1.2 / x 1.5.type:*. Stackable bonus.
Your reviewer responds within 48 hours. Ping @Karanjot786 on Discord for urgent help.
🚀 Welcome to the cohort.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@examples/snake-game/src/index.tsx`:
- Around line 96-105: The generateRandomFood() function can infinite-loop if the
snake fills the whole GRID_SIZE*GRID_SIZE board; update generateRandomFood to
first check if this.snake.length >= GRID_SIZE * GRID_SIZE and handle the "board
full" case by returning null (or throwing a clear BoardFullError) instead of
looping forever, change its return type to {x:number;y:number}|null (or keep
throwing) and then update callers (notably the food-spawn after eating in the
move/eat handler) to handle the null/board-full result by ending the game or
skipping spawning new food. Ensure references to generateRandomFood, the
food-spawn logic after eating, and the game-over/end-game handler are updated to
handle the new behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: f120a034-baae-4980-97a7-5e2324e169ec
⛔ Files ignored due to path filters (1)
bun.lockis excluded by!**/*.lock
📒 Files selected for processing (3)
examples/snake-game/package.jsonexamples/snake-game/src/index.tsxexamples/snake-game/tsconfig.json
Overview
This PR adds a classic Snake Game as a new example in the
examples/snake-gamedirectory. It demonstrates how to build an interactive terminal game using TermUI's widget system.Features
Rafter game overQto quitTechnical Implementation
SnakeBoardwidget renders the game gridSnakeGamewidget manages game state and logiconMount,onUnmount,handleKey,_renderSelfsetIntervalat 150ms tick rateHow to Run