SimpleSoccer.Net.SoccerBall.PlaceAtPosition C# (CSharp) Method

PlaceAtPosition() public method

positions the ball at the desired location and sets the ball's velocity to zero
public PlaceAtPosition ( Vector2D NewPos ) : void
NewPos Vector2D
return void
        public void PlaceAtPosition(Vector2D NewPos)
        {
            Position = NewPos;

            OldPosition = Position;

            Velocity.Zero();
        }
    }

Usage Example

Example #1
0
        public void Update()
        {
            if (_paused)
            {
                return;
            }

            //update the balls
            _ball.Update();

            //update the teams
            _redTeam.Update();
            _blueTeam.Update();

            //if a goal has been detected reset the pitch ready for kickoff
            if (_blueGoal.CheckIfGoalScored(_ball) || _redGoal.CheckIfGoalScored(_ball))
            {
                _gameInPlay = false;

                //reset the ball
                _ball.PlaceAtPosition(new Vector2D((double)_clientWidth / 2.0, (double)_clientHeight / 2.0));

                //get the teams ready for kickoff
                _redTeam.FSM.ChangeState(PrepareForKickoffState.Instance);
                _blueTeam.FSM.ChangeState(PrepareForKickoffState.Instance);
            }
        }