Skip navigation

…code

Each member of the team did one part of the programming. The programming divides into four parts: 1) “Menu and Send Menu”, 2) “Find Menu”, 3) “Receive”, 4) “Get information”. The last two parts concern what happens after the interaction after the interaction between the person and the origami. And then at the end we put the first two parts together, for us this was the biggest technical challenges.

The main code was divided in two tabs: logic and graphic. The graphic part, loads and draws images that are displays in the application. And defines the each screen. The logic part, organizes the order of the images, such as calling each menu and screen. The two parts, logic+graphic, is interrelated.

“Menu and Send Menu”

Set up and name each screen to make it equal to a number, likes the mathematics. That is easy to make you remember the each screen.

int screen_menu1 = 0;
int screen_screen1 = 1;
int screen_screen2 = 2;
int screen_screen3 = 3;
int screen_screen4 = 4;
int screen_menu2 = 5;

Use the “Boolean” to control the flower and dragonfly because these two icon are on the same screen at the first we must name them are false, it means that they can’t move at the beginning. Then when the mouse pressed the “Boolean” came to true and then the animation works.

boolean okToMoveFlower=false;                                                                     boolean okFlower=true;                                                                                                                                  boolean DragonflyMove=false;

The part of setup, load every screen that is happened in the application. Measure the size of your phone screen.

void setup() {
size (320,480);
loadSend();
loadMenu();
loadMenu1();
loadScreen1();}

Set a different screen and show the different content.

void draw() {
if(screenMode == -2) {
drawMenu();
}
else if(screenMode == -1) {
drawSend();
}
else if(screenMode == screen_menu1) {
drawMenu1();

The animation of the mouse in every different screen. That will control move the flower or the dragonfly, and then show the next screen after your click.

void mousePressed() {
if(screenMode == -2) {
if (mouseX>225&&mouseX<305&&mouseY>25&&mouseY<105) {
okToMoveFlower = true;
}
if (mouseX>5&&mouseX<85&&mouseY>375&&mouseY<445) {
DragonflyMove =true;
}

“Send Message”

This part of code is for blow the flower on the water and will show you how to set microphone input and audio volume threshold.

import ddf.minim.*;
Minim minim;
AudioInput input;


float threshold = 0.2;
float highestVolume = 0;
boolean wasLoud = false;

void setup() {
minim = new Minim(this);
input = minim.getLineIn();

void draw () {
image(sfondo,0, 0);
image(hand,110,380);
image(flower,cx,cy);
x=x+1;

boolean loud = false;
// measure all signals and finds the highest one
for (int i = 0; i < input.bufferSize() – 1; i++) {
if (input.mix.get(i) > threshold) {
loud = true;
highestVolume = input.mix.get(i);
wasLoud = true;
}
}
if (loud) {
cy = cy – (highestVolume * 15);
cy = constrain(cy,width*1/2,height*1/2);
}

if(cy == constrain(cy,width*1/2,width*1/2)) {
image(handmenu,10,10);
hand= nothing;
x=x+1;
}
if(frameCount % 100 == 0) {
image(flower,cx,cy);
}
image(flower,cx,cy);
}

“Loading”

This part of code is for show you a process of download the message which your mobile phone got. The process is like to open a paper flower.

int loadingletter=1;
PImage loading;

void setup(){
size(320,480);
}

void draw(){
if (loadingletter<=25) {
loading = loadImage ((“a”+ loadingletter)+”.png”);
image (loading, 85, 120);
if(frameCount%5==0) {
loadingletter+=1;
}
}
}

home |  concept |  design | process | code | critical reflection | teamwork | download |