GithubHelp home page GithubHelp logo

snake's Introduction

snake

Snake project in Ruby programming language.

Rules

In the Snake game, you are a snake, trying to eat as much apples as you can.
You controll the snake using the arrows on your keyboard.
If the snake hits a wall he will go through it and will re-appear in the other side.
Every time the snake hits an apple, the snake will grow by one cube and will gain one point.
The apple will be generated randomly on the board.
If the snake hits itself, you lose!

App.rb

The game manager - running and managing the game's objects and score count.
The game manager handles events and enforce the games rule.

Board.rb

Holds the class that describes the board and keep track on the player's points.

Class Functions

  • point - Add a point to the score count.
  • draw - Write on the screen the player's score.

Snake.rb

Holds the class that describes and keep the data of the snake.

Class Functions

  • move - Moves the snake one blok according to the snake's direction.
  • draw - Draws the snake on the screen.
  • check_death? - Checks if the snake hit itself.
  • location - Returns the location of the snake's head.

Apple.rb

Holds the clas that describes an Apple object.

Class Functions

  • draw - Draws the apple on the screen.
  • ==(other) - compare the location of an object(In te game the object is the snake) and checks if they are on top of each other.

consts.rb

The consts file holds the consts that are used throughout the project.

  • GRID_SIZE - The size of the grid - The size of every blockin the Snake game.
  • SCREEN_WIDTH - The number of blocks that exists on the X diagnol.
  • SCREEN_HEIGHT - The number of blocks that exists on the Y diagnol.
  • DIRECTIONS - A list consists of the possible directions of the snake - up, down, left and right.

Snake Game

snake's People

Contributors

ciantfv456 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.