title: Problems with my setInterval and if statement
body: <p>my first post here so bear with me :)</p>
  
  <p>Im rediscovering my programing intrest with the "new" canvas elements and javascript and i tought i make a game for fun, pretty new to javascript tough.</p>
  
  <p>The game is a hunting game and the problem i have is that when the animal comes into hearing range (a pixel representing the hunter and two circles around him represents his hearingrange and visionrange) he should say "i hear something" and in vision range he should shoot.</p>
  
  <p>That all works fine but he spams the text and shooting every time the gameloop repeats and the animal is in range.</p>
  
  <p>My tought was to use setInterval but i cant get it to work as i want :(
  Here is my code:</p>
  
  <pre><code>var Interval = setInterval(function() {
      hunterTimer()
  },1000);
  
  if (hunter.x &gt;= moose.x-hunter.d1/2 &amp;&amp;
      hunter.x &lt;= moose.x+hunter.d2+hunter.d1/2 &amp;&amp;
      moose.y &gt;= moose.y-hunter.d1/2 &amp;&amp;
      hunter.y &lt;= moose.y+hunter.d2+hunter.d1/2) {
  
      function hunterTimer() {
          ctxtext.fillText("I hear something!",50,textbreak),
          textbreak += 10;
      }
  
      hunterTimer();
  }
  </code></pre>
  
  <p>Any help would be nice, sorry for the long post :D</p>