Skip to content

Commit

Permalink
pewpewpew!
Browse files Browse the repository at this point in the history
  • Loading branch information
kaliumxyz committed May 7, 2017
1 parent fb42898 commit b5be112
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 41 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 10 additions & 12 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@
</main>
<h1>press space or tap the screen</h1>
<div class='center'>
<ul class='options terminal'>
<li>
<span class='cursor'>b</span>ounds? <span class="option active">y</span>/<span class='option'>n</span>
</li>
<li>
gravity? <span class='option active'>[wiggly]</span>/<span class='option'>[wigglyInverse]</span>/<span class='option'>[regular]</span>
</li>
<li>
collisions? <span class='option'>[boring]</span>/<span class='option active'>[care]</span>
</li>

</ul>

<div class='terminal'>
<div class='terminal-ghost'></div>
<div class='options terminal-main'>
bounds? <span class="option active">y</span>/<span class='option'>n</span>
gravity? <span class='option active'>[wiggly]</span>/<span class='option'>[wigglyInverse]</span>/<span class='option'>[regular]</span>
collisions? <span class='option'>[boring]</span>/<span class='option active'>[care]</span>

</div>
</div>
</div>

<canvas width="1000" height="1000">If you can read this, your browser does not support HTML5 canvas.</canvas>
Expand Down
47 changes: 33 additions & 14 deletions app/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
`<span class="cursor">${terminal.innerText[currentPosition]}</span>`,
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 class="cursor">(.*?)<\/span>/,'<span class="cursor">$1</span>$2')
terminal.innerHTML = match
const terminal = select('.terminal-main')
const ghost = select('.terminal-ghost')
const match = replaceChar(
terminal.innerText,
`<span class="cursor">${terminal.innerText[currentPosition]}</span>`,
currentPosition--
)
ghost.innerHTML = match
},
right: ev => {
const terminal = select('.terminal')
const match = terminal
.innerHTML
.replace(/<span class="cursor">(.*?)<\/span>(.)/,'$1<span class="cursor">$2</span>')
terminal.innerHTML = match
const terminal = select('.terminal-main')
const ghost = select('.terminal-ghost')
const match = replaceChar(
terminal.innerText,
`<span class="cursor">${terminal.innerText[currentPosition]}</span>`,
currentPosition++
)
ghost.innerHTML = match
},
}

Expand Down
21 changes: 16 additions & 5 deletions app/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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% {
Expand All @@ -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;
Expand Down
21 changes: 16 additions & 5 deletions assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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% {
Expand All @@ -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;
Expand Down
19 changes: 15 additions & 4 deletions assets/style.sass
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand All @@ -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
Expand Down

0 comments on commit b5be112

Please sign in to comment.