diff --git a/README.md b/README.md index ca185cc..2e468c9 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Just clone the repo or download the files. ``` $ git clone https://github.com/kaliumxyz/asap ``` -Then go to the dir and run nmp +Then go to the dir and run npm ``` $ cd asap $ npm diff --git a/app/index.html b/app/index.html index 0d81f74..ed51225 100644 --- a/app/index.html +++ b/app/index.html @@ -11,18 +11,16 @@

press space or tap the screen

- + +
+
+
+bounds? y/n +gravity? [wiggly]/[wigglyInverse]/[regular] +collisions? [boring]/[care] + +
+
If you can read this, your browser does not support HTML5 canvas. diff --git a/app/load.js b/app/load.js index edb81ea..3135eba 100644 --- a/app/load.js +++ b/app/load.js @@ -4,39 +4,58 @@ const select = selector => document.querySelector(selector) const selectAll = selector => document.querySelectorAll(selector) +const replaceChar = (string, substring, index) => string.substr(0, index - 1) + substring + string.substr(index) + const loadScript = _ => { let script = document.createElement("script") - script.setAttribute("src","main.js") + script.setAttribute("src", "main.js") select("head").appendChild(script) select('h1').innerText = "A Simple Aesthetic Particle engine" - select('.options').setAttribute('style','display:none;') + select('.options').setAttribute('style', 'display:none;') + select('.terminal-ghost').remove() } const canvas = select('canvas') window.onresize = _ => { - canvas.width = window.innerWidth - canvas.height = window.innerHeight + canvas.width = window.innerWidth + canvas.height = window.innerHeight + const terminal = select('.terminal-main') + const ghost = select('.terminal-ghost') + const match = replaceChar( + terminal.innerText, + `${terminal.innerText[currentPosition]}`, + currentPosition + ) + ghost.innerHTML = match } window.onload = window.onresize +let currentPosition = 2 + // look I'll fix this later lol. const moveCursor = { left: ev => { - const terminal = select('.terminal') - const match = terminal - .innerHTML - .replace(/(.)(.*?)<\/span>/,'$1$2') - terminal.innerHTML = match + const terminal = select('.terminal-main') + const ghost = select('.terminal-ghost') + const match = replaceChar( + terminal.innerText, + `${terminal.innerText[currentPosition]}`, + currentPosition-- + ) + ghost.innerHTML = match }, right: ev => { - const terminal = select('.terminal') - const match = terminal - .innerHTML - .replace(/(.*?)<\/span>(.)/,'$1$2') - terminal.innerHTML = match + const terminal = select('.terminal-main') + const ghost = select('.terminal-ghost') + const match = replaceChar( + terminal.innerText, + `${terminal.innerText[currentPosition]}`, + currentPosition++ + ) + ghost.innerHTML = match }, } diff --git a/app/style.css b/app/style.css index 5bff216..fd54200 100644 --- a/app/style.css +++ b/app/style.css @@ -2,7 +2,8 @@ html, body, canvas { margin: 0; padding: 0; overflow: hidden; - font-family: 'Roboto Mono', monospace; } + font-family: 'Roboto Mono', monospace; + background: white; } @keyframes blink { 0% { @@ -25,16 +26,26 @@ h1 { user-select: none; } .center { + top: 280px; position: fixed; width: 100%; } -.options { - background: black; - color: white; +.terminal { margin: 0 auto; padding: 10px; width: 540px; - user-select: none; } + user-select: none; + z-index: -1; } + +.terminal-main { + background: black; + color: white; + white-space: pre-wrap; } + +.terminal-ghost { + color: transparent; + position: absolute; + white-space: pre-wrap; } .option { padding: 0; diff --git a/assets/style.css b/assets/style.css index 5bff216..fd54200 100644 --- a/assets/style.css +++ b/assets/style.css @@ -2,7 +2,8 @@ html, body, canvas { margin: 0; padding: 0; overflow: hidden; - font-family: 'Roboto Mono', monospace; } + font-family: 'Roboto Mono', monospace; + background: white; } @keyframes blink { 0% { @@ -25,16 +26,26 @@ h1 { user-select: none; } .center { + top: 280px; position: fixed; width: 100%; } -.options { - background: black; - color: white; +.terminal { margin: 0 auto; padding: 10px; width: 540px; - user-select: none; } + user-select: none; + z-index: -1; } + +.terminal-main { + background: black; + color: white; + white-space: pre-wrap; } + +.terminal-ghost { + color: transparent; + position: absolute; + white-space: pre-wrap; } .option { padding: 0; diff --git a/assets/style.sass b/assets/style.sass index 9e451b8..6dc2adb 100644 --- a/assets/style.sass +++ b/assets/style.sass @@ -3,6 +3,7 @@ html, body, canvas padding: 0 overflow: hidden font-family: 'Roboto Mono', monospace + background: white @keyframes blink 0% {background: rgba(255,105,180,0.8)} @@ -22,17 +23,27 @@ h1 user-select: none .center - top: + top: 280px position: fixed width: 100% -.options - background: black - color: white +.terminal margin: 0 auto padding: 10px width: 540px user-select: none + z-index: -1 + +.terminal-main + background: black + color: white + white-space: pre-wrap + + +.terminal-ghost + color: transparent + position: absolute + white-space: pre-wrap .option padding: 0