예제 #1
0
    public static void Main(string[] args)
    {
        // TODO: Change between SVec and CVec in the following two lines
        var a = new SVec(1, 2);
        var b = new SVec(3, 4);

        // ...and try to make sense of the console output:

        Console.WriteLine("Types: " + a.GetType());

        Console.WriteLine("VALUES:\n    Vector a: {0} vector b: {1}", a, b);

        Console.WriteLine("INSTRUCTION: a = b");
        a = b;
        Console.WriteLine("VALUES:\n    Vector a: {0} vector b: {1}", a, b);

        Console.WriteLine("INSTRUCTION: a.x = 7");
        a.x = 7;
        Console.WriteLine("VALUES:\n    Vector a: {0} vector b: {1}", a, b);

        Console.WriteLine("INSTRUCTION: Scale(a,2)");
        Scale(a, 2);
        Console.WriteLine("VALUES:\n    Vector a: {0} vector b: {1}", a, b);

        Console.WriteLine("INSTRUCTION: a.Scale(3)");
        a.Scale(3);
        Console.WriteLine("VALUES:\n    Vector a: {0} vector b: {1}", a, b);

        Console.WriteLine("INSTRUCTION: a = a + b");
        a = a + b;
        Console.WriteLine("VALUES:\n    Vector a: {0} vector b: {1}", a, b);

        // Force the garbage collector to do its job:
        // (demonstration purposes only - you should usually avoid this method!)
        System.GC.Collect();

        Console.WriteLine("\nPress enter to quit");
        Console.ReadLine();
    }
예제 #2
0
 static void Scale(SVec v, float scalar)
 {
     v.x *= scalar;
 }