Skip to content
masonmcelvainPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

snake

The classic game of Snake, in your terminal.

                       S N A K E

  ╭────────────────────────────────────────────────╮
  │                                                │
  │                            ██                  │
  │                                                │
  │              ████████████                      │
  │                        ██                      │
  │                        ██                      │
  │                                                │
  ╰────────────────────────────────────────────────╯
   Score 7                                  Best 12
        arrows/hjkl move   p pause   q quit

Install

go install github.com/masonmcelvain/snake-go/cmd/snake@latest

Or build from a clone:

go build -o snake ./cmd/snake
./snake

Play

Key Action
Arrow keys, hjkl, or wasd Steer
p or space Pause / resume
q, esc, or ctrl-c Quit

Eat the red pellets to grow and score. Each pellet also speeds the snake up, so a long snake is a fast snake. Running into a wall or into your own body ends the round.

On game over the final board stays on screen behind a menu offering Restart and Quit — move between them with the arrow keys and confirm with enter, or press r or q directly. Your best score for the session is kept across restarts.

The board is sized to fit your terminal (up to 44x22 cells) and picks up a resize on the next restart.

Layout

  • cmd/snake — entry point.
  • internal/game — the rules: movement, growth, collisions, pellet placement. No terminal dependency, so it is tested directly.
  • internal/tui — raw-mode terminal handling, key decoding, and rendering onto a character canvas that is redrawn each tick.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages