title: Surface Detection in 2d Game?
body: <p>I'm working on a 2D Platform game, and I was wondering what's the best (performance-wise)  way to implement Surface (Collision) Detection.</p>
  
  <p>So far I'm thinking of constructing a list of level objects constructed of a list of lines, and I draw tiles along the lines.</p>
  
  <p><a href="http://img375.imageshack.us/img375/1704/lines.png" rel="nofollow noreferrer">alt text http://img375.imageshack.us/img375/1704/lines.png</a></p>
  
  <p>I'm thinking every object holds the ID of the surface that he walks on, in order to easily manipulate his y position while walking up/downhill.</p>
  
  <p>Something like this:</p>
  
  <pre><code>//Player/MovableObject class
  MoveLeft()
  {
      this.Position.Y = Helper.GetSurfaceById(this.SurfaceId).GetYWhenXIs(this.Position.X)
  }
  </code></pre>
  
  <p>So the logic I use to detect "droping/walking on surface" is a simple point (player's lower legs)-touches-line (surface) check 
  (with some safety approximation 
  - let`s say 1-2 pixels over the line).</p>
  
  <p><strong>Is this approach OK?
  I`ve been having difficulty trying to find reading material for this problem, so feel free to drop links/advice.</strong></p>