public override void Draw(RenderSprite RT) { Rect.Position = Position; Rect.Rotation = Angle.ToDeg(); RT.Draw(Rect); }
public override void Draw(RenderSprite RT) { RT.Clear(Color.Black); CRT.Clear(Color.Transparent); CRT.Draw(GUIText, Shaders.UseCRT(GUIText.Sprite.Texture, 0.1f, 0.8f, 0.9f, 0.015f)); CRT.Display(); RT.Draw(Shaders.DrawPhosphorGlow(CRT.Texture)); }
public MenuState() { GUIText = new TextBuffer(80, 30); GUIText.SetFontTexture(ResourceMgr.Get<Texture>("font")); GUIText.Sprite.Scale = Renderer.Screen.Size.ToVec2f().Divide(GUIText.Sprite.Texture.Size.ToVec2f()); GUIText.Sprite.Position = Renderer.Screen.Texture.Size.ToVec2f() / 2; GUIText.Sprite.Origin = GUIText.Sprite.Texture.Size.ToVec2f() / 2; AAA = new RenderSprite(Renderer.Screen.Size); BBB = new RenderSprite(Renderer.Screen.Size); CRT = new RenderSprite(Renderer.Screen.Size); MainMenu = new MenuEntry("Main Menu"); if (Renderer.CountStates() > 0) MainMenu.Add(new WidgetButton("Continue Universe", () => Renderer.PopState())); MainMenu .Add(new WidgetButton("Create Universe", () => Renderer.PushState(new GameState()))) .Add(new WidgetButton("Load Universe", () => CurrentMenu = LoadUniverse).Disable()) .Add(new WidgetButton("Universal Constants", () => CurrentMenu = Constants)) .Add(new WidgetButton("Terminate", () => Program.Running = false)); Action BackToMainMenu = () => { GUIText.Clear(); CurrentMenu = MainMenu; }; LoadUniverse = new MenuEntry("Load Universe") .Add(new WidgetButton("Back", BackToMainMenu)); Constants = new MenuEntry("Universal Constants") .Add(new WidgetTextbox("Resolution X", Program.ResX.ToString(), 6, (S) => { if (S.Length > 0) Program.ResX = int.Parse(S); GUIText.Print(0, 0, "Restart required for changes to take effect"); }, char.IsNumber)) .Add(new WidgetTextbox("Resolution Y", Program.ResY.ToString(), 6, (S) => { if (S.Length > 0) Program.ResY = int.Parse(S); GUIText.Print(0, 0, "Restart required for changes to take effect"); }, char.IsNumber)) .Add(new WidgetCheckbox("Debug", Program.Debug, (B) => Program.Debug = B)) .Add(new WidgetCheckbox("Border", Program.Border, (B) => Program.Border = B)) .Add(new WidgetButton("Back", BackToMainMenu)); CurrentMenu = MainMenu; CurrentMenu.DrawMenu(GUIText); }
public static RenderSprite DrawPhosphorGlow(Texture Tex, float Sub = 0.1f) { if (A == null) { A = new RenderSprite(Tex.Size); B = new RenderSprite(Tex.Size); } B.Clear(Color.Transparent); B.Draw(A); B.Display(); A.Clear(Color.Transparent); A.Draw(VertexShapes.Quad, PrimitiveType.Quads, Shaders.UsePhosphorGlow(B.Texture, Tex, Sub).Scale(Tex.Size.ToVec2f())); A.Display(); return A; }
public GameState() { WorldRT = new RenderSprite(Renderer.Screen.Size); Engine.ActiveCamera = new Camera(); Engine.ActiveCamera.Resolution = Renderer.Screen.Size.ToVec2f(); Entity[] Ents = Engine.GetAllEntities(); for (int i = 0; i < Ents.Length; i++) Engine.RemoveEntity(Ents[i]); Engine.Space = new World(new Vector2f(0, 0).ToVec()); /*for (int i = 0; i < 10; i++) { PhysicsBox Box = new PhysicsBox(); Box.Position = new Vector2f(Utils.Random(-400, 400), Utils.Random(-400, 400)); Engine.SpawnEntity(Box); }*/ /*StarshipEnt Ply = new StarshipEnt(); Ply.Position = new Vector2f(1, 1); Engine.SpawnEntity(Ply);*/ }
public override void Draw(RenderSprite RT) { RT.Clear(Color.Cyan); WorldRT.Clear(Color.Transparent); WorldRT.Draw(VertexShapes.Quad, PrimType.Quads, Shaders.UseStarfield(Engine.ActiveCamera.Position / 2, Engine.ActiveCamera.Rotation, RT.Size.ToVec2f()) .Scale(WorldRT.Size.ToVec2f())); WorldRT.Draw(Shaders.DrawPhosphorGlow(WorldRT.Texture, 0.02f)); WorldRT.SetView(Engine.ActiveCamera); for (int i = 0; i < Engine.Entities.Count; i++) Engine.Entities[i].Draw(WorldRT); if (HasA && HasB) { WorldRT.Draw(VA); GL.PointSize(5); WorldRT.Draw(VB); GL.PointSize(1); } WorldRT.SetView(WorldRT.DefaultView); WorldRT.Display(); RT.Draw(WorldRT); }
public virtual void Draw(RenderSprite RT) { }
public static void Init(Window Wind) { States = new Stack<State>(); Screen = new RenderSprite((int)Scales.XRes, (int)Scales.YRes); FPSLabel = new Text("FPS: Unknown", ResourceMgr.Get<Font>("Inconsolata"), Scales.GetFontSize(16)); FPSLabel.Position = new Vector2f(0.01f * Scales.XRes, 0); Wind.Closed += (S, E) => { if (States.Count > 0) States.Peek().OnClosed(); }; Wind.GainedFocus += (S, E) => { if (States.Count > 0) States.Peek().OnGainedFocus(); }; Wind.LostFocus += (S, E) => { if (States.Count > 0) States.Peek().OnLostFocus(); }; Wind.KeyPressed += (S, E) => { if (E.Alt && E.Code == Keyboard.Key.F4) { Program.Running = false; return; } if (States.Count > 0) States.Peek().OnKey(E, true); }; Wind.KeyReleased += (S, E) => { if (States.Count > 0) States.Peek().OnKey(E, false); }; Wind.TextEntered += (S, E) => { if (States.Count > 0) States.Peek().OnTextEntered(E); }; Wind.MouseButtonPressed += (S, E) => { if (States.Count > 0) States.Peek().OnMouseButton(E, true); }; Wind.MouseButtonReleased += (S, E) => { if (States.Count > 0) States.Peek().OnMouseButton(E, false); }; Wind.MouseEntered += (S, E) => { if (States.Count > 0) States.Peek().OnMouseEntered(true); }; Wind.MouseLeft += (S, E) => { if (States.Count > 0) States.Peek().OnMouseEntered(false); }; Wind.MouseMoved += (S, E) => { if (States.Count > 0) States.Peek().OnMouseMoved(E); }; Wind.MouseWheelMoved += (S, E) => { if (States.Count > 0) States.Peek().OnMouseWheelMoved(E); }; Wind.Resized += (S, E) => { if (States.Count > 0) States.Peek().OnResized(E); }; PushState(new MenuState()); }