JackRichards
JackRichards
plain_text
4 years ago
757 B
7
Indexable
// IGME470 Snake Processing import processing.serial.*; import ddf.minim.*; import processing.sound.*; Serial myPort; String val; int trigger; Minim minim; AudioPlayer player; SoundFile file; void setup() { String portName = Serial.list()[0]; myPort = new Serial(this, portName, 9600); minim = new Minim(this); size(400,400); player = minim.loadFile("tone.mp3"); } void draw() { if(myPort.available() > 0) { val = myPort.readStringUntil('\n'); playAudio(); println(val == null ? "" : val); } } void playAudio() { if(val == null){ return; } val = val.trim(); if (val.equals("You did not scroll long enough. Bad human. CONSUME!!!")) { file = new SoundFile(this, "tone.mp3"); file.play(); } }
Editor is loading...