0 Members and 1 Guest are viewing this topic.
using System;using System.Collections.Generic;using System.Timers;using SFML;using SFML.Window;using SFML.Graphics;namespace FrostFire{ class MainGame : Program { public MainRenderBuffer MainBuffer; public MainGame() { Text NewText = new Text(); NewText.Position = new Vector2(200, 200); NewText.Color = new Color(250, 100, 30); Text NewText2 = new Text(); NewText2.Position = new Vector2(120, 210); NewText2.Color = new Color(110, 222, 30); //sort all the sprites by depth and draw them to a buffer this.MainBuffer = new MainRenderBuffer(base.MainWindow.Height, base.MainWindow.Width); while (MainWindow.IsOpened()) { base.MainWindow.DispatchEvents(); //clear the window so we have a fresh screen to work with base.MainWindow.Clear(); //Do all the game update logic MainGame.MainGameStateLoop(); //replace this with the depth drawing array NewText.DisplayedString = Convert.ToString(base.MainWindow.GetFrameTime()); NewText2.DisplayedString = Convert.ToString(base.MainWindow.GetFrameTime()); this.MainBuffer.RenderBufferImage.Draw(NewText); this.MainBuffer.RenderBufferImage.Draw(NewText2); //draw the main buffer image to the screen base.MainWindow.Draw(new Sprite(this.MainBuffer.RenderBufferImage.Image)); //display drawn buffer to the window base.MainWindow.Display(); //clear the main buffer for the next frame. this.MainBuffer.RenderBufferImage.Clear(); } } public static void MainGameStateLoop() { //switch statement for different room states (title, level, etc.) } }}
using System;using System.Collections.Generic;using SFML;using SFML.Window;using SFML.Graphics;namespace FrostFire{ class MainRenderBuffer { public uint Height, Width; public RenderImage RenderBufferImage; public MainRenderBuffer(uint Height, uint Width) { this.Height = Height; this.Width = Width; this.RenderBufferImage = new RenderImage(this.Width, this.Height); RenderBufferImage.Image.Smooth = false; } }}
base.MainWindow.Draw(new Sprite(this.MainBuffer.RenderBufferImage.Image));