Exemple #1
0
 public static void setPixel(int x, int y, pixel p)
 {
     if (x >= 0 && x < settings.width)
     {
         if (y >= 0 && y < settings.height)
         {
             if (screen[x, y].z < p.z)
             {
                 screen[x, y].c = p.c;
                 screen[x, y].z = p.z;
             }
         }
     }
 }
Exemple #2
0
        static void Main(string[] args)
        {
            Console.Title = "dirt";

            Console.ReadLine();
            Console.BackgroundColor = ConsoleColor.Black;

            /*
             * cubes.Add(new Cube(new vector(-0.5f, -0.5f, -2.5f), Color.Brown));
             * cubes.Add(new Cube(new vector(-0.5f, -0.5f, -1.5f), Color.Red));
             * cubes.Add(new Cube(new vector(-0.5f, -0.5f, -0.5f), Color.White));
             * cubes.Add(new Cube(new vector(-0.5f, -0.5f, 0.5f), Color.Yellow));
             * cubes.Add(new Cube(new vector(-0.5f, -0.5f, 1.5f), Color.Blue));*/


            cubes = loadFromImage("knight.png");
            //cubes = loadFromImage("teapot.png");
            //cubes = loadFromImage("castle.png");

            settings.width  = Console.WindowWidth;
            settings.height = Console.WindowHeight;
            settings.offX   = settings.width / 2;
            settings.offY   = settings.height / 2;

            oldScreen = new pixel[settings.width, settings.height];
            for (int x = 0; x < oldScreen.GetLength(0); x++)
            {
                for (int y = 0; y < oldScreen.GetLength(1); y++)
                {
                    oldScreen[x, y] = new pixel(-1000, Color.Black);
                }
            }

            List <Cube> tmp = new List <Cube>();

            Console.Title = "checking sides";

            for (int i = 0; i < cubes.Count; i++)
            {
                tmp.Add(cubes[i].checkSides(cubes));
            }

            cubes = tmp;

            Console.WriteLine("starting...");



            //render loop
            while (true)
            {
                screen = new pixel[settings.width, settings.height];
                for (int x = 0; x < screen.GetLength(0); x++)
                {
                    for (int y = 0; y < screen.GetLength(1); y++)
                    {
                        screen[x, y]   = new pixel(-1000, Color.Black);
                        screen[x, y].z = -1000;
                    }
                }

                foreach (Cube c in cubes)
                {
                    c.renderCube();
                }

                draw();

                oldScreen = screen;


                //rx += 0.005f;
                ry -= 0.005f;
                //rz += 0.001f;

                //Console.WriteLine("tick");
            }
        }