Giter Site home page Giter Site logo

rockpaperscissors-app-game-pure-js's Introduction

DRUM KIT

There is a drum kit application for childs. You have seven clickable drums and their voice. But page is broken and not working. Try to fix it.

First create a variable drum1 that reaches first drum.

Assign drum1 clicking expression to an empty arrow function. This function will make sound when button is clicked.

Inside this function ; Make the sound active. Look at your Project folder, you found sounds for each drum. HİNT: usage; “new Audio("somesound.mp3").play();”

Start your function and see if it is working.

Now you can make this for all drums but do not.

Create a variable that takes all drums at the page. Use querySelectorAll. This will gives you an array consist of all drums. Now you can create a for loop for each element in that variable.

İnside this for loop create your onclick function and make all sounds working properly. You can use button values to manipulate (reach and play) sounds. (Or use innerHTML values)

Refresh your page and see if your game is working when you are clicking the buttons.

Now your game is ready to play but there is something else to do: Keypress. Some users want to control drums by using keyboard.

Create an event listener to the DOM. This time use “keypress” instead of “click”. It will gives you the key pressed on the keyboard. İnside this function print your keys pressed by keyboard to the console. Make sure you got the correct keys.

Now write your script to run each sound according to the key.

  1. CHALLENGE There is no effect in your game. Use same event listener to create an animation function. When user pressed the key, related button will take the class of “pressed” that has been already created in .css file. And also don’t forget to remove this class automaticaly after a short while. HİNT: setTimeout();

Good luck!

rockpaperscissors-app-game-pure-js's People

Contributors

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