GithubHelp home page GithubHelp logo

cloudsthere / responsive-snake Goto Github PK

View Code? Open in Web Editor NEW

This project forked from iamchrismiller/responsive-snake

0.0 2.0 0.0 464 KB

HTML5 Responsive Snake Game

Home Page: http://iamchrismiller.github.io/responsive-snake/example/

License: MIT License

JavaScript 83.35% CSS 13.17% HTML 3.49%

responsive-snake's Introduction

Responsive Snake Built with Grunt

A Responsive HTML5 Snake Game with a particle explosion on food impact!

Requirements

You must have Zepto or jQuery attached to the Window Global

Usage

Install through Bower

bower install responsive-snake

Customization:

You may define a width (width="400px") / height (height="400px") on the canvas tag itself
OR use the data attribute `data-full-screen="true"` for full-screen

Game Options

- snakePixels (int) default : 14
    - Snake piece width in pixels
- snakeSize (int) default : 3
    - How many snake pieces to start with
- headColor (string) default : transparent
    - Custom Head Color (#ff0000 || rgb(0,0,0))
- foodColor (string) default : random color
    - Custom Food Color (#ff0000 || rgb(0,0,0))
- bot (int) default : true
    - Do you want the bot to play when you start the game?
- timeout (int) default : 1000
    - How long to wait in between game loses
- explosion (bool) default : true
    - Do you want to particle explosion when food is consumed

Supported Keys / Touches

- (swipeUp, swipeDown, swipeLeft, swipeRight) Mobile Touch Events  - Directional
- (UP/Down/Left/Right) Keyboard Arrow Keys - Directional
- (O) - Game On/Off
- (R) - Game Restart
- (B) - Enable Bot
- (+) - Increase Snake Frames Per Second
- (-) - Decrease Snake Frames Per Second
- (Space Bar) - Pause/Resume Toggle

Sample Markup

<script src="path/to/snake.build.min.js"></script>

<canvas id="snake-canvas" autofocus="autofocus" data-full-screen="true"></canvas>

<div id="scoreboard">
    <div id="score">
        Score :
        <span>0</span>
    </div>

    <div id="hi-score">
        Hi Score :
        <span>0</span>
    </div>

    <div id="bot-hi-score">
        Bot Hi Score :
        <span>0</span>
    </div>
</div>

<script>
    //Start Snake Game
    $(document).ready(function() {
        ResponsiveSnake.start({
            snakePixels    : 14,
            snakeSize      : 4,
            bot            : true,
            explosion      : true
        });
    });
</script>

To View The Example

visit http://iamchrismiller.github.io/responsive-snake/example/

OR clone the repo and open the example

git clone https://github.com/iamchrismiller/responsive-snake.git

npm install && grunt dev

open http://127.0.0.1:8000/example/

Contributing

In lieu of a formal style-guide, take care to maintain the existing coding style. Lint and test your code using grunt (dev).

License

Licensed under the MIT license.

Release History

  • 2014-06-20   v0.1.5   Added console strip on build
  • 2014-06-20   v0.1.4   Added custom snake head color
  • 2014-06-20   v0.1.3   Added key events for (+/-) Frames Per Second
  • 2014-06-17   v0.1.2   Fixed bot enabled flag
  • 2014-06-17   v0.1.1   Added "play" options, exports for AMD/CommonJS
  • 2014-06-17   v0.1.0   Initial Release

Author

Chris Miller


responsive-snake's People

Watchers

 avatar  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.