Skip to content

Snake is an attempt to recreate the Snake game that used to be shipped with earlier versions of Nokia phones. It can be executed on CLI and is built using Ruby and Object-Oriented Programming principles.

Notifications You must be signed in to change notification settings

hirengondhiya/name_snake_game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

Snake application is inspired by the Snake game that came with old Nokia phones. The goal of the game is to feed the apples produced by the game to the snake without hitting boundaries of the wall and without running over itself. Each time the snake is fed with an apple it grows by one unit. This game is implemented as a terminal app using Ruby programming language.

System Requirements

The app is built using Ruby programming language hence your system must be able to run Ruby interpreter.

This app was tested on macOS Mojave version 10.14.6 and ruby-2.6.3

Installation

  1. Follow the instructions at https://www.ruby-lang.org/en/documentation/installation/ to download and install Ruby on you computer.

  2. Clone or Download the repository from GitHub

  3. On terminal cd into root directory of the cloned/downloaded repository

  4. Install the bundler gem

This step is optional if you already have installed Bundler gem. If not on terminal using below command install Bundler gem.

Gem install bundler
  1. Install depencies

This app have dependencies on Ruby gems "Colorize" and "Feep". Use below command to install all the dependencies.

bundle install

Run

In the terminal run bash script to run the file.

chmod u+x snake.sh
./snake.sh

Alternatively run

ruby index.rb -username="Your Name" -help

Dependencies

This app has dependency on following Ruby gems

  1. Colorize
  2. Feep

Features

  1. Commandline parameters

The application recognizes two command-line parameters.

-username: This optional parameter can be used to pass username to the game. Usage ruby index.rb -username="name of the user" Please note Equal sign (=) after the parameter name must be used to assign the username value to the parameter If the name is more than one word it should be enclosed in quotes (")

-help: This optional parameter can be used to show the help file it does not need to be passed any value to the parameter. If any value is passed to -help it would be ignored. The snake can be controlled by using arrow keys on the keyboard.

  1. Moving the Snake

Press

Up Arrow: to move the snake in top direction.

Down Arrow: to move the snake in the down direction.

Left Arrow: to move snake in left direction.

Right Arrow: to move the snake in the right direction.

  1. Quiting the game

Anytime during the game play the user can Quit the game by pressing "q" or "Q".

  1. Pausing the game

Anytime during the game play the user can Pause the game by pressing "p" or "P"

  1. Input Error During the gameplay, if you press any other key except mentioned above the snake will move by one step in the same direction as the previous one and the app will indicate invalid keypress by sounding a beep sound.

The game will continue until the user does not hit any of the four walls or runs its head over its tail.

Software Development Plan

The software development plan can be accessed from here

About

Snake is an attempt to recreate the Snake game that used to be shipped with earlier versions of Nokia phones. It can be executed on CLI and is built using Ruby and Object-Oriented Programming principles.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published