Skip to content

Latest commit

 

History

History
47 lines (35 loc) · 1.23 KB

README.md

File metadata and controls

47 lines (35 loc) · 1.23 KB

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