codegolf / pac-man

Pac-Man in < 512 Bytes of HTML and JavaScript

Home Page:http://codegolf.github.io/pac-man/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Remove Single Quotes

aemkei opened this issue · comments

We could try to use "onload" without the single quotes by replacing all > with < and the space with \u00A0.

onload=`...`
onload=...

I would love to see how to transform the code here.

This is where we have to change >> to <<.

k + 1 >> 2 || 9 & l[...]

I'm not that familiar with refactoring bitwise shifts, so any help is welcome!

As I can understand, k+1>>2 is a keypress guard that returns falsy values if (and only if) k is >=-1 and <= 2.

There's another dirty (and short) way to check it, 2%k. Unfortunately, it yields 0 for -2 (Home key) as well and the pacman moves up with double speed. I don't know if you're okay with that.

Alternatively we could add %4 somewhere into k=e.which-38 so any pressed key would be a valid control.

I'm on Mac OS without a Home-Key, so that sounds like it could work!