-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhalloween.html
More file actions
80 lines (73 loc) · 3.27 KB
/
Copy pathhalloween.html
File metadata and controls
80 lines (73 loc) · 3.27 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE html>
<html>
<head>
<!-- Import a creepy font from google -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Sixtyfour+Convergence&display=swap" rel="stylesheet">
<title>Among Us</title>
<style>
body {
background-color: rgb(4, 17, 36);
font-family: "Sixtyfour Convergence";
}
</style>
</head>
<body>
<div id="game"></div>
<script>
// Gets an element based on id, either from the body or from a more specific element
function elem(a,b) {
return (b != null) ? a.getElementById(b) : document.getElementById(a);
}
var game = elem("game");
function create(a,b) {
game.innerHTML = game.innerHTML + "<" + a + " id='" + b + "'>" + "</" + a + ">;
}
var run = setInterval(clock, 100); // Runs every 100 ms (1/10 of a second);
create("h1","sus");
var header = elem("sus");
header.innerHTML = "ohio time";
var scheduler = [];
// function ATS is "Add to Schedule". Adds a function identifier and how many times the function should be run
function ATS(identifier, input, init) {
scheduler.push(identifier);
scheduler.push(input);
scheduler.push(init);
}
// This function is run every 100 ms (1/10 of a second), and each time goes through the scheduler and executes each function.
// This is also the core game loop
function clock() {
let toDelete = [];
// Loop through the scheduler list
for (let i = 0; i < scheduler.length; i+=3) {
let cur = scheduler[i];
let input = scheduler[i+1];
let curi = scheduler[i+2];
// Checks the function identifier, executes the function
switch (cur) {
case "text":
// Input 0 = element; input 1 = string; input 2 = already;
input[0].innerHTML = input[2] + input[1].substring(0,input[1].length-curi);
break;
}
// Decreases the iteration of the function, and if it's at 0, add it to be deleted
if (curi >= 1) {
scheduler[i+2] -= 1;
} else {
toDelete.push(i);
}
}
// Goes through functions to be deleted and removes them from the scheduler
for (let i = toDelete.length-1; i >= 0; i--) {
scheduler.pop(i);
scheduler.pop(i);
scheduler.pop(i);
}
}
function fancyText(id, string) {
ATS('text', [elem(id), string, header.innerHTML], string.length);
}
</script>
</body>
</html>