Game Development Reference
In-Depth Information
//
------------------------------------------------------------
// Fired when draggable is dropped inside a
target (onDrop)
//
------------------------------------------------------------
function startGame() {
// Keep the game from starting more than once
if (!isPlaying) {
// Register input handlers
document.body.addEventListener("keyup",
doOnKeyUp);
document.body.addEventListener("keydown",
doOnKeyDown);
// Reposition the bowl lid
var bowlTop =
document.querySelector("#bowl-top");
bowlTop.classList.remove("bowl-closed");
bowlTop.style.left = (event.screenX -
bowlTop.offsetWidth + 65) + "px";
bowlTop.style.top = (event.screenY -
bowlTop.offsetHeight + 65 * 0) + "px";
// Disable dragging on the lid by removing
the HTML5 draggable attribute
bowlTop.removeAttribute("draggable");
bowlTop.classList.remove("dragging-icon");
newJelly();
isPlaying = true;
// Start out the main game loop
gameTimer = setInterval(tick, 15);
Search WWH ::




Custom Search