Giter VIP home page Giter VIP logo

typinggame's Introduction

TypingGame

Vanilla javascript로 구현한 타이핑게임입니다.
구현기간 : 2021년 11월 6일 ~ 12월 8일 (약 1달간)
사용언어 : HTML/CSS/Javascript

게임방법

  1. https://jirongkim.github.io/TypingGame/ 접속
  2. 게임시작 버튼 누르기
  3. 화면에 표시되는 영단어를 텍스트박스에 입력 후 Enter!

기능설명

  1. https://random-word-api.herokuapp.com/word?number=1000 해당 사이트 Ajax Get 요청하여 랜덤 단어를 받아옵니다.
axios.get('https://random-word-api.herokuapp.com/word?number=1000')
  .then(function (response) {
    response.data.forEach((word) => {
      if(word.length < 10){
        words.push(word);
      }
    });
    buttonChange('게임시작');
    console.log('finish');
    callback(words);
  })
  .catch(function (error) {
    // handle error
    console.log(error);
  });



  1. Enter Key가 입력되면, 입력한 영단어와 정답이 일치한지 확인합니다.
if(window.event.keyCode == 13)
    {
      if(userText.value == answer.innerText && GAMEINFO.isPlaying)
      {
        toast('1점 추가!');
        ...
      }
      else {
        toast('틀렸습니다!');
      }
    }



3. 좌측 상단에 표시되는 Toast 메세지는 이렇게 구현했습니다!

let removeToast;
export var toast = function(string) {
    const toast = document.getElementById("toast");

    toast.classList.contains("reveal") ?
        (clearTimeout(removeToast), removeToast = setTimeout(function () {
            document.getElementById("toast").classList.remove("reveal")
        }, 1000)) :
        removeToast = setTimeout(function () {
            document.getElementById("toast").classList.remove("reveal")
        }, 1000)
    toast.classList.add("reveal"), toast.innerText = string;
  }



전체 디자인

full_view

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.