Thread: C++

Results 1 to 7 of 7
  1. #1
    Applesouce's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    89
    Reputation
    10
    Thanks
    20
    My Mood
    Doh

    C++

    Hi im learning c++ right now *nerd* xD well and i wanted to do a simple matrix "animation" ^^ and i got the code but there are errors but i dont know whats wrong with it

    #define readkey

    using System;

    namespace m7tr1x
    {
    class Program
    {
    static void Main(string[] args)
    {
    Console.Title = "Matrix by DrooPy DoG";
    Console.ForegroundColor = ConsoleColor.DarkGreen;
    Console.WindowLeft = Console.WindowTop = 0;
    Console.WindowHeight = Console.BufferHeight = Console.LargestWindowHeight;
    Console.WindowWidth = Console.BufferWidth = Console.LargestWindowWidth;

    #if readkey
    Console.WriteLine("ApaSa 0 Ta$ta pEnTRu a C0nTinuA =/");
    Console.ReadKey();
    #endif

    Console.CursorVisible = false;
    int width, height;
    int[] y;
    int[] l;
    Initialize(out width, out height, out y, out l);
    int ms;

    while (true)
    {
    DateTime t1 = DateTime.Now;
    MatrixStep(width, height, y, l);
    ms = 10 - (int)((TimeSpan)(DateTime.Now - t1)).TotalMilliseconds;

    if (ms > 0)
    System.Threading.Thread.Sleep(ms);

    if (Console.KeyAvailable)
    if (Console.ReadKey().Key == ConsoleKey.F5)
    Initialize(out width, out height, out y, out l);
    }
    }

    static bool thistime = false;

    private static void MatrixStep(int width, int height, int[] y, int[] l)
    {
    int x;
    thistime = !thistime;

    for (x = 0; x < width; ++x)
    {
    if (x % 11 == 10)
    {
    if (!thistime)
    continue;

    Console.ForegroundColor = ConsoleColor.White;
    }
    else
    {
    Console.ForegroundColor = ConsoleColor.DarkGreen;
    Console.SetCursorPosition(x, inBoxY(y[x] - 2 - (l[x] / 40 * 2), height));
    Console.Write(R);
    Console.ForegroundColor = ConsoleColor.Green;
    }
    Console.SetCursorPosition(x, y[x]);
    Console.Write(R);
    y[x] = inBoxY(y[x] + 1, height);
    Console.SetCursorPosition(x, inBoxY(y[x] - l[x], height));
    Console.Write(' ');
    }
    }

    private static void Initialize(out int width, out int height, out int[] y, out int[] l)
    {
    int h1;
    int h2 = (h1 = (height = Console.WindowHeight) / 2) / 2;
    width = Console.WindowWidth - 1;
    y = new int[width];
    l = new int[width];
    int x;
    Console.Clear();
    for (x = 0; x < width; ++x)
    {
    y[x] = r.Next(height);
    l[x] = r.Next(h2 * ((x % 11 != 10) ? 2 : 1), h1 * ((x % 11 != 10) ? 2 : 1));
    }
    }

    static Random r = new Random();

    static char R
    {
    get
    {
    int t = r.Next(10);
    if (t <= 2)
    return (char)('0' + r.Next(10));
    else if (t <= 4)
    return (char)('a' + r.Next(27));
    else if (t <= 6)
    return (char)('A' + r.Next(27));
    else
    return (char)(r.Next(32, 255));
    }
    }

    public static int inBoxY(int n, int height)
    {
    n = n % height;
    if (n < 0)
    return n + height;
    else
    return n;
    }
    }
    }

  2. #2
    Felipeb18's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Posts
    33
    Reputation
    10
    Thanks
    6
    Isnt it C#?

  3. #3
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    It is C# lol
    Ah we-a blaze the fyah, make it bun dem!

  4. #4
    Applesouce's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    89
    Reputation
    10
    Thanks
    20
    My Mood
    Doh
    can editor make c# ???

  5. #5
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    No...............
    Ah we-a blaze the fyah, make it bun dem!

  6. #6
    'Bruno's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Portugal
    Posts
    2,883
    Reputation
    290
    Thanks
    1,036
    My Mood
    Busy
    yes this is C# lol, and btw, you should use
    Code:
     [.code] [./code] (without ".")
    so it is easier to read and understand... o.o
    Light travels faster than sound. That's why most people seem bright until you hear them speak.

  7. #7
    XGelite's Avatar
    Join Date
    Mar 2009
    Gender
    male
    Location
    Enter text here
    Posts
    1,344
    Reputation
    12
    Thanks
    276
    and... start from the basics -.-

    if you couldn't tell the difference between C++ and C# code then you obviously have no experience coding. start wit a basic program. no animation or anything. just something simple. like a calculator