Giter Site home page Giter Site logo

js-game's Introduction

Javascript Game

상세설명

제한된 시간 내에 당근을 모두 없애는 게임입니다.
벌레를 클릭할 경우, 타임아웃이 되었을 경우 게임에서 지게 됩니다

1. Result

filtered

2. 사용언어

  • HTML
  • CSS
  • Javascript

주요기능

  • Play button 클릭 시 게임 시작(당근, 벌레, 카운트, 타이머 창 등장) 및 타이머 동작
  • 당근을 클릭할시 count의 개수가 줄어들고 count가 0 이 되면 win popup이 뜸
  • 벌레를 클릭 시 game이 stop되고 lose popup이 뜸
  • 게임 동작 중(started = true일 때) 정지버튼을 누르면 replay popup이 뜨고 게임을 재실행 할 수 있음

구현과정

  1. Math.random API를 이용하여 randomNumber를 호출하는 함수를 만든 뒤 init Game에서 당근과 벌레 이미지를 translate을 이용하여 정해진 갯수만큼 field내에 random한 위치에 뿌림
  2. setInterval을 이용해 startGameTimer함수를 생성하고 게임에서 지거나 게임이 정지될 때 clearInterval로 타이머를 제어함
  3. playGame과 stopGame함수를 만들고 started를 boolean으로 지정해서 게임이 동작하고 있는지 아닌지 여부에 따라 게임을 제어함
  4. field를 클릭할 때 당근과 벌레에 반응하는 이벤트 핸들러를 만들어주고 게임이 동작되지 않을때(started = false일 때)는 빠르게 return해주어 이벤트가 호출되지 않게 한다

js-game's People

Contributors

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