Skip to content

Commit

Permalink
Merge pull request #5 from leandroiohk/arcade-machine
Browse files Browse the repository at this point in the history
Project pages
  • Loading branch information
ch1bo committed Aug 1, 2024
2 parents 4b467d3 + 4a1db85 commit 6f8ac00
Show file tree
Hide file tree
Showing 62 changed files with 4,153 additions and 0 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added arcade-machine/assets/images/bg-0-5x.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arcade-machine/assets/images/bg-1-0x.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arcade-machine/assets/images/bg-1-5x.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arcade-machine/assets/images/doom-guy-1-0x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arcade-machine/assets/images/doom-guy-1-5x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arcade-machine/assets/images/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arcade-machine/assets/images/hydra-logo-2-0x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arcade-machine/assets/images/hydra-text-1-0x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arcade-machine/assets/images/hydra-text-1-5x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arcade-machine/assets/images/noise.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arcade-machine/assets/images/play-doom-button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arcade-machine/assets/images/speedometer-tick.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arcade-machine/assets/images/speedometer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
434 changes: 434 additions & 0 deletions arcade-machine/index.html

Large diffs are not rendered by default.

78 changes: 78 additions & 0 deletions arcade-machine/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
document.addEventListener("DOMContentLoaded", () => {
/**
* Modal
*/
const openModal = (modal) => {
if (modal) {
modal.style.display = "flex";

if (modal.id === "modal-game" || modal.id === "modal-intro") {
document
.querySelectorAll(".js-hide-when-modal-opens")
.forEach((element) => {
element.style.display = "none";
});
}
}
};

const closeModal = (modal) => {
if (modal) {
modal.style.display = "none";

if (modal.id === "modal-intro") {
document
.querySelectorAll(".js-hide-when-modal-opens")
.forEach((element) => {
element.style.display = "flex";
});
}
}
};

document.querySelectorAll("[data-modal-target]").forEach((button) => {
button.addEventListener("click", () => {
const modalId = button.getAttribute("data-modal-target");
const modal = document.getElementById(modalId);
openModal(modal);
});
});

document.querySelectorAll("[data-modal-close]").forEach((button) => {
button.addEventListener("click", () => {
const modal = button.closest(".modal");
closeModal(modal);
});
});

document.querySelectorAll("[data-modal-auto-open]").forEach((modal) => {
openModal(modal);
});

/**
* Copy to clipboard
*/
document.querySelectorAll("[data-copy-clipboard]").forEach((element) => {
element.addEventListener("click", (event) => {
const data = event.target.getAttribute("data-copy-clipboard");
navigator.clipboard.writeText(data).then(function () {
alert("Copied to clipboard: " + data);
});
});
});

/**
* Speedometer
*/

// Map range from [0, 500] to [0, 180]
function mapRange(value, inMin, inMax, outMin, outMax) {
return ((value - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin;
}

document.querySelectorAll("[data-speedometer-value]").forEach((element) => {
const value = element.getAttribute("data-speedometer-value");
const degree = mapRange(value, 0, 500, 0, 180);
element.style.transform = `rotate(${degree}deg)`;
});
});
Loading

0 comments on commit 6f8ac00

Please sign in to comment.