Ejemplo n.º 1
0
        public bool Construct(uint width, uint height, uint cellX, uint cellY, string title, Color clearColor, bool fullscreen)
        {
            Title           = title;
            this.fullscreen = fullscreen;

            resolution = new Vector2i((int)width, (int)height);

            this.cellX = (int)cellX;
            this.cellY = (int)cellY;


            backBuffer = new Pixel[width / cellX, height / cellY];

            backBuffer.Populate(new Pixel().Construct(clearColor, cellX, cellY));

            this.clearColor = clearColor;

            input = new InputHandler();

            graphics = new GrapeGraphics(ref backBuffer);

            screen   = new ScreenBuffer(backBuffer.GetLength(0), backBuffer.GetLength(1), (int)cellX, (int)cellY, ref backBuffer);
            vecGraph = new VertexGraphics(ref screen.vertexArr, backBuffer.GetLength(0), backBuffer.GetLength(1));

            thread = new Thread(new ThreadStart(Start));
            thread.Start();

            return(true);
        }
Ejemplo n.º 2
0
        public ScreenBuffer(int width, int height, int cellX, int cellY, ref Pixel[,] buffer)
        {
            backBuffer = buffer;
            vertexArr  = new Vertex[width * height * 4];
            int i = 0;

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    vertexArr[i]     = new Vertex(new Vector2f(x * cellX, y * cellY), Color.White);
                    vertexArr[i + 1] = new Vertex(new Vector2f((x + 1) * cellX, y * cellY), Color.White);
                    vertexArr[i + 2] = new Vertex(new Vector2f((x + 1) * cellX, (y + 1) * cellY), Color.White);
                    vertexArr[i + 3] = new Vertex(new Vector2f(x * cellX, (y + 1) * cellY), Color.White);
                    i += 4;
                }
            }
            graphics = new GrapeGraphics(ref buffer);
        }
Ejemplo n.º 3
0
        public bool Construct(uint width, uint height, uint cellX, uint cellY, string title, Color clearColor, bool fullscreen)
        {
            Title = title;

            if (fullscreen)
            {
                window = new RenderWindow(VideoMode.FullscreenModes[0], title, Styles.Fullscreen);
            }
            else
            {
                window = new RenderWindow(new VideoMode(width, height), title);
            }



            this.cellX = (int)cellX;
            this.cellY = (int)cellY;

            backBuffer = new Pixel[window.Size.X / cellX, window.Size.Y / cellY];

            backBuffer.Populate(new Pixel().Construct(clearColor, cellX, cellY));

            this.clearColor = clearColor;

            input = new InputHandler();

            graphics = new GrapeGraphics(ref backBuffer);

            window.KeyPressed  += input.KeyPress;
            window.KeyReleased += input.KeyRelease;
            window.Closed      += Window_Closed;

            screen   = new ScreenBuffer(backBuffer.GetLength(0), backBuffer.GetLength(1), (int)cellX, (int)cellY, ref backBuffer);
            vecGraph = new VertexGraphics(ref screen.vertexArr, backBuffer.GetLength(0), backBuffer.GetLength(1));

            OnCreate();

            Loop();


            return(true);
        }