Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#ActualMichael Tanczos

Posted 28 December 2012 - 12:09 AM

public class MyVector
{
    public int X { get; set; }
    public int Y { get; set; }
}

class Program
{
    public static T AddVector<T>(T a, T b)
      where T : MyVector, new()
    {
      T newVector = new T();
      newVector.X = a.X + b.X;
      newVector.Y = a.Y + b.Y;

      return newVector;
    }

    static void Main(string[] args)
    {
     MyVector a = new MyVector();
     a.X = 1;
     a.Y = 2;
     MyVector b = new MyVector();
     b.X = 10;
     b.Y = 11;
     MyVector c = AddVector(a, b);
     Console.WriteLine(c.X + ", " + c.Y);
   }
}

 

Code here..
 
 
 

const int map_width = 20, map_height = 20;
int[,] map = new int[map_width, map_height];
 
 
// open a StreamReader to read the index
string path = Path.Combine(StorageContainer.TitleLocation, "Content\\map.txt");
using (StreamReader reader = new StreamReader(path))
{
   int y = 0;
   while (!reader.EndOfStream)
   {
      // get a line
      string line = reader.ReadLine();
  
      // split at the equals sign
      string[] parts = line.Split(',');
  
      for (int x = 0; x < parts.length; x++)
      {
        map[x,y] = Convert.ToInt32(parts[x]);
      }
      
      y++;
   }
}


#1Michael Tanczos

Posted 28 December 2012 - 12:05 AM

public class MyVector
{
    public int X { get; set; }
    public int Y { get; set; }
}

class Program
{
    public static T AddVector<T>(T a, T b)
      where T : MyVector, new()
    {
      T newVector = new T();
      newVector.X = a.X + b.X;
      newVector.Y = a.Y + b.Y;

      return newVector;
    }

    static void Main(string[] args)
    {
     MyVector a = new MyVector();
     a.X = 1;
     a.Y = 2;
     MyVector b = new MyVector();
     b.X = 10;
     b.Y = 11;
     MyVector c = AddVector(a, b);
     Console.WriteLine(c.X + ", " + c.Y);
   }
}

 

Code here..
 
 
 

const int map_width = 20, map_height = 20;
int[,] map = new int[map_width, map_height];
 
 
// open a StreamReader to read the index
string path = Path.Combine(StorageContainer.TitleLocation, "Content\\map.txt");
using (StreamReader reader = new StreamReader(path))
{
   int y = 0;
   while (!reader.EndOfStream)
   {
      // get a line
      string line = reader.ReadLine();
  
      // split at the equals sign
      string[] parts = line.Split(',');
  
      for (int x = 0; x < parts.length; x++)
      {
        map[x,y] = Convert.ToInt32(parts[x]);
      }
      
      y++;
   }
}


PARTNERS