Commit c41ca65e authored by Evan Hahn's avatar Evan Hahn

More byte-shaving; at 1173, which is too big!

parent a283fbda
......@@ -6,11 +6,12 @@
* f = pressing Left?
* g = pressing Right?
* h = pressing Stop?
* i = used instead of `icon` in a function
* j = player speed
* k = player direction
* l = last tick time
* m = player X
* n = player Y
* j = player speed
* k = player direction
* p = player
* q = tick function
* r = scalar relative to screen size
......@@ -65,7 +66,7 @@ onkeyup = event => {
if (event.keyCode === 68) { g = 0 }
}
p = () => {
p = _ => {
// y[3][2] === turn speed
k += ((g * y[3][2]) - (f * y[3][2])) * s
......@@ -84,7 +85,7 @@ p = () => {
n = n % a.height
// this could probably be smaller ^
c.fillStyle = 'deeppink'
c.fillStyle = '#f19'
c.translate(m, n)
c.rotate(k)
c.beginPath()
......@@ -102,28 +103,24 @@ p = () => {
// Item
u = (type, itemX, itemY, me) => {
itemX = Math.random() * a.width
itemY = Math.random() * a.height
return (me = () => {
let icon // TODO
[c.fillStyle, icon] = y[type]
u = (type, itemX, itemY, me) => (
me = _ => {
[c.fillStyle, i] = y[type]
c.beginPath()
c.arc(itemX, itemY, r, 0, 7)
c.fill()
c.fillStyle = 'black'
c.fillText(icon, itemX, itemY)
c.fillText(i, itemX, itemY)
if (((itemX - m) ** 2 + (itemY - n) ** 2) < ((r * y[2][2]) ** 2)) {
y[type][2] += y[type][3]
y[type][4] += type === 4 ? y[type][3] : 1
e.splice(e.indexOf(me), 1)
}
})
}
}
)
// Define the list of entities
......@@ -131,8 +128,12 @@ e = [p]
// Add a new item periodically
;(v = () => {
e.push(u((Math.random() * y.length) | 0))
;(v = _ => {
e.push(u(
(Math.random() * 5) | 0,
Math.random() * a.width,
Math.random() * a.height
))
setTimeout(v, Math.random() * 4000)
})()
......
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