Processing beginner.

I'd like to make an animation that a small circle goes back and forth in a big circle using PVector.
The angle and range cannot be set for the point movement direction.

For the direction of movement, I want to move in the right direction and move in the opposite direction by bouncing off the wall of the area.
It is also the range to be moved, but I want to make it like a wall that cannot be seen with a perfect circle.
Should it be set in a way that eliminates all fills and strokes, or should it be set with a range value?

Please give me an answer.

  • Answer # 1

    There is a sample using the ball as an official sample.

    bouncingball | processing.org

    circlecollision | processing.org

    First, move the sample on this page and check the principle while outputting the value of the variable withprintln.
    If you overridetoStringof theBallclass in the following form, it is easy to check the variable with println.

      String toString () {
        return position.toString ();

    The reference page of the PVector | processing.org class is also kept as reference information.


    The angle and range of the moving direction of the point cannot be set.

    Tips for asking questions | Show the source code with reference to StackOverflow,

    Steps to reproduce the problem

    What to expect ... If it's hard to explain the behavior with text, you can use a freehand illustration.

    What was observed instead ... Execution error, compilation error, strange behavior
    Reference: Easy bug tracking | Joel on Software

    If this part of the code doesn't work, ask a question with a comment added to the code
    Since respondents can save time and effort to create source code from scratch, are they easy to answer?

    Processing tag | StackOverflow has a response rate of 82.2%, so the question ofProcessingis accompanied by an answer.

    About the site you are asking

    If you can speak English, Processing forum | processing.org

    A question with a #processing hashtag around Twitter mightprobablyhave an answer.