C# Collision test of a ship and asteriod
<p>We are trying to to do a collision detection for the ship and asteroid.
If success than it should detect the collision before N turns. 
However it is confused between angle 350 and 15 and it is not really working.
Sometimes it is moving but sometime it is not moving at all.
On the other hand, it is not shooting at the right time as well.</p>

<p>I just want to ask how to make the collision detection working???
And how to solve the angle confusion problem?</p>

<pre><code>            // Get velocities of asteroid


            Console.WriteLine("lol");

            // IF equation is between -2 and -3
            if (equation1a &lt;= -2)
            {
                // Calculate no. turns till asteroid hits
                float turns_till_hit = dx / vx;

                // Calculate angle of asteroid
                float asteroid_angle_rad = (float)Math.Atan(Math.Abs(dy / dx));
                float asteroid_angle_deg = (float)(asteroid_angle_rad * 180 / Math.PI);

                float asteroid_angle = 0;

                // Calculate angle if asteroid is in certain positions
                if (asteroid.Y &gt; ship.Y &amp;&amp; asteroid.X &gt; ship.X)
                {
                    asteroid_angle = asteroid_angle_deg; 
                }
                else if (asteroid.Y &lt; ship.Y &amp;&amp; asteroid.X &gt; ship.X)
                {
                    asteroid_angle = (360 - asteroid_angle_deg);
                }
                else if (asteroid.Y &lt; ship.Y &amp;&amp; asteroid.X &lt; ship.X)
                {
                    asteroid_angle = (180 + asteroid_angle_deg);
                }
                else if (asteroid.Y &gt; ship.Y &amp;&amp; asteroid.X &lt; ship.X)
                {
                    asteroid_angle = (180 - asteroid_angle_deg);
                }

                // IF turns till asteroid hits are less than 35
                if (turns_till_hit &lt; 50)
                {
                    float angle_between = 0;

                    // Calculate angle between if asteroid is in certain positions
                    if (asteroid.Y &gt; ship.Y &amp;&amp; asteroid.X &gt; ship.X)
                    {
                        angle_between = ship_angle - asteroid_angle;
                    }
                    else if (asteroid.Y &lt; ship.Y &amp;&amp; asteroid.X &gt; ship.X)
                    {
                        angle_between = (360 - Math.Abs(ship_angle - asteroid_angle));
                    }
                    else if (asteroid.Y &lt; ship.Y &amp;&amp; asteroid.X &lt; ship.X)
                    {
                        angle_between = ship_angle - asteroid_angle;
                    }
                    else if (asteroid.Y &gt; ship.Y &amp;&amp; asteroid.X &lt; ship.X)
                    {
                        angle_between = ship_angle - asteroid_angle;
                    }

                    // If angle less than 0, add 360
                    if (angle_between &lt; 0)
                    {
                        //angle_between %= 360;
                        angle_between = Math.Abs(angle_between);
                    }

                    // Calculate no. of turns to face asteroid
                    float turns_to_face = angle_between / 25;

                    if (turns_to_face &lt; turns_till_hit)
                    {
                        float ship_angle_left = ShipAngle(ship_angle, "leftKey", 1);

                        float ship_angle_right = ShipAngle(ship_angle, "rightKey", 1);

                        float angle_between_left = Math.Abs(ship_angle_left - asteroid_angle);

                        float angle_between_right = Math.Abs(ship_angle_right - asteroid_angle);

                        if (angle_between_left &lt; angle_between_right)
                        {
                            leftKey = true;
                        }
                        else if (angle_between_right &lt; angle_between_left)
                        {
                            rightKey = true;
                        }

                    }

                    if (angle_between &gt; 0 &amp;&amp; angle_between &lt; 25)
                    {
                        spaceKey = true;
                    }
                }
            }


        }

    }  
</code></pre>
