Commit 19485093 authored by Evan Hahn's avatar Evan Hahn

Trim some more bytes

parent fdc90c96
......@@ -2,6 +2,7 @@
* a = canvas
* b = body
* c = context
* d = document (?)
* e = array of entities (functions that are called)
* f = pressing Left?
* g = pressing Right?
......@@ -41,29 +42,27 @@ y = [
// The stats element
b.appendChild(z = document.createElement('b'))
z.style.margin = z.style.padding = '1vh'
z.style.position = 'absolute'
z.style.fontSize = '4vh'
z.style.background = 'rgba(0,0,0,.8)'
// `z.style.bottom = 0` is done later to save bytes
// `z.style.top = 0` is done later to save bytes
// The player
m = a.width / 2
n = a.height / 2
j = k = f = g = h = z.style.bottom = 0
j = k = f = g = h = z.style.top = 0
onkeydown = event => {
if (event.keyCode === 32) { h = 1 }
if (event.keyCode === 65) { f = 1 }
if (event.keyCode === 68) { g = 1 }
if (event.keyCode === 37) { f = 1 }
if (event.keyCode === 39) { g = 1 }
}
onkeyup = event => {
if (event.keyCode === 32) {
h = 0
j += r / 2
}
if (event.keyCode === 65) { f = 0 }
if (event.keyCode === 68) { g = 0 }
if (event.keyCode === 37) { f = 0 }
if (event.keyCode === 39) { g = 0 }
}
p = _ => {
......@@ -95,10 +94,6 @@ p = _ => {
c.lineTo(-r * y[2][2], r * y[2][2])
c.fill()
c.setTransform(1, 0, 0, 1, 0, 0)
z.innerHTML = y.map(stat => (
`<font color="${stat[0]}">${stat[1]} ${stat[4]}</font>`
)).join(' ')
}
// Item
......@@ -111,7 +106,7 @@ u = (type, itemX, itemY, me) => (
c.arc(itemX, itemY, r, 0, 7)
c.fill()
c.fillStyle = 'black'
c.fillStyle = '#000'
c.fillText(i, itemX, itemY)
if (((itemX - m) ** 2 + (itemY - n) ** 2) < ((r * y[2][2]) ** 2)) {
......@@ -149,13 +144,17 @@ requestAnimationFrame(q = (currentTime) => {
// canvas font stuff is reset when screen is cleared
c.textAlign = 'center'
c.textBaseline = 'middle'
b.style.font = c.font = 'bold 3vh sans-serif'
c.font = b.style.font = 'bold 3vh sans-serif'
e.map(entity => entity())
if (y[4][2] <= 0) {
z.innerHTML = `<font color="gold">Game over! Score: ${y[0][2]}¢</font>`
z.innerHTML = `<b style='color:#fff'>Game over! Score: ${y[0][2]}¢`
} else {
z.innerHTML = y.map(stat => (
`<b style='color:${stat[0]}'>${stat[1]} ${stat[4]}</b>`
)).join(' ')
requestAnimationFrame(q)
}
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment