-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e155929
commit 61eb2ff
Showing
5 changed files
with
145 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
body { | ||
margin: 0; | ||
height: 100vh; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
background-color: #333; | ||
overflow: hidden; | ||
} | ||
|
||
.dvdLogo { | ||
background: rgb(14, 18, 50); | ||
color: #fff; | ||
|
||
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif; | ||
|
||
position: absolute; | ||
|
||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: space-between; | ||
|
||
width: 20vw; | ||
height: 20vw; | ||
max-height: 90vh; | ||
height: max-content; | ||
} | ||
|
||
.eventImage { | ||
width: 100%; | ||
max-height: 90%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>screenIT - dvd logo</title> | ||
|
||
<link rel="stylesheet" href="css/dvd.css"> | ||
|
||
<script src="js/dvd.js" defer></script> | ||
</head> | ||
<body> | ||
<div id="dvdLogo" class="dvdLogo"> | ||
<img id="eventImage" class="eventImage" src="img/easterEggs/hubben-rattan-eating-1.png"></img> | ||
<p id="text">PIXELN GREJS</p> | ||
|
||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
const logo = document.getElementById('eventImage'); | ||
const dvdLogo = document.getElementById('dvdLogo'); | ||
const text = document.getElementById('text'); | ||
|
||
setMaxValues(); | ||
let x = Math.random() * maxX; | ||
let y = Math.random() * maxY; | ||
|
||
|
||
|
||
let xVelocity = 2; | ||
let yVelocity = 2; | ||
|
||
console.log("maxX: " + maxX) | ||
console.log("maxY: " + maxY) | ||
|
||
console.log(x) | ||
console.log(y) | ||
|
||
|
||
images = []; | ||
let pathToEventImages = "/img/eventImages/"; | ||
let currentImage = 0; | ||
|
||
function setMaxValues() { | ||
maxX = window.innerWidth - dvdLogo.offsetWidth; | ||
maxY = window.innerHeight - dvdLogo.offsetHeight; | ||
} | ||
|
||
async function getFutureImages() { | ||
return await fetch('/api/images/getFutureImages') | ||
.then(response => response.json()) | ||
.then(data => { | ||
return data; | ||
}); | ||
} | ||
|
||
function nextImage(){ // TODO: This function is what makes the div get stuck in the sides sometimes | ||
currentImage = (currentImage + 1) % images.length; | ||
logo.src = pathToEventImages + images[currentImage].path; | ||
|
||
setMaxValues(); | ||
text.innerHTML = images[currentImage].eventName || "Undertext"; | ||
} | ||
|
||
getFutureImages().then(newImages => { | ||
images = newImages | ||
}); | ||
|
||
function updatePosition() { | ||
x += xVelocity; | ||
y += yVelocity; | ||
|
||
if (x <= 0 && xVelocity < 0) { | ||
nextImage(); | ||
xVelocity *= -1; | ||
} else if (x >= maxX && xVelocity > 0) { | ||
nextImage(); | ||
xVelocity *= -1; | ||
} | ||
|
||
if (y <= 0 && yVelocity < 0) { | ||
nextImage(); | ||
yVelocity *= -1; | ||
} else if (y >= maxY && yVelocity > 0) { | ||
nextImage(); | ||
yVelocity *= -1; | ||
} | ||
|
||
dvdLogo.style.left = x + 'px'; | ||
dvdLogo.style.top = y + 'px'; | ||
} | ||
|
||
let intervalId; | ||
intervalId = setInterval(updatePosition, 10); | ||
running = true; | ||
|
||
document.addEventListener("keydown", (event) => { | ||
if (event.code === "Space") { | ||
if (running) { | ||
clearInterval(intervalId); | ||
running = false; | ||
} else { | ||
intervalId = setInterval(updatePosition, 10); | ||
running = true; | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters