mirror of
https://github.com/Investigamer/cardconjurer.git
synced 2025-07-27 21:31:39 -05:00
life
This commit is contained in:
@@ -2,10 +2,7 @@
|
|||||||
// Card Conjurer, by Kyle Burton //
|
// Card Conjurer, by Kyle Burton //
|
||||||
//============================================//
|
//============================================//
|
||||||
//define variables
|
//define variables
|
||||||
var playerCount, startingLifeTotal, firstPlayerWide = false, lastPlayerWide = false, playerList = [], rowHeight = 0, columnWidth = 0, rowCount = 0, isFullscreen = true, touchscreen = false, loop = false, activePlayerBoxes = []
|
var playerCount, startingLifeTotal, firstPlayerWide = false, lastPlayerWide = false, playerList = [], rowHeight = 0, columnWidth = 0, rowCount = 0, isFullscreen = true, mouseClickId = 0
|
||||||
if ((typeof window.orientation !== "undefined") || (navigator.userAgent.indexOf('IEMobile') !== -1)) {
|
|
||||||
isMobile = true
|
|
||||||
}
|
|
||||||
//This function sets everything up
|
//This function sets everything up
|
||||||
function fullscreen() {
|
function fullscreen() {
|
||||||
//Full screen!
|
//Full screen!
|
||||||
@@ -229,12 +226,13 @@ function drawAllPlayerBoxes() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Event Listener magic! (always records mouse/touch positions so the loop can work without events)
|
//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)
|
document.getElementById("mainGrid").addEventListener("mousedown", startMouseCoordinates, true)
|
||||||
window.addEventListener("mousemove", updateMouseCoordinates, true)
|
window.addEventListener("mousemove", updateMouseCoordinates, true)
|
||||||
window.addEventListener("mouseup", endMouseCoordinates, true)
|
window.addEventListener("mouseup", endMouseCoordinates, true)
|
||||||
function startMouseCoordinates() {
|
function startMouseCoordinates() {
|
||||||
playerList[event.target.customVarID - 1].touchId = 1
|
mouseClickId += 1
|
||||||
|
playerList[event.target.customVarID - 1].touchId = mouseClickId
|
||||||
singleTap(event.target)
|
singleTap(event.target)
|
||||||
}
|
}
|
||||||
function updateMouseCoordinates() {
|
function updateMouseCoordinates() {
|
||||||
@@ -299,22 +297,22 @@ function singleTap(targetPlayerBox) {
|
|||||||
tappedPlayerBox.direction = lifeAdjust
|
tappedPlayerBox.direction = lifeAdjust
|
||||||
tappedPlayerBox.life += lifeAdjust
|
tappedPlayerBox.life += lifeAdjust
|
||||||
drawPlayerBox(tappedPlayerBox.id)
|
drawPlayerBox(tappedPlayerBox.id)
|
||||||
setTimeout(clockCheck.bind(null, tappedPlayerBox), 500)
|
setTimeout(clockCheck.bind(null, tappedPlayerBox, tappedPlayerBox.touchId), 500)
|
||||||
}
|
}
|
||||||
function clockCheck(tappedPlayerBox) {
|
function clockCheck(tappedPlayerBox, lastTapID) {
|
||||||
if (tappedPlayerBox.touchId != 0.5) {
|
if (tappedPlayerBox.touchId == lastTapID) {
|
||||||
tappedPlayerBox.life += tappedPlayerBox.direction
|
tappedPlayerBox.life += tappedPlayerBox.direction
|
||||||
drawPlayerBox(tappedPlayerBox.id)
|
drawPlayerBox(tappedPlayerBox.id)
|
||||||
if (tappedPlayerBox.holdTime >= 150) {
|
if (tappedPlayerBox.holdTime >= 150) {
|
||||||
setTimeout(clockCheck.bind(null, tappedPlayerBox), 10)
|
setTimeout(clockCheck.bind(null, tappedPlayerBox, tappedPlayerBox.touchId), 10)
|
||||||
} else if (tappedPlayerBox.holdTime >= 50) {
|
} else if (tappedPlayerBox.holdTime >= 50) {
|
||||||
setTimeout(clockCheck.bind(null, tappedPlayerBox), 50)
|
setTimeout(clockCheck.bind(null, tappedPlayerBox, tappedPlayerBox.touchId), 50)
|
||||||
} else {
|
} else {
|
||||||
setTimeout(clockCheck.bind(null, tappedPlayerBox), 100)
|
setTimeout(clockCheck.bind(null, tappedPlayerBox, tappedPlayerBox.touchId), 100)
|
||||||
}
|
}
|
||||||
tappedPlayerBox.holdTime += 1
|
tappedPlayerBox.holdTime += 1
|
||||||
} else {
|
} else {
|
||||||
tappedPlayerBox.holdTime = 0
|
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!",
|
"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",
|
"image": "http://cardconjurer.com/data/site/sampleCards/sample8.png",
|
||||||
"mainEntityOfPage": "cardconjurer.com",
|
"mainEntityOfPage": "cardconjurer.com",
|
||||||
"name": "Card Conjurer"
|
"name": "Life Counter"
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
Starting Life Total:<br>
|
Starting Life Total:<br>
|
||||||
<input id="inputStartingLife" class="input" type="number" min="0" value="40"><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>
|
<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>
|
||||||
<div onclick="fullscreen()" class="hidden" id="return">CLICK ANYWHERE TO RETURN TO FULLSCREEN</div>
|
<div onclick="fullscreen()" class="hidden" id="return">CLICK ANYWHERE TO RETURN TO FULLSCREEN</div>
|
||||||
<div id="gridShell">
|
<div id="gridShell">
|
||||||
@@ -225,6 +225,12 @@
|
|||||||
.rngNumber {
|
.rngNumber {
|
||||||
font-size: 4em;
|
font-size: 4em;
|
||||||
}
|
}
|
||||||
|
a {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
a:hover {
|
||||||
|
color: grey;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<script src="data/life/life.js"></script>
|
<script src="data/life/life.js"></script>
|
||||||
<html>
|
<html>
|
||||||
|
Reference in New Issue
Block a user