Exemple #1
0
        public override void _Process(float delta)
        {
            base._Process(delta);

            if (Input.IsActionPressed("ui_right"))
            {
                this.currentMoveSpeed = this.moveSpeed;
            }
            else if (Input.IsActionPressed("ui_left"))
            {
                this.currentMoveSpeed = -this.moveSpeed;
            }
            else
            {
                this.currentMoveSpeed = 0;
            }

            // Update position
            Vector2 position = this.ship.Position;

            position.x += this.currentMoveSpeed * delta;
            this.ship.SetPosition(position);

            // Check for fire
            if (Input.IsActionJustPressed("fire"))
            {
                Fire();
            }

            // Check when fire key is held
            if (Input.IsActionPressed("fire"))
            {
                UpdateFireHeld(delta);
            }
            else
            {
                this.polledTime = 0;
            }
        }