-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
30 lines (25 loc) · 799 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"use strict";
// MIT License btw HaHAA
function createCard(cardType, mouseEvent) {
const origAudio = document.getElementById(cardType+"-audio");
const newAudio = origAudio.cloneNode()
const origImage = document.getElementById(cardType+"-image");
const newImage = origImage.cloneNode();
newAudio.play()
newImage.style.top = (mouseEvent.clientY - 198) + "px";
newImage.style.left = (mouseEvent.clientX - 143) + "px";
newImage.classList.remove("preload");
const body = document.getElementsByTagName("body")[0];
body.appendChild(newImage);
}
function click(mouseEvent) {
const percentChanceSquire = 0.25;
let cardType;
if (Math.random() < 0.25) {
cardType = "squire";
} else {
cardType = "knight";
}
createCard(cardType, mouseEvent);
}
document.addEventListener("click", click);