GithubHelp home page GithubHelp logo

oop_game-v2's Introduction

OOP Treehouse FSJS Techdegree Project 4 - OOP Game App

https://rlertola.github.io/oop_game-v2/

This project was built using vanilla js.

App.js

App.js contains the listeners for the physical keyboard and the keyboard buttons on the screen.

Either the on-screen keyboard or the physical keyboard can be clicked. If the physical keyboard is used, the corresponding button on the screen is deactivated and changes color as if you were clicking on the button on the screen.

Helper functions helpe mostly with the keyboards. If the physical keyboard is clicked, findMatchingButton finds the corresponding key button on the screen. ResetKeyboard clears the keyboard of its classes, and toggleKeyboard takes a boolean to activate/deactivate the keyboard so no keys can be pushed when game is not in play.

Game.js

Game.js is a class that contains all the props and functions for game play. It creates a new game instance when the start button is pushed. A random phrase is picked, and added to the screen.

The handleInteraction function is the most used as it uses the other functions and checks which keyboard was clicked, which button was clicked, if it is a match, shows that letter on the board if so, removes lives if not, and checks if the game is won or lost.

The gameOver function has a 2.5 second delay before the overlay is displayed to give some time to view the board. The keyboards are deactivated during this time.

Helper functions removeOldPhrase removes the phrase html from the screen after a game is won or lost, and resetHearts puts the lives back when a new game is started.

Phrase.js

Phrase.js is a class that creates a phrase object. It is responsible for adding the phrase to the display, and checking if the letters selected are a match, and displaying them.

oop_game-v2's People

Contributors

rlertola avatar

Watchers

James Cloos 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.