TypeError: Cannot read properties of undefined (reading '-5')

It gives line numbers like “at undefined:53042:53”
The number ranges from 0 to -5 depending on the length of my code.
here is the code

Have you copied and pasted the code from another editor?

It seems to me that you might have extra non-visible characters either at the line-ends or file-end.

I did get an undefined error of line 2 and when I deleted after the ; the sketch worked.

1 Like

BTW the game looks promising but I thought the the red dots very quickly became so fast I just gave up trying to touch the red dots.

Thanks that is a convention in the genre.
Make a game too hard to beat and then use upgrades until you can.
I used JShint to clean some stuff up.
So which ; do I have to delete?

When I first tried it I got an error on line 2, I clicked behind the ; e.g.

Screenshot 2024-08-09 at 17.23.48

Pressed the delete key (not the backspace) and it concatenated lines 2 & 3

Screenshot 2024-08-09 at 17.31.28

Then I pressed the enter key to move line 3 back and bingo your game started.

The most likely culprit is the EOL (End-of-line character) because it can vary depending on the code editor / OS.

I have been playing your game - it’s quite addictive once you undrstand the game play. Well done :+1:

2 Likes

Thank you so much you are a mensch do you mind saving the change you made?

Just noticed this. The editor will not allow me to make changes to another persons sketch.

Update
I have created a working copy here

1 Like

No worries
I fixed it by clicking on “tidy code” I suppose that stripped off the hidden characters.

1 Like

This is a really cool game!

However, the icon for slow drops upgrade does not show.
It just shows ⛛ .

I guess I chose the icon poorly LOL
⛛is the one I picked

I have been playing your game again very addictive - I must get back to my own programming LOL.

I noticed that as the game progressed and I managed to get bigger and slower drops I was trying to get the net very close to the top canvas border.

This disrupted game play in a number of ways

  1. if the mouse exits the canvas the net becomes ‘stuck’ until the mouse re-enters the canvas
  2. When trying to get drops in the top left corner it triggers the intro screen.
  3. The net is only partially visible.

I suggest that you introduce a solid border (borderWeoght ~20 pixels) and reduce the game play area to inside the border. Also rather than use mouseX and mouseY to control the net position you might introduce 2 new variables netX and netY then constrain these to inside the border like this

mouseMoved(){
  // constrain the net position to inside the border
  netX = constrain(mouseX, borderWeight, width - borderWeight);
  netY = constrain(mouseY, borderWeight, height - borderWeight);
}

I would move the ? button to bottom-right inside the border because it is not an area you might move the net.

Personally I think these would enhance the game and in particular the border will ‘frame’ the play area focusing the player’s attention to the game area.

Feel free to ignore these suggestions - after all it is your game not mine.

2 Likes

Those are fantastic Ideas. Also the constrain function is something I wish I knew about before I wrote my own lim function. I am glad you are enjoying the game. Are you playing on The Yellow Quadrangle by JakobVirgil or on the directly from p5.js?

I have been playing in the p5.js editor though I have just visited your site and read some of the comments.

Hopefully they were not too rude.
There is a new version
Organic raincoat by a.king.ink -p5.js Web Editor