private void UpdateInput() { KeyboardState newState = Keyboard.GetState(); // Is the SPACE key down? if (newState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Enter)) { Form.setPlayerName("enter"); // If not down last update, key has just been pressed. if (!oldState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Enter)) { Form.setPlayerName("enter"); // //backColor = // new Color(backColor.R, backColor.G, (byte)~backColor.B); } } else if (oldState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Enter)) { // Key was down last update, but not down now, so // it has just been released. } // Update saved state. oldState = newState; }
public Game(DungeonVandal.MenuForm form,string player_name) { Form = form; graphics = new GraphicsDeviceManager(this) { PreferredBackBufferWidth = Form.ViewportSize.Width, PreferredBackBufferHeight = Form.ViewportSize.Height }; player = new Player(player_name); Form.setPlayerName(player.Name); graphics.PreparingDeviceSettings += graphics_PreparingDeviceSettings; System.Windows.Forms.Control.FromHandle(Window.Handle).VisibleChanged += MainGame_VisibleChanged; System.Windows.Forms.Control.FromHandle(Form.Handle).KeyUp += new System.Windows.Forms.KeyEventHandler(Game_KeyUp); System.Windows.Forms.Control.FromHandle(Form.Handle).KeyDown += new System.Windows.Forms.KeyEventHandler(Game_Key); // System.Windows.Forms.Control.FromHandle(Form.Handle).KeyPress += new System.Windows.Forms.KeyPressEventHandler(Game_KeyPress); Content.RootDirectory = "Content"; IsMouseVisible = true; }
public Game(DungeonVandal.MenuForm form, string player_name) { Form = form; graphics = new GraphicsDeviceManager(this) { PreferredBackBufferWidth = Form.ViewportSize.Width, PreferredBackBufferHeight = Form.ViewportSize.Height }; player = new Player(player_name); Form.setPlayerName(player.Name); graphics.PreparingDeviceSettings += graphics_PreparingDeviceSettings; System.Windows.Forms.Control.FromHandle(Window.Handle).VisibleChanged += MainGame_VisibleChanged; System.Windows.Forms.Control.FromHandle(Form.Handle).KeyUp += new System.Windows.Forms.KeyEventHandler(Game_KeyUp); System.Windows.Forms.Control.FromHandle(Form.Handle).KeyDown += new System.Windows.Forms.KeyEventHandler(Game_Key); // System.Windows.Forms.Control.FromHandle(Form.Handle).KeyPress += new System.Windows.Forms.KeyPressEventHandler(Game_KeyPress); Content.RootDirectory = "Content"; IsMouseVisible = true; }
/// <summary> /// Konstruktor ³aduj¹cy zapisan¹ grê /// </summary> /// <param name="form"> WskaŸnik do okna gry</param> /// <param name="player">Instancja gracza</param> /// <param name="game_state_data_to_load">Dane stany gry do ³adowania</param> /// <param name="data_index">Indeks danych w tablicy stanów gry</param> public Game(DungeonVandal.MenuForm form, Player player, GameState.GameStateData game_state_data_to_load, int data_index) { Form = form; graphics = new GraphicsDeviceManager(this) { PreferredBackBufferWidth = Form.ViewportSize.Width, PreferredBackBufferHeight = Form.ViewportSize.Height }; data_to_load = game_state_data_to_load; this.data_index = data_index; this.player = player; this.player.Dynamite = data_to_load.Dynamites[data_index]; this.player.Points = data_to_load.Points[data_index]; this.player.Rackets = data_to_load.Rackets[data_index]; totalMinutes = data_to_load.TotalMinutes[data_index]; totalSeconds = data_to_load.TotalSeconds[data_index]; Form.setPlayerName(player.Name); graphics.PreparingDeviceSettings += graphics_PreparingDeviceSettings; System.Windows.Forms.Control.FromHandle(Window.Handle).VisibleChanged += MainGame_VisibleChanged; System.Windows.Forms.Control.FromHandle(Form.Handle).KeyUp += new System.Windows.Forms.KeyEventHandler(Game_KeyUp); System.Windows.Forms.Control.FromHandle(Form.Handle).KeyPress += new System.Windows.Forms.KeyPressEventHandler(Game_KeyPress); System.Windows.Forms.Control.FromHandle(Form.Handle).KeyDown += new System.Windows.Forms.KeyEventHandler(Game_Key); System.Windows.Forms.Control.FromHandle(Form.Handle).PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(Game_PreviewKeyDown); Content.RootDirectory = "Content"; IsMouseVisible = true; }