# Applying collisions and physics to a processing 3 project

**URL:** <https://discourse.processing.org/t/applying-collisions-and-physics-to-a-processing-3-project/12049>\
**Category:** Coding Questions\
**Created:** [June 14, 2019, 12:21am UTC](https://discourse.processing.org/t/applying-collisions-and-physics-to-a-processing-3-project/12049 "2019-06-14T00:21:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bluu](https://avatars.discourse-cdn.com/v4/letter/b/a88e4f/32.png) [@Bluu](https://discourse.processing.org/u/Bluu)\
**Post date:** [June 14, 2019, 12:21am UTC](https://discourse.processing.org/t/applying-collisions-and-physics-to-a-processing-3-project/12049/1 "2019-06-14T00:21:46Z")

</div>

I’ve been working on a simulation project which has a cannon and 2 towers of blocks which must collide with each other in a way that causes movement(however rotation is not required, just displacement and gravity)  
I’ve been trying to use this processing script I wrote: [https://pastebin.com/g1T0U7YN](https://pastebin.com/g1T0U7YN)  
to do just that, but when the blocks fall, they stack on top of each other, but the console says that collision is detected, what’s wrong with my collision?  
Relevant excerpt:

```auto
  void drawblock() {
    for (int i=0; i<blocks.size(); i++) {
      block sb=blocks.get(i);
      if (sb.by<by+25&&sb.by+25>by&&(sb.bx+25>bx||cbs.get(0).cx>bx)) {
        //left
        println("left");
      }
      if (sb.by<by+25&&sb.by+25>by&&(sb.bx<bx+25||cbs.get(0).cx>bx)) {
        //right
        println("right");
      }
      if (sb.bx+25>bx&&sb.bx<bx+25&&(sb.by+25>by||cbs.get(0).cx>bx)) {
        //top
        println("top");
      }
      if (sb.bx+25>bx&&sb.bx<bx+25&&(sb.by<by||cbs.get(0).cx>bx)) {
        //bottom
        println("bottom");
      } else {
        if (by<400) {
          VelD+=.98;
          by+=VelD;
        }
      }
    }

```

-Jake T.
