protected override void Initialize() { Hx.Initialize(this); if (HxInput.IsGamePadConnected(PlayerIndex.One)) { Console.WriteLine("GamePad connected..."); } _codelines.Add(""); base.Initialize(); }
protected override void Update(GameTime gameTime) { Hx.Update(gameTime); if (!IsActive) { return; } if (HxInput.IsGamePadConnected(PlayerIndex.One)) { if (HxInput.CurrentGamepadStates[0].ThumbSticks.Right.Y >= 0.3f) { _scale += 0.01f * _scale; } if (HxInput.CurrentGamepadStates[0].ThumbSticks.Right.Y <= -0.3f) { _scale -= 0.01f * _scale; if (_scale < 0.25f) { _scale = 0.25f; } } if (HxInput.CurrentGamepadStates[0].ThumbSticks.Right.X >= 0.3f) { _cameraPosition.X += HxInput.CurrentGamepadStates[0].ThumbSticks.Right.X; } if (HxInput.CurrentGamepadStates[0].ThumbSticks.Right.X <= -0.3f) { _cameraPosition.X += HxInput.CurrentGamepadStates[0].ThumbSticks.Right.X; } if (HxInput.IsButtonPressed(PlayerIndex.One, Buttons.A)) { //A pressed _codelines[_currentLine] += ".A"; } if (HxInput.IsButtonPressed(PlayerIndex.One, Buttons.B)) { //B pressed _codelines[_currentLine] += ".B"; } if (HxInput.IsButtonPressed(PlayerIndex.One, Buttons.X)) { //X pressed _codelines[_currentLine] += ".X"; } if (HxInput.IsButtonPressed(PlayerIndex.One, Buttons.Y)) { //Y pressed _codelines[_currentLine] += ".Y"; } if (HxInput.IsButtonPressed(PlayerIndex.One, Buttons.DPadUp)) { //Dup pressed _codelines[_currentLine] += ".U"; } if (HxInput.IsButtonPressed(PlayerIndex.One, Buttons.DPadDown)) { //Ddown pressed _codelines[_currentLine] += ".D"; } if (HxInput.IsButtonPressed(PlayerIndex.One, Buttons.DPadLeft)) { //Dleft pressed _codelines[_currentLine] += ".L"; } if (HxInput.IsButtonPressed(PlayerIndex.One, Buttons.DPadRight)) { //Dright pressed _codelines[_currentLine] += ".R"; } if (HxInput.IsButtonPressed(PlayerIndex.One, Buttons.RightShoulder)) // New Line { //RShoulder pressed //_codelines[_currentLine] += ".RB"; if (_codelines.Count - 1 <= _currentLine) { _currentLine += 1; _codelines.Add(""); } else { _currentLine += 1; } } if (HxInput.IsButtonPressed(PlayerIndex.One, Buttons.LeftShoulder)) // New Line { //RShoulder pressed //_codelines[_currentLine] += ".RB"; if (_currentLine > 0) { _currentLine -= 1; } } } if (_cameraPosition.X > 0) { _cameraPosition.X = 0; } string[] code = _codelines[_currentLine].Split("."); if ((code.Length * 128) * _scale > (GraphicsDevice.Viewport.Width / 2) - _cameraPosition.X) { _cameraPosition.X -= 128 * _scale; } else if ((code.Length * 128) * _scale <= (GraphicsDevice.Viewport.Width / 2)) { Console.WriteLine((code.Length * 128) * _scale); Console.WriteLine((GraphicsDevice.Viewport.Width / 2) - _cameraPosition.X); Console.WriteLine(); _cameraPosition.X = 0; } if ((_currentLine * 128) * _scale > (GraphicsDevice.Viewport.Height / 2) - _cameraPosition.Y) { _cameraPosition.Y -= 128 * _scale; } if ((_currentLine * 128) * _scale < 0 - _cameraPosition.Y) { _cameraPosition.Y += 128 * _scale; } base.Update(gameTime); }