public static float[] GetFloatValues(this Color color) { Color4 c = GLGame.ConvertColor(color); return(new float[] { c.R, c.G, c.B, c.A }); }
static void Main(string[] args) { //Screen.GLMode = false; { int os = (int)Environment.OSVersion.Platform; if(os == 4 || os == 6 || os == 128){ Global.LINUX = true; } } if(args != null && args.Length > 0){ if(args[0] == "-c" || args[0] == "--console"){ Screen.GLMode = false; } if(args[0] == "-g" || args[0] == "--gl"){ Screen.GLMode = true; } } if(!Screen.GLMode){ if(Global.LINUX){ Screen.CursorVisible = false; Screen.SetCursorPosition(0,0); //todo: this should still work fine but it's worth a verification. if(Console.BufferWidth < Global.SCREEN_W || Console.BufferHeight < Global.SCREEN_H){ Console.Write("Please resize your terminal to {0}x{1}, then press any key.",Global.SCREEN_W,Global.SCREEN_H); Screen.SetCursorPosition(0,1); Console.Write(" Current dimensions are {0}x{1}.".PadRight(57),Console.BufferWidth,Console.BufferHeight); Input.ReadKey(); Screen.SetCursorPosition(0,0); if(Console.BufferWidth < Global.SCREEN_W || Console.BufferHeight < Global.SCREEN_H){ Environment.Exit(0); } } Screen.Blank(); Console.TreatControlCAsInput = true; } else{ if(Type.GetType("Mono.Runtime") != null){ // If you try to resize the Windows Command Prompt using Mono, it crashes, so just switch Screen.GLMode = true; // back to GL mode in that case. (Fortunately, nobody uses Mono on Windows unless they're compiling a project in MD/XS.) } else{ Screen.CursorVisible = false; Console.Title = "Forays into Norrendrin"; Console.BufferHeight = Global.SCREEN_H; Console.SetWindowSize(Global.SCREEN_W,Global.SCREEN_H); Console.TreatControlCAsInput = true; } } } if(Screen.GLMode){ ToolkitOptions.Default.EnableHighResolution = false; int height_px = Global.SCREEN_H * 16; int width_px = Global.SCREEN_W * 8; gl = new GLGame(height_px,width_px,Global.SCREEN_H,Global.SCREEN_W,height_px,width_px,"Forays into Norrendrin"); GLGame.text_surface = new SpriteSurface(gl,Global.SCREEN_H,Global.SCREEN_W,16,8,0,0,"font8x16.bmp",1,128,0,0,1.0f,8.0f / 9.0f, GLWindow.GetBasicVertexShader(),GLWindow.GetBasicFontFragmentShader(),GLWindow.GetBasicFontVertexAttributeSizes(), GLWindow.GetBasicFontDefaultVertexAttributes(),GLWindow.GetBasicFontVertexAttributes()); /*GLGame.graphics_surface = new SpriteSurface(gl,22,33,16,16,16*3,8*13,"sprites.png",64,64,17,0,1.0f,1.0f,GLWindow.GetBasicVertexShader(), GLWindow.GetBasicGraphicalFragmentShader(),GLWindow.GetBasicGraphicalVertexAttributeSizes(),GLWindow.GetBasicGraphicalDefaultVertexAttributes(),GLWindow.GetBasicGraphicalVertexAttributes()); gl.SpriteSurfaces.Add(GLGame.graphics_surface); GLGame.actors_surface = new SpriteSurface(gl,22,33,16,16,16*3,8*13,"sprites.png",64,64,17,0,1.0f,1.0f,GLWindow.GetBasicVertexShader(), GLWindow.GetBasicGraphicalFragmentShader(),GLWindow.GetBasicGraphicalVertexAttributeSizes(),GLWindow.GetBasicGraphicalDefaultVertexAttributes(),GLWindow.GetBasicGraphicalVertexAttributes()); gl.SpriteSurfaces.Add(GLGame.actors_surface); GLGame.visibility_surface = new SpriteSurface(gl,22,33,16,16,16*3,8*13,"visibility.png",1,3,0,0,1.0f,1.0f,GLWindow.GetBasicVertexShader(), GLWindow.GetBasicGraphicalFragmentShader(),GLWindow.GetBasicGraphicalVertexAttributeSizes(),GLWindow.GetBasicGraphicalDefaultVertexAttributes(),GLWindow.GetBasicGraphicalVertexAttributes()); gl.SpriteSurfaces.Add(GLGame.visibility_surface);*/ gl.SpriteSurfaces.Add(GLGame.text_surface); GLGame.cursor_surface = new SpriteSurface(gl,1,1,2,8,-99,-99,"font6x12.bmp",1,128,0,0,1.0f,8.0f / 9.0f, GLWindow.GetBasicVertexShader(),GLWindow.GetBasicFontFragmentShader(),GLWindow.GetBasicFontVertexAttributeSizes(), GLWindow.GetBasicFontDefaultVertexAttributes(),GLWindow.GetBasicFontVertexAttributes()); gl.SpriteSurfaces.Add(GLGame.cursor_surface); /*GLGame.particle_surface = new SpriteSurface(gl,22,33,16,16,16*3,8*13,"animations.png",128,128,0,0,1.0f,1.0f,GLWindow.GetBasicVertexShader(), GLGame.GetParticleFragmentShader(),GLWindow.GetBasicFontVertexAttributeSizes(),GLWindow.GetBasicFontDefaultVertexAttributes(),GLWindow.GetBasicFontVertexAttributes()); gl.SpriteSurfaces.Add(GLGame.particle_surface); GLGame.particle_surface.NumElements = 0; float r1 = (float)(R.r.NextDouble() * 22); float r2 = (float)(R.r.NextDouble() * 22); float r3 = (float)(R.r.NextDouble() * 22); float c1 = (float)(R.r.NextDouble() * 33); float c2 = (float)(R.r.NextDouble() * 33); float c3 = (float)(R.r.NextDouble() * 33); int s1 = R.Roll(10) + 4; int s2 = R.Roll(10) + 4; int s3 = R.Roll(10) + 4; Animations.Generators.Add(new ParticleGenerator(0,0,5,3,Color4.Magenta,Color4.White,r1,c1,FloatNumber.CreateRange(FloatNumber.CreateDelta(0.0f,0.001f * s1),FloatNumber.CreateDelta(0.1f,0.003f * s1)),FloatNumber.CreateValue(0.0f),FloatNumber.CreateValue(0.0f),Number.CreateValue(3),Number.CreateValue(5),500/s1)); Animations.Generators.Add(new ParticleGenerator(0,0,5,3,Color4.Yellow,Color4.Firebrick,r2,c2,FloatNumber.CreateRange(FloatNumber.CreateDelta(0.0f,0.001f * s2),FloatNumber.CreateDelta(0.01f,0.003f * s2)),FloatNumber.CreateValue(0.0f),FloatNumber.CreateValue(0.0f),Number.CreateValue(3),Number.CreateValue(5),500/s2)); Animations.Generators.Add(new ParticleGenerator(0,0,5,3,Color4.Cyan,Color4.Yellow,r3,c3,FloatNumber.CreateRange(FloatNumber.CreateDelta(0.0f,0.001f * s3),FloatNumber.CreateDelta(0.01f,0.003f * s3)),FloatNumber.CreateDelta(0.0f,0.01f),FloatNumber.CreateValue(0.0f),Number.CreateValue(3),Number.CreateValue(5),500/s3)); Animations.Generators.Add(new ParticleGenerator(0,0,5,3,Color4.Chocolate,Color4.Cyan,r1,c1,FloatNumber.CreateRange(FloatNumber.CreateDelta(0.0f,0.001f * s1),FloatNumber.CreateDelta(0.1f,0.003f * s1)),FloatNumber.CreateValue(0.0f),FloatNumber.CreateValue(0.0f),Number.CreateValue(3),Number.CreateValue(5),500/s1));*/ //GLGame.particle_surface.Disabled = true; GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha,BlendingFactorDest.OneMinusSrcAlpha); gl.AllowScaling = false; //GLGame.graphics_surface.Disabled = true; //gl.ToggleFullScreen(true); gl.Visible = true; GLGame.Timer = new Stopwatch(); GLGame.Timer.Start(); Screen.CursorVisible = false; } Input.LoadKeyRebindings(); TitleScreen(); MainMenu(); }