mirror of
https://github.com/Investigamer/cardconjurer.git
synced 2025-07-27 05:14:53 -05:00
life
This commit is contained in:
@@ -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
|
10
life.html
10
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"
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
@@ -52,7 +52,7 @@
|
||||
Starting Life Total:<br>
|
||||
<input id="inputStartingLife" class="input" type="number" min="0" value="40"><br>
|
||||
<button id="buttonStartGame" class="input" onclick="startGame()">Game On!</button><br><br>
|
||||
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.<br><a href="https://cardconjurer.com">Check out my other website, Card Conjurer, to easily create custom Magic cards!</a>
|
||||
</div>
|
||||
<div onclick="fullscreen()" class="hidden" id="return">CLICK ANYWHERE TO RETURN TO FULLSCREEN</div>
|
||||
<div id="gridShell">
|
||||
@@ -225,6 +225,12 @@
|
||||
.rngNumber {
|
||||
font-size: 4em;
|
||||
}
|
||||
a {
|
||||
color: white;
|
||||
}
|
||||
a:hover {
|
||||
color: grey;
|
||||
}
|
||||
</style>
|
||||
<script src="data/life/life.js"></script>
|
||||
<html>
|
||||
|
Reference in New Issue
Block a user