# Fisica Library, how to avoid contact

**URL:** <https://discourse.processing.org/t/fisica-library-how-to-avoid-contact/23835>\
**Category:** Libraries\
**Created:** [September 13, 2020, 2:15pm UTC](https://discourse.processing.org/t/fisica-library-how-to-avoid-contact/23835 "2020-09-13T14:15:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![doloresgarcia](https://avatars.discourse-cdn.com/v4/letter/d/48db29/32.png) [@doloresgarcia](https://discourse.processing.org/u/doloresgarcia)\
**Post date:** [September 13, 2020, 2:15pm UTC](https://discourse.processing.org/t/fisica-library-how-to-avoid-contact/23835/1 "2020-09-13T14:15:02Z")

</div>

Hi, i have to do a project and i am having problems with my code.  
In my game i have to shoot a spear and it has to hit a fish. The problem is that the spear doesn´t have to collide with the plataforms. Can somebody help me?

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/8/84c68a3c3c94f932c42a6d7eb9539330afa09af4.png)

```auto
import fisica.*;

FWorld world;
Plataforma piso;
Lanza lanza;
Pez pez;

ArrayList <Plataforma> plataformas;
ArrayList <Plataforma> plataformas1;

String estado;
PImage fondo;
int gy;

void setup() {
  size (800, 600);

  estado="inicio";
  Fisica.init(this);

  comenzar();
}
void draw() {

  if (estado.equals("inicio")) {
    fondo= loadImage("fondo.jpg");
    image(fondo, 0, 0, width, height);
    fill(255);
    rect(width/2-75, height/2-25, 150, 50);
    stroke(0);
    fill(0);
    textSize(16);
    text("inicio", width/2-20, height/2+5);
  }
  if (estado.equals("juego")) {
    background(102, 153, 255);
    pez.actualizar();
    lanza.actualizar();
    world.step();
    world.draw();
  }
}

void keyPressed() {
  lanza.cambio();
  lanza.actualizar();
}

void mousePressed() {
  if (estado.equals("inicio") && mouseX<width/2+75 && mouseX> width/2-75 && mouseY>height/2-25 && mouseY< height/2+25) {
    estado="juego";
  }

  //else if (estado.equals("juego")){
  // pez.colisiona();
  // }
}

void contactStarted(FContact contact) {
  if (estado.equals("juego")) {
    if (hayColisionEntre( contact, "lanza", "pez")) {
      pez.colisiona();
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [September 18, 2020, 10:22am UTC](https://discourse.processing.org/t/fisica-library-how-to-avoid-contact/23835/2 "2020-09-18T10:22:40Z")

</div>

Hi doloresgarcia  
I think you missed to post the Plataforma Class to try this code.
