Skip to content

Instantly share code, notes, and snippets.

@chrishamant
Last active August 29, 2015 14:24
Show Gist options
  • Save chrishamant/06a86b15d6fb69bb1071 to your computer and use it in GitHub Desktop.
Save chrishamant/06a86b15d6fb69bb1071 to your computer and use it in GitHub Desktop.

Revisions

  1. chrishamant revised this gist Jul 1, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion index.html
    Original file line number Diff line number Diff line change
    @@ -22,5 +22,5 @@
    </script>

    <body onload="init()">
    <p style="float:left" id="gamePiece"> X
    <img style="float:left" id="gamePiece" src="https://s-media-cache-ak0.pinimg.com/736x/fd/4d/74/fd4d74d5083647d78a68ce087b2e350c.jpg">

  2. chrishamant renamed this gist Jul 1, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. chrishamant created this gist Jul 1, 2015.
    26 changes: 26 additions & 0 deletions Silly Game
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    <script>

    function init(){
    var gameLength = 15000 // 15 seconds
    var s = 0 // Number of clicks
    var t = Date.now() //start time (in seconds since 1970)

    var elm = document.getElementById("gamePiece")

    elm.onclick = function(){
    s++

    var elapsed = Date.now() - t

    if(elapsed < gameLength){
    elm.style.margin = elapsed % 300 + ' 0 0 ' + elapsed * 7 % 300
    }else{
    alert(s) //number of clicks at end of game
    }
    }
    }
    </script>

    <body onload="init()">
    <p style="float:left" id="gamePiece"> X