Interactive Art [Week 8] - Interactive Button
Homework
Code
import processing.serial.*;
Serial Port;
int val;
int TurnNum;
int Boom;
PImage img1;
PImage img2;
PImage img3;
void setup()
{
size(1000, 1000);
printArray(Serial.list());
Port = new Serial(this, Serial.list()[1], 9600);
TurnNum = 0;
Boom = (int) random(150);
img1 = loadImage("1.png");
img2 = loadImage("2.png");
img3 = loadImage("3.png");
}
void draw() {
//background(0);
if ( Port.available() > 0) {
val = Port.read();
println("Button Pressed: " + val);
println("Turn Num: " + TurnNum);
println("Boom: " + Boom);
if (TurnNum > Boom){
image(img3,0,0);
}
}
if (val == 0){
fill(0);
}else{
TurnNum = TurnNum + 1;
if (TurnNum >= 0 && TurnNum <=9){
image(img1,0,0);
}
if (TurnNum >= 10 && TurnNum <=20){
image(img1,0,0);
}
if (TurnNum >= 21 && TurnNum <=30){
image(img2,0,0);
}
if (TurnNum >= 31 && TurnNum <=40){
image(img1,0,0);
}
if (TurnNum >= 41 && TurnNum <=50){
image(img2,0,0);
}
if (TurnNum >= 51 && TurnNum <=60){
image(img1,0,0);
}
if (TurnNum >= 61 && TurnNum <=70){
image(img2,0,0);
}
if (TurnNum >= 71 && TurnNum <=80){
image(img1,0,0);
}
if (TurnNum >= 81 && TurnNum <=90){
image(img2,0,0);
}
if (TurnNum >= 91 && TurnNum <=100){
image(img1,0,0);
}
if (TurnNum >= 101 && TurnNum <=110){
image(img2,0,0);
}
if (TurnNum >= 111 && TurnNum <=120){
image(img1,0,0);
}
if (TurnNum >= 121 && TurnNum <=130){
image(img2,0,0);
}
if (TurnNum >= 131 && TurnNum <=140){
image(img1,0,0);
}
if (TurnNum >= 141 && TurnNum <=150){
image(img2,0,0);
}
}
if (TurnNum >= 10){
}
}
FILE: https://www.dropbox.com/s/f481dxhph23y4px/RopeJump.zip?dl=0
Comentarios
Publicar un comentario