Skip to content

Commit

Permalink
enable adding blinker via click or touch
Browse files Browse the repository at this point in the history
  • Loading branch information
gbuesing committed Dec 1, 2014
1 parent 05da22b commit 8b6a37c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
line-height: 1.428571429;
color: #333;
background-color: #fff;
margin: 0;
border: 0;
}
a {
color: #428bca;
Expand All @@ -22,6 +24,7 @@
width: 758px;
height: 602px;
border: 1px dotted #ccc;
cursor: pointer;
}
</style>
</head>
Expand Down Expand Up @@ -203,5 +206,26 @@
game.next();
elem.textContent = game.toString();
}, 100);

elem.addEventListener("touchstart", handleStart, false);
elem.addEventListener("click", handleClick, false);

function addPattern(pattern, offsetX, offsetY) {
var matrixX = Math.round((offsetX / 758) * 90);
var matrixY = Math.round((offsetY / 602) * 30);
game.addPattern(pattern, matrixX - 2, matrixY - 2);
}

function handleClick (e) {
e.preventDefault();
addPattern(patterns['blinker'], e.offsetX, e.offsetY);
}

function handleStart(e) {
e.preventDefault();
addPattern(patterns['blinker'], e.changedTouches[0].pageX, e.changedTouches[0].pageY);
}


</script>
</html>

0 comments on commit 8b6a37c

Please sign in to comment.