Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This never presses the down key. A small correction so it'll move randomly in all directions

  function step() {
      var eventObj = document.createEvent("Events");
      eventObj.initEvent("keydown", true, true);
      eventObj.which = 37 + Math.floor(Math.random(0, 1)*4);
      document.dispatchEvent(eventObj);   
  }
  int = setInterval(step, 0.001);


I think that's the point, since one of the key strategies to this game is to only use 3 of the direction keys.


I didn't realize that :-p Good looking out!




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: