Some problem in pushing blocks in p5.js sketch

https://editor.p5js.org/Nis_Collect/sketches/eeOTXD_D2
:point_up::point_up::point_up::point_up::point_up::point_up::point_up::point_up::point_up::point_up::point_up::point_up::point_up::point_up::point_up::point_up::point_up::point_up::point_up::point_up:
Above is the link of my code…
I want to push a new block every time i click. But my code has some problem which makes it “doesn’t seem to work well”…
According to me…I couldn’t use proper values for mouseX and mouseY…please please please check and please recommended me the best and the most proper answer.
Someone please please please suggest me, whete am i getting wrong in my code…and also how could i correct any problem if there in my code.

Please please please please please someone help

You forgot the new keyword on line 59.
It should be:

b.push(new B());

If you don’t use new then you are just calling the function and, as the function doesn’t return anything, you will end up pushing undefined to your array (b).

3 Likes

Ya ok…Thanks…Its working now…
But still if you try and run my sketch you will also experience something wrong. The blocks aren’t getting inserted at the proper mouseX and mouseY.
Please please please check it and answer me please

Sir please respond…please please please.please please please.please please please