Code works fine with Java but not with JavaScript

edited December 2013 in JavaScript Mode

Hey mates,
i'm sorry i have to ask again for help for my recent project i'm working on.

The code now works fine in Java, but when i change the mode in Processing to JavaScript or upload the code to Openprocessing, there's something corrupt.
You see three dominoes, everyone should display a certain ammount of ellipses to show the time. My problem is that the stone in the middle never shows anything but it's coded like the third stone. Do you know what line in my code keeps the ellipses on the stone in the middle invisible?

Here's the link to Openprocessing: http://www.openprocessing.org/sketch/122588

Thank's so much in advance! :)

Answers

  • edited December 2013

    JavaScript has no variable types.

    On line 273, change

    int m1 = minute() / 10; // yields a float value in JS mode, e.g. for 23 one would obtain 2.3 and then all the comparisons do not match.

    to

    int m1 = int(minute() / 10);

    Another comment: While your sketch is looking nice, wouldn't it be advisable to restructure your code by using a general domino stone class and then just to pass the value and position of the stone to the display method of this class instead of repeating code over and over?

  • Wow, thank's so much!
    I'm actually still a beginner so i would never have found this little mistake.
    And yes i know the code is really much longer than it could be but with more time there will hopefully come more knowledge to myself so that i can code it shorter one day. :D

    Thank you again! :)

Sign In or Register to comment.