how to execute sequence of operations in draw() one after another without repeating each operations

bpkbpk
edited February 2014 in Programming Questions

I want each operations should be executed once.. can anyone could help me with this issue

Answers

  • Answer ✓

    Well, use a variable to hold a value indicating at which stage your program is at! 8-}

  • Thanks I used similar method

    I used millis() function to get current time and stored in a variable(lasttime) once one event finishes and before starting the next event I used delay like millis()-lasttime > 5000

    I used this in switch case statement which produced sequence of events and I am able to see the output of each event.

  • Sometimes I use the frame count, ie if frame count is 5 do statements or call void, then if 10 do other statements, each runs once. Then to re run again set frame count back to 0. regards, Alan.

  • "set frame count back to 0"
    If you talk about frameCount, the Processing variable, I think it isn't a good idea... If that's a distinct variable, why not.
    The problem with using frame count is that the time Processing spends on each frame is variable, so 10 frames at one point of the code might be longer or shorter than 10 frames at a later time. That's why we use millis(), in general.

  • edited February 2014

    That's why we use millis(), in general.

    Agreed! But for programs which don't demand high time preciseness, frameCount is as good as millis()! ~:>

  • Yes, I understand. If time is the critical thing in the program loop, ie for videos,iimages... but just for single pass execution, it works, but should really be a defined switch status variable to toggle an execution or not.

    By the way, not a processing guru like you guys, so my code is always what ever works is best. Rarely is it reworked to look like your examples...lots of fun 8)...

Sign In or Register to comment.