From 76446f179d3de3b5635e8b4c40e1bd49ea99995c Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Thu, 19 Jan 2023 13:39:40 -0500 Subject: cube working --- public/gl/io/File.js | 11 +++++++++++ public/gl/io/Input.js | 16 ++++++++++++++++ public/gl/io/file.js | 11 ----------- 3 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 public/gl/io/File.js create mode 100644 public/gl/io/Input.js delete mode 100644 public/gl/io/file.js (limited to 'public/gl/io') diff --git a/public/gl/io/File.js b/public/gl/io/File.js new file mode 100644 index 0000000..2b3c23b --- /dev/null +++ b/public/gl/io/File.js @@ -0,0 +1,11 @@ +export const File = {} + +File.readFileAsync = async (path) => { + try { + let data = await fetch(path) + let text = await data.text() + return text + } catch (err) { + return undefined + } +} \ No newline at end of file diff --git a/public/gl/io/Input.js b/public/gl/io/Input.js new file mode 100644 index 0000000..ecc4af5 --- /dev/null +++ b/public/gl/io/Input.js @@ -0,0 +1,16 @@ +export const Input = {} + +const keys = {} +Input.setup = () => { + document.onkeydown = function(e) { + keys[e.key] = true + + }; + document.onkeyup = function(e) { + keys[e.key] = false + } +} + +Input.isKeyDown = (key) => { + return keys[key] +} \ No newline at end of file diff --git a/public/gl/io/file.js b/public/gl/io/file.js deleted file mode 100644 index f89565c..0000000 --- a/public/gl/io/file.js +++ /dev/null @@ -1,11 +0,0 @@ -export { readFileAsync } - -const readFileAsync = async (path) => { - try { - let data = await fetch(path) - let text = await data.text() - return text - } catch (err) { - return undefined - } -} \ No newline at end of file -- cgit v1.2.3-freya