public static PointF Dimensions; //The dimensions of the game public game_obj(uint Width, uint Height, uint FrameRate, string Name) { FrameRateController.Initialize(FrameRate); //Controls the Framerate to be at 60 FPS Components = new System.ComponentModel.Container(); //Form Setup this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Text = Name; this.Width = (int)Width; this.Height = (int)Height; this.Visible = true; this.MinimizeBox = false; this.MaximizeBox = false; this.StartPosition = FormStartPosition.CenterScreen; this.FormBorderStyle = FormBorderStyle.FixedSingle; this.Activate(); this.BackColor = Color.Black; this.DoubleBuffered = true; this.Paint += Game_Paint; this.KeyDown += new KeyEventHandler(Game_KeyDown); //Keyboard Input Handler setup this.KeyUp += new KeyEventHandler(Game_KeyUp); Dimensions = new PointF(Width, Height); //Sets the dimensions of the game XInputWrapper.XboxController.StartPolling(); //Start checking the XBoxController for input and updating the state this.FormClosing += (object sender, FormClosingEventArgs e) => { XInputWrapper.XboxController.StopPolling(); running = false; FrameRateController.Deinitialize(); }; }
// 初期化 private void AboutDialog_Load(object sender, EventArgs e) { // ウィンドウサイズはここで指定する ClientSize = new Size(width: 400, height: 225); // フィールドの初期化 controller = new FrameRateController(owner: this, fps: 60); device = new GraphicsDevice(this); manager = new TaskManager(capacity: 50); rand = new Random(); // 固定表示するタスクを生成 manager.Add(new Background()); manager.Add(new PanelLayer(color: Color.FromArgb(192, 128, 128, 128), x: 16.0f, y: 32.0f, width: 368.0f, height: 96.0f, priority: 0.9f)); manager.Add(new IconLayer(x: 32.0f, y: 48.0f, priority: 0.95f)); manager.Add(new TextLayer(text: AssemblyInfo.Title, emSize: 10.0f, color: Color.White, x: 112.0f, y: 48.0f, priority: 0.95f)); manager.Add(new TextLayer(text: $"Version {AssemblyInfo.Version.ToString(3)}", emSize: 10.0f, color: Color.White, x: 112.0f, y: 70.0f, priority: 0.95f)); manager.Add(new TextLayer(text: AssemblyInfo.Copyright, emSize: 10.0f, color: Color.White, x: 112.0f, y: 92.0f, priority: 0.95f)); // メインループの実行 controller.RunAsync(() => { Update(); Draw(); }); }