title: SFML 2.0 Collision class
body: <p>I've been working on an oop version of snake use the sfml 2.0 library and I have a separate class for handling collisions. Here's the code:</p>
  <h1>include &quot;collision.hpp&quot;</h1>
  <pre><code>bool sfc::Sprite::collision(sfc::Sprite sprite2) {
    this-&gt;setBounds();
    sprite2.setBounds();
  
    if (top &gt; sprite2.bottom ||  bottom &lt; sprite2.top ||  left &gt; sprite2.right ||  right &lt; sprite2.left) {
      return false;
    }
  
    return true;
  }
  
  void sfc::Sprite::colMove(sf::Vector2f &amp;movement, sfc::Sprite sprite2) {
    if (!this-&gt;collision(sprite2)) {
      this-&gt;move(movement);
    }
  }
  
  void sfc::Sprite::colMove(float x, float y, sfc::Sprite sprite2) {
    if (!this-&gt;collision(sprite2)) {
      this-&gt;move(x, y);
    }
  }
  
  void sfc::Sprite::setBounds() {
    top = this-&gt;getPosition().y;
    bottom = this-&gt;getPosition().y + this-&gt;getTexture()-&gt;getSize().y;
    left = this-&gt;getPosition().x;
    right = this-&gt;getPosition().x + this-&gt;getTexture()-&gt;getSize().y;
  }
  </code></pre>
  <p>The only problem is once the collision event happens, the sprite is stuck for the rest of the window life. How can I get it so that on that collision it does not stick there. Thanks! ~Michael</p>
  <p>Edit: I understand that the sprite is not allowed to move after collision occurs but I don't know any other way of stopping the sprite from moving after the collision.</p>