title: isometric tile selection formula is slightly off
body: <p>I almost made the isometric tile selection formula work but it seems to be slightly off: <a href="http://prntscr.com/pn3gbv" rel="nofollow noreferrer">http://prntscr.com/pn3gbv</a><br></p>
  
  <p>It seems to be working correctly when the mouse is hovered over the first half of the tile but it jumps to the next tile as the mouse is moved to the second half: <a href="http://prntscr.com/pn3hpx" rel="nofollow noreferrer">http://prntscr.com/pn3hpx</a><br> <em>(<a href="https://youtu.be/MgwaJrilJrk" rel="nofollow noreferrer">here's</a> a video showing the issue)</em>.</p>
  
  <p>It also doesn't account for a camera and I don't know how to implement that. So some help on that as well would be appreciated.</p>
  
  <p>Below is the relevant code used, and <a href="https://gist.github.com/Torxed/8b2e6d762307f5e14b02f73cc55ed65a" rel="nofollow noreferrer">here's a minimal executable example</a> and also the image resource used:</p>
  
  <p><img src="https://i.imgur.com/P1QVJqd.png" alt="path.png"></p>
  
  <pre class="lang-py prettyprint-override"><code>import pyglet
  
  tile_width_half = 84/2
  tile_height_half = 51/2
  
  class Game(pyglet.window.Window):
      def __init__(self,*args,**kwargs):
          super().__init__(*args,**kwargs)
          self.island = Island()
          self.camera = Camera()
          self.selection = pyglet.sprite.Sprite(pyglet.image.load("path.png"))
      def on_mouse_motion(self, x, y, dx, dy):
          global tile_height_half,tile_width_half
          j = int((x / tile_width_half + y / tile_height_half) / 2)
          i = int((y / tile_height_half - x / tile_width_half) / 2)
          self.selection.x = (j-i)*tile_width_half
          self.selection.y = (j+i)*tile_height_half
      def on_draw(self):
          self.clear()
          self.island.draw()
          self.selection.draw()
      def on_key_press(self, symbol, modifiers):
          if symbol == key.A:
              self.camera.left = True
          if symbol == key.W:
              self.camera.up = True
          if symbol == key.D:
              self.camera.right = True
          if symbol == key.S:
              self.camera.down = True
          if symbol == key.ESCAPE:
              pyglet.app.exit()
      def on_key_release(self, symbol, modifiers):
          if symbol == key.A:
              self.camera.left = False
          if symbol == key.W:
              self.camera.up = False
          if symbol == key.D:
              self.camera.right = False
          if symbol == key.S:
              self.camera.down = False
      def update(self,dt):
          for tile in self.island.all_sprites:
              tile.x += self.camera.position[0]
              tile.y += self.camera.position[1]
          self.camera.move()
  
  
  if __name__ == '__main__':
      game = Game(800,600,"title")
      pyglet.clock.schedule_interval(game.update,1/60)
  
      pyglet.app.run()
  </code></pre>