Animation Problems - School Project
in
Programming Questions
•
2 years ago
First off I'd just like to say that I am not a programmer. This project is for school and I took it on to help myself and my group members as I do have some experience and familiarity with javascript, but I refuse to call myself a programmer
. The project we are trying to complete is to use processing to recognize a particular file on a drive. For example, you plug in your flash drive, it searches for a text file, and does an action if it does or does not find it. At the moment our code recognizes our file, plays audio when the file is or is not there, and displays an image. However, we want our code to play an animation instead of displaying an image. Our animation is 200+ frames long. I've been trying different array methods and haven't got much to work. Below is our WORKING code. If anyone could help with displaying a 200+ frame animation instead of the image we have listed it would be much appreciated!
import ddf.minim.*;
Minim minim;
AudioPlayer connect;
AudioPlayer disconnect;
PImage HappyImage;
PImage SadImage;
boolean pause = false;
File file = new File("/Volumes/JT Drive/test.txt");
int secondsPast;
void setup()
{
size (890, 438);
frameRate(100);
secondsPast = 0;
HappyImage = requestImage("Happypause.gif");
SadImage = requestImage("Sadpause.gif");
//Audio
minim = new Minim(this);
connect = minim.loadFile("happytune.mp3");
disconnect = minim.loadFile("sad.mp3");
}
void draw()
{
if (millis() % 5000 < 50)
{
if (file.exists())
{
onConnect();
background(0);
image(HappyImage, 0, 0);
println("There!");
}
else
{
onDisconnect();
background(0);
image(SadImage, 0, 0);
println("Not there!");
}
}
}
//Audio Functions
void onConnect()
{
if (disconnect.isPlaying())
{
disconnect.pause();
disconnect.rewind();
}
connect.play();
}
void onDisconnect()
{
if (connect.isPlaying())
{
connect.pause();
connect.rewind();
}
disconnect.play();
}
void stop()
{
// always close Minim audio classes when you are done with them
connect.close();
disconnect.close();
minim.stop();
super.stop();
}
import ddf.minim.*;
Minim minim;
AudioPlayer connect;
AudioPlayer disconnect;
PImage HappyImage;
PImage SadImage;
boolean pause = false;
File file = new File("/Volumes/JT Drive/test.txt");
int secondsPast;
void setup()
{
size (890, 438);
frameRate(100);
secondsPast = 0;
HappyImage = requestImage("Happypause.gif");
SadImage = requestImage("Sadpause.gif");
//Audio
minim = new Minim(this);
connect = minim.loadFile("happytune.mp3");
disconnect = minim.loadFile("sad.mp3");
}
void draw()
{
if (millis() % 5000 < 50)
{
if (file.exists())
{
onConnect();
background(0);
image(HappyImage, 0, 0);
println("There!");
}
else
{
onDisconnect();
background(0);
image(SadImage, 0, 0);
println("Not there!");
}
}
}
//Audio Functions
void onConnect()
{
if (disconnect.isPlaying())
{
disconnect.pause();
disconnect.rewind();
}
connect.play();
}
void onDisconnect()
{
if (connect.isPlaying())
{
connect.pause();
connect.rewind();
}
disconnect.play();
}
void stop()
{
// always close Minim audio classes when you are done with them
connect.close();
disconnect.close();
minim.stop();
super.stop();
}
1