Why is my counter not working correct?

edited December 2017 in Questions about Code

OK, so I made it where my lights on my tree choose a random number then round the number. After they all chose a number and rounded it I'm trying to see what number has how many so the tree aint filled with a bunch of 1 and a few of the others, but everytime I tried I either get a number that cant even be possible because there not that many lights or the wrong number

main page https://paste.ofcode.org/LxNxk9MtQLrUJTQMxwGXYq



lights https://paste.ofcode.org/36tAArKaGBay7UfmkMi9kBA

here a picture the 10 says there are 10 light == 0 which is red. I only count 9;


ok, anyone know why my counter is off?


i counted 14 on this one;



  • Pleas post the code as text in one go here in the forum

    I told you how

    If I open the link it’s cut off

  • Can you tell us also the tab and line Numbers please ?

    I couldn’t find it....

  • Control con; Light[] light = new Light[153]; float timer, t; float room = 1; void setup() { size(600, 600); con = new Control(); for (int i = 0; i < light.length; i++) { con.update();//////////////////////////// this makes them if (light[i].z == 0){////////////////////// this looks at each color con.a1 += 1; //////////////////////// this adds one if color is red } } } void draw() { background(0); if (room == 1) { textSize(18); if (timer < 0 && room == 1) { for (int i = 0; i < light.length; i++) { light[i].s += 1; timer = 15; } } for (Light l : light) { l.show(); } } }

    lol, why do they got a system that messes up the code when you place it in the code block?

    I marked the lines where they are made and where they are counted and checked.

  • Edit post, highlight code, press Ctrl-o to format.

  • so do you see why it dont count right?

  • You are counting in con.a1, but you never use it

  • edited December 2017

    @chrisir so you saying even though my counter dont work I should still add the code it should do? wouldn't that just mess everything up? messed up code at the beginning will mess everything up in the code.

Sign In or Register to comment.