How do I detect if an object is on top of another object (like Mario on a brick)
<p>I am building an auto-run platforming game. I have code so that if the character collides with a wall, they are pushed back until they are able to get past the wall. Unfortunately, this means that when the character tries to jump on an object, he just gets pushed backward. How do I discern when a character is on top of an object, from when it is on the side?</p>

<p>My Current Algorithm (c-ish because i like c-ish syntax):</p>

<pre><code>if (wall.Top &lt; (character.Top + character.Height) &amp;&amp;
    wall.Left &lt; (character.Left + character.Width) &amp;&amp;
   (wall.Top + wall.Height) &gt; character.Top &amp;&amp;
   (wall.Left + wall.Width) &gt; character.Left) { #code here# }
</code></pre>