this sucks

This commit is contained in:
Julian 2023-04-27 11:52:09 -04:00
parent 8d428d90a8
commit 366910861c
Signed by: NotNite
GPG Key ID: BD91A5402CCEB08A
7 changed files with 215 additions and 0 deletions

BIN
public/tic80/cart.tic Normal file

Binary file not shown.

View File

@ -0,0 +1,56 @@
import startTic80 from "./tic80.js";
const initialize = () => {
const canvasSelector = "#canvas";
const canvasElement = document.querySelector(canvasSelector);
const options = {
canvas: canvasElement,
arguments: ["/tic80/cart.tic"],
saveAs(blob, filename) {
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.download = filename;
link.click();
},
showAddPopup(callback) {
callback(null, null);
var input = document.createElement("input");
input.type = "file";
input.click();
input.addEventListener("change", (event) => {
const file = event.target.files[0];
if (file) {
var reader = new FileReader();
reader.onload = function (event) {
var rom = new Uint8Array(event.target.result);
callback(file.name, rom);
};
reader.readAsArrayBuffer(file);
}
});
},
preRun: [
function (module) {
module.ENV.SDL_EMSCRIPTEN_KEYBOARD_ELEMENT = canvasSelector;
}
]
};
startTic80(options);
}
const a = () => {
initialize();
document.querySelector("#canvas").removeEventListener("click", a);
document.querySelector("#deez-nuts").remove();
}
document.querySelector("#canvas").addEventListener("click", a);

96
public/tic80/index.html Normal file
View File

@ -0,0 +1,96 @@
<!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>TIC-80 tiny computer</title>
<style>
body {
margin:0; padding:0; background: #000; display: flex; justify-content: center; align-items: center; height: 100vh;
}
.tic80-container {
width: 100%; padding-top: 50%; position: relative;
}
.tic80-canvas {
position: absolute; top: 0; left:0; width: 100%; height: 100%;
}
.tic80-play {
position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; background: #1a1c2c; color: #fff; display: flex; justify-content: center; align-items: center; image-rendering: pixelated; cursor: pointer;
}
</style>
</head>
<body>
<div class="tic80-container">
<canvas class="tic80-canvas" id="canvas" oncontextmenu="event.preventDefault()" tabindex="1"></canvas>
<div class="tic80-play" id="tic80-play">
<img
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAF9JREFUOE+d0jsOACAIA1B6/0NjHDB+UFtcnPpC0sLd3cwMAPqvPgQQQRU6ABW6Aiz0BX4QDdwgGdihMjCgvUZlB73y0gXzViQgGxkFvNb5BJhZpwATTFtQggtQCQbQAJ4FQA3PbK2EAAAAAElFTkSuQmCC"
alt="Play"
width="64" height="64"
>
</div>
</div>
<script type="module">
import startTic80 from './tic80.js'
const initialize = () => {
const canvasSelector = '#canvas'
const canvasElement = document.querySelector(canvasSelector)
const playElement = document.getElementById('tic80-play')
const options = {
canvas: canvasElement,
arguments: ['cart.tic'],
saveAs (blob, filename) {
const url = URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = filename
link.click()
},
showAddPopup (callback) {
callback(null, null)
var input = document.createElement('input')
input.type = 'file'
input.click()
input.addEventListener('change', (event) => {
const file = event.target.files[0]
if (file) {
var reader = new FileReader
reader.onload = function(event) {
var rom = new Uint8Array(event.target.result)
callback(file.name, rom)
}
reader.readAsArrayBuffer(file)
}
})
},
preRun: [
function (module) {
module.ENV.SDL_EMSCRIPTEN_KEYBOARD_ELEMENT = canvasSelector
}
]
}
playElement.addEventListener('click', () => {
playElement.style.display = 'none'
canvasElement.focus()
startTic80(options)
})
}
window.addEventListener('DOMContentLoaded', initialize)
</script>
</body>
</html>

16
public/tic80/tic80.js Normal file

File diff suppressed because one or more lines are too long

BIN
public/tic80/tic80.wasm Normal file

Binary file not shown.

23
src/app/sekrit/page.tsx Normal file
View File

@ -0,0 +1,23 @@
import Tic80 from "@/components/Tic80";
export default function Page() {
return (
<div
style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
width: "100vw",
height: "100vh",
backgroundColor: "#1A1C2C",
textAlign: "center"
}}
>
<p style={{ position: "absolute", top: 0, left: 0 }} id="deez-nuts">
(click on screen!)
</p>
<Tic80 />
</div>
);
}

24
src/components/Tic80.tsx Normal file
View File

@ -0,0 +1,24 @@
"use client";
import React from "react";
export default function Tic80() {
return (
<div>
<canvas
className="tic80-canvas"
id="canvas"
onContextMenu={(e) => e.preventDefault()}
tabIndex={1}
width={1280}
height={720}
></canvas>
<script
type="module"
src="/tic80/disgusting-hack.js"
async
defer
></script>
</div>
);
}