We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › simple code, execute an event list
Page Index Toggle Pages: 1
simple code, execute an event list (Read 847 times)
simple code, execute an event list
Aug 22nd, 2009, 9:42am
 
i remember old times when Amiga demo rules the scene.

I'd like to create with Processing a script like Amiga demo "Friday at Eight " Polka Brothers, or a script like an intro.


my question is simple, i need a simple code, how i can subdivide event in the same code, example:

moving text, after ended, load an image, after ended , bouncing ball , after ended, draw ellipse?

a sequence of event subdivided by time that i decide for every event,


I have the code for every video effect , but i cannot insert in sequence........


sorry but i'm new in Processing .....

Undecided
Re: simple code, execute an event list
Reply #1 - Aug 22nd, 2009, 10:02am
 
Can't you simply use a number variable and launch functions/methods based on its current state by checking it with a condition?  

Actually I guess it's not entirely that simple - you'd need to keep a particular function running for a certain amount of time.  You could either use a timer (using millis() ) or a crude counter variable incremented each frame.

This would be one simple implementation (untested):

Code:
int currentFunction = 1;
int counter = 0;

void setup() {
 size(400,300);
frameRate(30);
}

void draw() {
 switch(currentFunction) {
 case 1:
   myFunction01();
   break;
 case 2:
   myFunction02();
   break;
 }

}

myFunction01() {
 // do stuff
// after approx 3 seconds assuming 30 fps
if (counter > 90) {
  currentFunction = 2;
counter = 0;
}
counter ++;
}

myFunction02() {
 // stuff
// after approx 3 seconds assuming 30 fps
if (counter > 90) {
currentFunction = 3;
counter = 0;
}
counter ++;
}

// etc...

Re: simple code, execute an event list
Reply #2 - Aug 22nd, 2009, 11:12am
 
Re: simple code, execute an event list
Reply #3 - Aug 22nd, 2009, 12:50pm
 
thanks , very interesting!  i will try to include music and other items inside !  Smiley
Page Index Toggle Pages: 1