Skip to content

Instantly share code, notes, and snippets.

@tatianajennings
Last active December 19, 2015 02:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tatianajennings/7053e6fcb68235931915 to your computer and use it in GitHub Desktop.
Save tatianajennings/7053e6fcb68235931915 to your computer and use it in GitHub Desktop.
// var declarations
float showlength = 5; // show duration, in minutes
int screenx = 960; // screen width px.
int screeny = 600; // screen height px
int[] audienceinput; // linear array containing audience input data
int[] script; // an array containing scenes/acts/script data. Eventually it will be loaded up from a text file, for now it is random data
int inputthreshhold = 48; // how many entries does it take to trigger an "audience" event
int eventindex = 0; // which audience response triggered the event is stored here
boolean aud_eventflag = false; // this is the audience-generated event flag
boolean god_eventflag = false; // and this is the gods-generated event !00000
float m = 0; //time counter, reserved for future use
void setup() {
int x = 0; // helper/index val
// initial setup and countdown start
size(960, 600);
colorMode(RGB, 255);
background(255);
noStroke();
audienceinput = new int[10]; // number of possible choices for audience input is set to 10
// here is where we deal with the show script; eventually we'll just load and parse a text file with the timeline / scene data. For now it's all random
int scenes = int(random(screenx/20)); // lets do a random number of scenes / events; for now based on the size of the window
script = new int[scenes];
fill(230);
rect(0,screeny-20,screenx,20);
for (int i = 0; i < scenes; i++) {
script[i] = int(random(showlength*60));
}
script = sort(script);
fill(255);
for (int i = 0; i < scenes; i++) {
x = int(script[i]/(showlength*60)*screenx);
rect(x,screeny-20,1,20);
}
// initializing audience input data with zeros and drawing initial set
for (int i = 0; i < 10; i++) {
audienceinput[i] = 0;
fill(i*20+25);
rect(20+i*24, 20, 20, audienceinput[i]+1);
}
}
void draw() {
//main logic loop
// we should also draw a time bar accross the lower part of the sceen. scenes/act markers are highlighted there as well
// start of the show == start of the program
m = int(millis()/(showlength*60000)*screenx)+2;
if (m>screenx) m=screenx;
fill(186);
rect(m-2, screeny-20, 1, 20);
fill(0,0,220); //blu
rect(m, screeny-20, 1, 20);
for (int i = 0; i < 10; i++) {
fill(i*20+25);
rect(20+i*24, 20, 20, audienceinput[i]+1);
}
if (aud_eventflag) { // audience event triggered, handling code goes here
// for now we are drawing a big box in the same color as the audience event that caused it
fill(eventindex*16+48);
rect(screenx/2-50,screeny/2-30, 100,60);
}
}
void mousePressed() {
// probably not going to use mouse input for now; placeholder
int mX = mouseX;
int mY = mouseY;
}
// over here we do the Gods part. Eventually it'll be a complex affair based on many factors, such as
// scene number, audience engagement, running time, etc etc. This logic has yet to be developed, creatively-speaking
// for now we are just randomizing it, with probabability of 1%
// but we'll do in only on keypress - aka audience input, so look for it here
void keyPressed() {
// audience input via networked app is simulated here
// for now we use number keys 0-9 to enter a range of feedback options
// space key is used to clear audience-intitiated event
int j = int(key)-48; // from ascii
if (key >= '0' && key <= '9') {
audienceinput[j]++;
if (audienceinput[j] > inputthreshhold) { // ok, audience interaction threshhold is reached, triggering the event
eventindex = j;
audienceinput[j] = 0;
aud_eventflag = true;
// also draw a marker of the audience event on the time bar
fill(j*20+25);
rect(m-3, screeny-20, 1, 20);
fill(255); // reset the bar back to white
rect(20+j*24, 20, 20, inputthreshhold+1);
} else {
if (random(100)>99) {
god_eventflag=true;
fill(255,0,0); // RED !!!!
rect(screenx/2-50,screeny/2-30, 100,60);
// don't forget the time bar too
rect(m-3, screeny-20, 1, 20);
}
}
}
// space key clears all the events
if (key == ' ') {
aud_eventflag = false; // clear the audience event flag, erase the box in the center
god_eventflag = false; // clear the gods event flag too
fill(255);
rect(screenx/2-50,screeny/2-30, 100,60);
}
}
@drart
Copy link

drart commented Dec 19, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment