From 5dea310f01a081ce6d0a84e0e5cbeb696f218380 Mon Sep 17 00:00:00 2001
From: Kyle <41976328+ImKyle4815@users.noreply.github.com>
Date: Fri, 16 Aug 2019 17:36:33 -0700
Subject: [PATCH] life
---
data/life/life.js | 24 +++++++++++-------------
life.html | 10 ++++++++--
2 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/data/life/life.js b/data/life/life.js
index f6bd1f72..7b5519db 100644
--- a/data/life/life.js
+++ b/data/life/life.js
@@ -2,10 +2,7 @@
// Card Conjurer, by Kyle Burton //
//============================================//
//define variables
-var playerCount, startingLifeTotal, firstPlayerWide = false, lastPlayerWide = false, playerList = [], rowHeight = 0, columnWidth = 0, rowCount = 0, isFullscreen = true, touchscreen = false, loop = false, activePlayerBoxes = []
-if ((typeof window.orientation !== "undefined") || (navigator.userAgent.indexOf('IEMobile') !== -1)) {
- isMobile = true
-}
+var playerCount, startingLifeTotal, firstPlayerWide = false, lastPlayerWide = false, playerList = [], rowHeight = 0, columnWidth = 0, rowCount = 0, isFullscreen = true, mouseClickId = 0
//This function sets everything up
function fullscreen() {
//Full screen!
@@ -229,12 +226,13 @@ function drawAllPlayerBoxes() {
}
}
//Event Listener magic! (always records mouse/touch positions so the loop can work without events)
-var touchX = [], touchY = [], clicking = false
+var touchX = [], touchY = []
document.getElementById("mainGrid").addEventListener("mousedown", startMouseCoordinates, true)
window.addEventListener("mousemove", updateMouseCoordinates, true)
window.addEventListener("mouseup", endMouseCoordinates, true)
function startMouseCoordinates() {
- playerList[event.target.customVarID - 1].touchId = 1
+ mouseClickId += 1
+ playerList[event.target.customVarID - 1].touchId = mouseClickId
singleTap(event.target)
}
function updateMouseCoordinates() {
@@ -299,22 +297,22 @@ function singleTap(targetPlayerBox) {
tappedPlayerBox.direction = lifeAdjust
tappedPlayerBox.life += lifeAdjust
drawPlayerBox(tappedPlayerBox.id)
- setTimeout(clockCheck.bind(null, tappedPlayerBox), 500)
+ setTimeout(clockCheck.bind(null, tappedPlayerBox, tappedPlayerBox.touchId), 500)
}
-function clockCheck(tappedPlayerBox) {
- if (tappedPlayerBox.touchId != 0.5) {
+function clockCheck(tappedPlayerBox, lastTapID) {
+ if (tappedPlayerBox.touchId == lastTapID) {
tappedPlayerBox.life += tappedPlayerBox.direction
drawPlayerBox(tappedPlayerBox.id)
if (tappedPlayerBox.holdTime >= 150) {
- setTimeout(clockCheck.bind(null, tappedPlayerBox), 10)
+ setTimeout(clockCheck.bind(null, tappedPlayerBox, tappedPlayerBox.touchId), 10)
} else if (tappedPlayerBox.holdTime >= 50) {
- setTimeout(clockCheck.bind(null, tappedPlayerBox), 50)
+ setTimeout(clockCheck.bind(null, tappedPlayerBox, tappedPlayerBox.touchId), 50)
} else {
- setTimeout(clockCheck.bind(null, tappedPlayerBox), 100)
+ setTimeout(clockCheck.bind(null, tappedPlayerBox, tappedPlayerBox.touchId), 100)
}
tappedPlayerBox.holdTime += 1
} else {
tappedPlayerBox.holdTime = 0
}
}
-//Updated!!! Are we there yet? Ooh! Is this it? ermagerd?
+//Updated :D
\ No newline at end of file
diff --git a/life.html b/life.html
index 05eca2f9..fc56a6c5 100644
--- a/life.html
+++ b/life.html
@@ -41,7 +41,7 @@
"description": "Card Conjurer: A free online tool that creates custom Magic: The Gathering Cards. Fast, easy, and offers a wide variety of card frames and other customizations. Planar cards, Ixalan maps, Planeswalkers, and more!",
"image": "http://cardconjurer.com/data/site/sampleCards/sample8.png",
"mainEntityOfPage": "cardconjurer.com",
- "name": "Card Conjurer"
+ "name": "Life Counter"
}
@@ -52,7 +52,7 @@
Starting Life Total:
- For an optimal experience, save this website to your home screen and open it from there.
+ For an optimal experience, save this website to your home screen and open it from there.
Check out my other website, Card Conjurer, to easily create custom Magic cards!