# Math doesn't work?

**URL:** <https://discourse.processing.org/t/math-doesnt-work/33384>\
**Category:** Beginners\
**Tags:** homework\
**Created:** [November 7, 2021, 5:58pm UTC](https://discourse.processing.org/t/math-doesnt-work/33384 "2021-11-07T17:58:32Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![stefanmz7](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@stefanmz7](https://discourse.processing.org/u/stefanmz7)\
**Post date:** [November 7, 2021, 5:58pm UTC](https://discourse.processing.org/t/math-doesnt-work/33384/1 "2021-11-07T17:58:32Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Post date:** [November 7, 2021, 8:51pm UTC](https://discourse.processing.org/t/math-doesnt-work/33384/2 "2021-11-07T20:51:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![stefanmz7](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@stefanmz7](https://discourse.processing.org/u/stefanmz7)\
**Post date:** [November 7, 2021, 9:38pm UTC](https://discourse.processing.org/t/math-doesnt-work/33384/3 "2021-11-07T21:38:03Z")

</div>

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 all.[Pastebin.com - Locked Paste](https://pastebin.com/0J1hjS5B) Password:99EDhzwYM0 also look at comments //

---

<div class="post-metadata">

**Author:** ![stefanmz7](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@stefanmz7](https://discourse.processing.org/u/stefanmz7)\
**Post date:** [November 7, 2021, 10:45pm UTC](https://discourse.processing.org/t/math-doesnt-work/33384/4 "2021-11-07T22:45:46Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [November 7, 2021, 11:43pm UTC](https://discourse.processing.org/t/math-doesnt-work/33384/5 "2021-11-07T23:43:42Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![stefanmz7](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@stefanmz7](https://discourse.processing.org/u/stefanmz7)\
**Post date:** [November 7, 2021, 11:59pm UTC](https://discourse.processing.org/t/math-doesnt-work/33384/6 "2021-11-07T23:59:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![stefanmz7](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@stefanmz7](https://discourse.processing.org/u/stefanmz7)\
**Post date:** [November 8, 2021, 12:00am UTC](https://discourse.processing.org/t/math-doesnt-work/33384/7 "2021-11-08T00:00:01Z")

</div>

and brick1 is -500 I checked it in the debugger

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [November 8, 2021, 12:06am UTC](https://discourse.processing.org/t/math-doesnt-work/33384/8 "2021-11-08T00:06:06Z")

</div>

> [@stefanmz7](#):
>
> is there any other way to erase it without teleporting?

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

---

<div class="post-metadata">

**Author:** ![stefanmz7](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@stefanmz7](https://discourse.processing.org/u/stefanmz7)\
**Post date:** [November 8, 2021, 12:10am UTC](https://discourse.processing.org/t/math-doesnt-work/33384/9 "2021-11-08T00:10:16Z")

</div>

um,how? how to not display the brick?

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [November 8, 2021, 12:14am UTC](https://discourse.processing.org/t/math-doesnt-work/33384/10 "2021-11-08T00:14:21Z")

</div>

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) {  
….

}

---

<div class="post-metadata">

**Author:** ![stefanmz7](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@stefanmz7](https://discourse.processing.org/u/stefanmz7)\
**Post date:** [November 8, 2021, 1:06am UTC](https://discourse.processing.org/t/math-doesnt-work/33384/11 "2021-11-08T01:06:39Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![stefanmz7](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@stefanmz7](https://discourse.processing.org/u/stefanmz7)\
**Post date:** [November 8, 2021, 1:24am UTC](https://discourse.processing.org/t/math-doesnt-work/33384/12 "2021-11-08T01:24:48Z")

</div>

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)
