public override void Update(float time) { if (Mouse[MouseButton.Left]) { float x = Mouse.X; float y = Mouse.Y; // orig size is 1024x768 (where coordinates below are taken) // so calculate x & y incase resolution is different than orig x = x / (float)Settings.Width * 1024f; y = y / (float)Settings.Height * 768f; if (y > 400 && y < 500) { // start if (x > 80 && x < 260) { GameClass game = new Game(); // start game BaseGame.SetGame(game); return; } // exit if (x > 780 && x < 940) { Dispose(); BaseGame.Running = false; // end game return; } } } base.Update(time); }
// starttaa esimerkki private void button1_Click(Object sender, EventArgs e) { Hide(); DisplayDevice dev = DisplayDevice.Default; int ind = comboBox1.SelectedIndex; string[] strs = ((string)(comboBox1.Items[ind])).Split('x'); Settings.Width = int.Parse(strs[0]); Settings.Height = int.Parse(strs[1]); Settings.Bpp = int.Parse(strs[2]); // fullscreen? if (checkBox1.Checked) Settings.FullScreen = true; else Settings.FullScreen = false; int version; GraphicsContextFlags flags; if (Settings.UseGL3 == false) { flags = GraphicsContextFlags.Default; version = 2; } else { flags = GraphicsContextFlags.ForwardCompatible; version = 3; } #if DEBUG flags |= GraphicsContextFlags.Debug; #endif using (BaseGame bgame = new BaseGame("Project XYZ", version, 0, flags)) { #if !DEBUG try #endif { GameClass game = new Game(); BaseGame.SetGame(game); bgame.Run(120.0); } #if !DEBUG catch (Exception ex) { Log.WriteLine(ex.ToString()); } #endif } GC.Collect(); GC.WaitForPendingFinalizers(); Show(); }
static void Main() { Log.Create("log.txt"); Settings.ReadXML("settings.xml"); int version; GraphicsContextFlags flags; if (Settings.UseGL3 == false) { flags = GraphicsContextFlags.Default; version = 2; } else { flags = GraphicsContextFlags.ForwardCompatible; version = 3; } #if DEBUG flags |= GraphicsContextFlags.Debug; #endif using (BaseGame bgame = new BaseGame("Project XYZ", version, 0, flags)) { BaseGame.Instance.WindowBorder = OpenTK.WindowBorder.Fixed; #if !DEBUG try #endif { GameClass game = new Game(); BaseGame.SetGame(game); bgame.Run(120.0); } #if !DEBUG catch (Exception e) { Log.WriteLine("Main(): " + e.ToString()); } #endif } Log.WriteLine("Exiting.."); #if DEBUG //Console.ReadKey(); #endif }