Giter Site home page Giter Site logo

joey-ma / catch Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 6.76 MB

Catch is a classic snake game in Pokemon theme.

Home Page: https://yoyoyojoe.github.io/catch

JavaScript 90.46% HTML 3.06% CSS 6.48%
dom-manipulation snake css game html javascript

catch's Introduction

Catch

Snake is one of the first video game genres. Catch, a browser based version of the classic snake game, is created using an understanding of OOP and DOM manipulation to create this dynamic, single-page app. Catch is a tribute to both the classic snake game as well as the Pokemon franchise.

I still remember playing the 1st generation (monochrome) and 2nd generation (color) Game Boys! Anyways...

Hope you'll enjoy!

Gotta Catch 'Em All

The game was built for desktop users in mind, and it is optimized for Google Chrome.

Note this game is not optimized for mobile devices.

Click anywhere inside the #gameboard, and you can use up, down, left, right arrow keys to start the game and move Ash (Snake Head).

Some keyboard shortcuts for you as you play this game:
Press P to play and pause the music.
Press M to mute the audio!
Press E to set game level to Easy.
Press N to set game level to Normal.
Press H to set game level to Hard.
Press Space to pause and resume the game. Press Enter to restart the game at anytime.

Learning Objectives

  • Using JavaScript to change the look and behavior of the DOM
  • React to user input
  • Utilize object-oriented programming

The Journey

Building Snake

  1. The snake is consisted of two files, Head.js & Body.js, with Apple consisting of, well, Apple.js.
  • Head
  • Body
  • Apple

Because each of the files is included in a script tag on index.html, these three classes are available to our main.js file (which is included AFTER the other script tags). To access classes (or instances of classes) from other classes, experiment leaving out the var, let, or const keywords. *Always be careful when messing with the global scope!

  1. Head Class

    • Make the head of the snake be able to turn based on the arrow keys
    • When the head of the snake reaches a border, end the game
  2. Apple Class

    • The apple should appear randomly on the screen
    • The apple should appear within the size of the board
    • Remove the apple when the head of the snake reaches the apple
    • Another apple should appear on the screen
    • The apple should not appear on the snake

Extension Challenges

  1. Head Class

    • The head of the snake should not be able to move backwards
  2. Body Class

    • Add a segment to the snake when the head of the snake reaches an apple
    • End the game when the snake runs into its own segment
  3. Make it your own!

    • Once you've gotten the core functionality down, feel free to have fun! Modify the functionality, look, even sound of your game. Get creative!

Testing

While we can certainly write tests for this, the more intuitive approach is to try playing the game by opening index.html in your browser.

Stretch Goals

  • add keyboard shortcuts to turn on/off the music (currently autoplay is off)
  • add a pause functionality when hitting space bar
  • improve code logic / readability
  • add a larger background music collection

catch's People

Contributors

joey-ma-steelgem avatar

Stargazers

 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.