public override void Update(GameTime gameTime) { if (FlxG.PixelPerfectOverlap(_player, _spikeBottom) || FlxG.PixelPerfectOverlap(_player, _spriteTop) || FlxG.PixelPerfectOverlap(_player, _paddleLeft) || FlxG.PixelPerfectOverlap(_player, _paddleRight)) { _player.Kill(); } if (_player.X < 5) { _player.X = 5; _player.Velocity.X = -_player.Velocity.X; _player.FlipX = false; IncreaseScore(); _bounceLeft.Animation.Play("flash"); _paddleRight.Randomize(); } else if (_player.X + _player.Width > FlxG.Width - 5) { _player.X = FlxG.Width - _player.Width - 5; _player.Velocity.X = -_player.Velocity.X; _player.FlipX = true; IncreaseScore(); _bounceRight.Animation.Play("flash"); _paddleLeft.Randomize(); } if (FlxG.Keyboard.JustPressed(Keys.E) && (FlxG.Keyboard.AnyPressed(new Keys[] { Keys.LeftShift, Keys.RightShift, Keys.LeftControl, Keys.RightControl, Keys.RightAlt, Keys.LeftAlt }))) { ClearSave(); FlxG.ResetState(); } base.Update(gameTime); }
public override void Update(GameTime gameTime) { base.Update(gameTime); _bat.Velocity.X = 0; //TODO : Touch controls if (FlxG.Keyboard.AnyPressed(new Keys[] { Keys.Left, Keys.A }) && _bat.X > 10) { _bat.Velocity.X = -BAT_SPEED; } else if (FlxG.Keyboard.AnyPressed(new Keys[] { Keys.Right, Keys.D }) && _bat.X < 270) { _bat.Velocity.X = BAT_SPEED; } if (FlxG.Keyboard.JustReleased(Keys.R)) { FlxG.ResetState(); } if (_bat.X < 10) { _bat.X = 10; } if (_bat.X > 270) { _bat.X = 270; } FlxG.Collide(_ball, _walls); FlxG.Collide(_bat, _ball, Ping); FlxG.Collide(_ball, _bricks, Hit); }
public override void Update(GameTime gameTime) { base.Update(gameTime); if (_scoreText.Alpha < 1) { _scoreText.Alpha += 0.1f; } if (!_snakeHead.Alive) { if (FlxG.Keyboard.AnyJustReleased(new Keys[] { Keys.Space, Keys.R })) { FlxG.ResetState(); } return; } FlxG.Overlap(_snakeHead, _fruit, CollectFruit); FlxG.Overlap(_snakeHead, _snakeBody, GameOver); if (FlxG.Keyboard.AnyPressed(new Keys[] { Keys.Up, Keys.W }) && _currentDirection != FlxObjectDirection.DOWN) { _nextDirection = FlxObjectDirection.UP; } else if (FlxG.Keyboard.AnyPressed(new Keys[] { Keys.Down, Keys.S }) && _currentDirection != FlxObjectDirection.UP) { _nextDirection = FlxObjectDirection.DOWN; } else if (FlxG.Keyboard.AnyPressed(new Keys[] { Keys.Left, Keys.A }) && _currentDirection != FlxObjectDirection.RIGHT) { _nextDirection = FlxObjectDirection.LEFT; } else if (FlxG.Keyboard.AnyPressed(new Keys[] { Keys.Right, Keys.D }) && _currentDirection != FlxObjectDirection.LEFT) { _nextDirection = FlxObjectDirection.RIGHT; } }