Skip to content

abskrj/snake-terminux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SNAKE TERMINUX

Snake Game Demo Gif

Running Locally

  1. Fetch the repo
git clone https://github.com/abhishekraj272/snake-terminux.git
  1. Download the dependencies
cd snake-terminux
go mod download
  1. Starting the game
go run main.go

Instructions

  • Use arrow keys to move your snake.
  • Press q, esc, Ctrl+C or Ctrl+D to quit the game.
  • Hitting the wall or snake itself means GAME OVER.
  • Eat food to increase score and length of snake.

Implementation

  • Chosen termbox-go for better UI/UX.
  • Ran termbox.PollEvent on a GoRoutine to detect key press and used Go Channels to share data between GoRoutine.
  • Created a Game object to store all required data, and created methods for all logics.
  • Created a 2d Array to represent board where, 0 means blank-space, 1 means snake and 2 means food.
  • Snake moves by moving its head coords and removing its tail.
  • When snake eats food, its tail is increased.

Dependency

  1. termbox-go

Tested On

  • Ubuntu 20.04 LTS

Time taken on this project 4-5hrs Max

Refrences

About

A terminal-based snake game, written in golang.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages