Monday 8 May 2017

Implement this Typing game Codepen with websockets for two players?

I found this codepen here https://codepen.io/nikola1970/pen/oxXbmb and I am curious how I can implement this for a two player game using websockets with NodeJS and Ember. It would only be a single page and assuming that only two people will ever visit this site at a time to play this game. I would be implementing this game using ember as well but that is in progress. I am just not too sure how to make it a 2 player game.

function countdown() {
    points = 0;
    var timer = setInterval(function(){
        button.disabled = true;
        seconds--;
        temp.innerHTML = seconds;
        if (seconds === 0) {
            alert("Game over! Your score is " + points);
            scoreDiv.innerHTML = "0";
            words.innerHTML = "";
            button.disabled = false;
            clearInterval(timer);
            seconds = 60;
            timerDiv.innerHTML = "60";
            button.disabled = false;    
        }
    }, 1000);
}

Just pasted the code above since it's a requirment for stack overflow.



via luiscovar

No comments:

Post a Comment