Stars is a vertical-scroll shoot 'em up game that you can play on the PC using an xbox360 controller. In order to power up the ship's weapons a player must use it to collect star energy, which drops from defeated enemy ships. Stars supports singleplayer, multiplayer coop and versus mode.

I have worked on this project for a year as my graduation project. Skills required and developed during this process include C# programming, game concept design and development, and 2D art. This game has been built up from the ground using only the XNA framework, Visual Studio and Photoshop.


More video content can be found on the YouTube channel

Check out the source code.




The following function is one that I use to check for collisions between two rectangles, two circles or one of both. The code is written in C# using Visual Studio 2010 and it uses some inherited functionality for some mathematical equations.

This code shows a basic understanding of mathematics and thus mainly served to demonstrate the sense for good code layout and structure.
/// <summary>
///
Returns whether or not two 2D objects collide. Objects can be either Rectangles or Circles, or both.
/// </summary>
/// <param name="ObjectA">
The first object.</param>
/// <param name="ObjectB">
The second object.</param>
/// <returns></returns>

public bool Collides(Object ObjectA, Object ObjectB)
{
  // Throw exception if either object is neither a Rectangle nor a Circle.
  if ((!(ObjectA is Rectangle) && !(ObjectA is Circle)) || (!(ObjectB is Rectangle) && !(ObjectB is Circle)))
    throw new System.ArgumentException("At least one of the objects is neither a Rectangle nor a Circle", "wrong parameter type");
  
  // Both objects are rectangles
  if (ObjectA is Rectangle && ObjectB is Rectangle)
  {
    return (Rectangle.Intersect((Rectangle)ObjectA, (Rectangle)ObjectB) != Rectangle.Empty);
  }
  
  // Both objects are circles
  else if (ObjectA is Circle && ObjectB is Circle)
  {
    // Return 'true' if circles collide (See custom function below)
    return CirclesCollide((Circle)ObjectA, (Circle)ObjectB);
  }
  
  // One object is a rectangle, the other is a circle
  else
  {
    Rectangle aRectangle;
    Circle aCircle;
    
    // Check which object is the circle and which is the rectangle
    if (ObjectA is Rectangle)
    {
      aRectangle = (Rectangle)ObjectA;
      aCircle = (Circle)ObjectB;
    }
    else
    {
      aCircle = (Circle)ObjectA;
      aRectangle = (Rectangle)ObjectB;
    }
    
    // Check if the circle is within a aCircle.Radius margin from the rectangle
    if (aCircle.Left > aRectangle.Right) return false;
    if (aCircle.Right < aRectangle.Left) return false;
    if (aCircle.Top > aRectangle.Bottom) return false;
    if (aCircle.Bottom < aRectangle.Top) return false;
    
    // The circle either collides one of the sides of the rectangle, or is close to one of the corners
    // Check if the circle collides with any of the corners of the rectangle

    for (int i = 0; i < 4; i++)
    {
      // Left side
      if (aCircle.Center.X < aRectangle.Left)
      {
        // Top left corner
        if (aCircle.Center.Y < aRectangle.Top)
          if (!CirclesCollide(aCircle, new Circle(aRectangle.Left, aRectangle.Top, 0))) return false;
        // Bottom left corner
        if (aCircle.Center.Y > aRectangle.Bottom)
          if (!CirclesCollide(aCircle, new Circle(aRectangle.Left, aRectangle.Bottom, 0))) return false;
      }
      // Right side
      if (aCircle.Center.X > aRectangle.Right)
      {
        // Top right corner
        if (aCircle.Center.Y < aRectangle.Top)
          if (!CirclesCollide(aCircle, new Circle(aRectangle.Right, aRectangle.Top, 0))) return false;
        // Bottom right corner
        if (aCircle.Center.Y > aRectangle.Bottom)
          if (!CirclesCollide(aCircle, new Circle(aRectangle.Right, aRectangle.Bottom, 0))) return false;
      }
    }
    
    return true;
  }
}

/// <summary>
///
Returns whether or not two circles collide.
/// </summary>
/// <param name="CircleA">
The first circle.</param>
/// <param name="CircleB">
The second circle.</param>
/// <returns></returns>

public bool CirclesCollide(Circle CircleA, Circle CircleB)
{
  // Calculate distance between the center points
  double distance = Math.Sqrt(Math.Pow((CircleA.X - CircleB.X), 2) + Math.Pow((CircleA.Y - CircleB.Y), 2));
  
  // Compare distance to combined radii
  return (distance <= (CircleA.Radius + CircleB.Radius));
}