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); }
public void Draw(VertexGraphics g) { for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { g.DrawPoint(x, y, image[x, y]); } } }
public void DrawClipped(VertexGraphics g, float x1, float y1, float x, float y, float w, float h) { if (x >= 0 && x < this.w && y >= 0 && y < this.h && x + w < this.w && x + w >= 0 && y + h < this.h && y + h >= 0) { for (int y0 = (int)y; y0 < y + h; y0++) { for (int x0 = (int)x; x0 < x + w; x0++) { g.DrawPoint(x1 + (x0 - x), y1 + (y0 - y), image[x0, y0]); } } } }
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); }