Math doesn't work?

Hey so why when I do location.y-brick1.y ,location 1 is positive brick1 is -500 it gives out a negative number? Like location.y–500 is location.y +500 so that’s positive. Do math rules not apply in processing?

Math rules do apply : P
can you share your code so we can see the issue? Usually for things like this, you should print the values of all the variables and work your way from there. You can also use the debugger. Doing so, you can diagnose the issue most of the time.

1 Like

well the code is kinda complicated(it’s a brick breaker game) or maybe not complicated for you but long I think if I share this snippet it’s enough if you want the whole thing tell me but I think I’ll just confuse you if I share the whole thing and also it’s kinda copy paste the same stuff so if I fix one I fix - Locked Paste Password:99EDhzwYM0 also look at comments //

tldr the problem is the teleporting to-500 -500,do you know any way to remove a rectangle from a 600 by 600 frame without teleporting?

There is definitely no error in processing

Maybe your value is off

You could just check if brick.y== -500
then don’t check and draw it (a work around)

yes the problem is caused by teleporting the rectangle. So is there any other way to erase it without teleporting?

and brick1 is -500 I checked it in the debugger

As I said: set y to -500 BUT then check for this value
And if it has this value don’t display the brick and
don’t check for the collision with your ball

um,how? how to not display the brick?

Well, it’s not important not to display the brick

When its value is -500 it’s invisible anyway

More important is to skip the collision check from your initial question

Here you can surround your code block with

if( brick1.y!=-500) {


1 Like

oh yeah I am so dumb you mean add another condition to the if that is brick1!=-500 so if(1&&2&&3&&brick1!=-500)

Thanks! It worked! Thank you so much,I mean it! I have a brick breaker game now(almost,because I have to set the boundaries so the ball bounces only from the platform at the bottom not from anything on its y but that’s it and then it’s done)