how to open and close a door after a random amount of time.

hi, i was just wondering how do you get a door to open for 5 seconds then close 8 seconds and have that repeat but the door would open at a random amount of time.

Answers

  • edited March 2018

    Do you know how to open the door? Do you have the code for the door? What have you attempted?

    Here is how I would attack the problem:

    1. How to open the door? Program a door and a way to open it, and a way to close it. It doesn't have to be spectacular or complicated. Just proof of concept.

    2. Find some way to track time. Maybe a clock? Check out millis(); in the reference at processing.org

    3. Make the clock react to inputs. How? The modulo might be useful, or you can set some variable to the value of millis() and then when that variable minus millis() is equal to or less than zero, you have reached your goal.

    4. Generate random numbers and make the door and the clock kommunicate.

  • edited March 2018

    This would be enough for a start with (1)

    text(„door is open“, 100,100);

    OR

    text(„door is closed“, 100,100);

    together with background (0); before it in draw()

Sign In or Register to comment.