-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
71 lines (58 loc) · 3.54 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SMACKDAB!</title>
<style type="text/css">
.modal{display:none;position:fixed;z-index:1;padding-top:100px;left:0;top:0;width:100%;height:100%;overflow:auto;background-color:#000;background-color:rgba(0,0,0,.4)}
.modal-content{color: #333c57;position:relative;background-color:#fefefe;margin:auto;padding:2px 16px;border:1px solid #888;width:500px;box-shadow:0 4px 8px 0 rgba(0,0,0,.2),0 6px 20px 0 rgba(0,0,0,.19);-webkit-animation-name:animatetop;-webkit-animation-duration:.4s;animation-name:animatetop;animation-duration:.4s}@keyframes animatetop{from{top:-300px;opacity:0}to{top:0;opacity:1}}
.close{color:#000;float:right;font-size:28px;font-weight:700}
.close:focus,
.close:hover{color:#000;text-decoration:none;cursor:pointer}
#game-frame > div { font-size: 44px; font-family: monospace; font-weight: bold;}
/* You can set custom dimensions here */
.game { width: 100vw; height: 100vh; }
/* Uncomment to remove the frame on top of the canvas and start the game directly */
/* #game-frame { display: none; } */
</style>
</head>
<body style="margin:0; padding:0;">
<div class="game" style="margin: 0; position: relative; background: #1a1c2c;">
<div id="game-frame" style="cursor: pointer; position: absolute; margin: 0 auto; opacity: 1; background: #1a1c2c; width: 100%; height: 100%;">
<div style="text-align: center; color: white; display: flex; justify-content: center; align-items: center; width: 100%; height: 100%;">
<p style="margin: 0;">- CLICK TO PLAY -</p>
</div>
</div>
<canvas style="width: 100%; height: 100%; margin: 0 auto; display: block; image-rendering: pixelated;" id="canvas" oncontextmenu="event.preventDefault()" onmousedown="window.focus()"></canvas>
</div>
<div id="add-modal" class="modal">
<div class="modal-content">
<span class="close">×</span>
<p>Select a file to add to the computer</p>
<p><input type="file" id="upload-input"></input></p>
</div>
</div>
<script type="text/javascript">
var Module = {canvas: document.getElementById('canvas'), arguments:['cart.tic']}
const gameFrame = document.getElementById('game-frame')
const displayStyle = window.getComputedStyle(gameFrame).display;
if (displayStyle === 'none')
{
let scriptTag = document.createElement('script'), // create a script tag
firstScriptTag = document.getElementsByTagName('script')[0]; // find the first script tag in the document
scriptTag.src = 'tic80.js'; // set the source of the script to your script
firstScriptTag.parentNode.insertBefore(scriptTag, firstScriptTag); // append the script to the DOM
} else {
gameFrame.addEventListener('click', function() {
let scriptTag = document.createElement('script'), // create a script tag
firstScriptTag = document.getElementsByTagName('script')[0]; // find the first script tag in the document
scriptTag.src = 'tic80.js'; // set the source of the script to your script
firstScriptTag.parentNode.insertBefore(scriptTag, firstScriptTag); // append the script to the DOM
this.remove()
});
}
</script>
</body>
</html>