Connect four game sketch working in Java mode but not in JavaScript mode

edited January 2014 in JavaScript Mode

My sketch: http://www.openprocessing.org/sketch/130226 is working in Java mode but not in JavaScript mode. You are supposed to be able to move the coin with the arrow keys. First I thought the key input is not working but after a few tests it appears that the program is frozen. Sadly it's not giving any errors. I found a lot threats with the similar problems but I could not figure out why my sketch is not working.

Tagged:

Answers

  • Answer ✓

    In JavaScript, functions are stored in variables. Thus we can't assign them something else lest we lose the function reference:

    TypeError: reset is not a function

  • edited January 2014

    Thanks for the fast answer :) Sorry, I am a big noob with this stuff. But do I understand right that when I just copy the code of my functions directly into void draw() it might work? They are not really needed anyways I just made em to give it more structure (at least I tried to) or is there a better solution?

  • Answer ✓

    I guess it wasn't clear enough:
    We can't have variables and functions sharing the same name in JS! (~~)

  • edited January 2014

    I am dumb, now I got it. I changed the names but it's still not working #-o Thanks for helping a noob like me out. But I guess I just made more silly mistakes.

  • edited January 2014

    I figured it out. #:-S The problem was that in JS "delay();" isn't working. Or at least it is working for me after replacing it :-bd

  • delay() is to be avoided in Java Processing too! They even removed it for a while...

Sign In or Register to comment.