Xmas and Javascript, part 2 · Dez 10, 18:02

I just uploaded a new version of my xmas js1k submission. It features a significant graphics upgrade and some insane optimizations. Here are the highlights:

function K(x,y,r,u,v) {
  r ? a.beginPath() | a.fill(a.arc(x,y,r,u||0,v||7,0))
    : a.fillStyle = '#'+'a000b4bbfff5'.substr(x,3);
  return K
}

So, this function…

p = (x|y) >> 8

This line checks whether the x and y coordinates are not in the game area (between 0 and 256).
More precisely, p is 0 if the values are valid. The coordinates can be checked in one step since the size of the area is a power of 2(2^n) and the bit representation of all valid values have 1’s only in the last n bytes(negative numbers have at least one leading 1, see Two’s complement).

— arne

---

Kommentare

Textile-Hilfe