I tried but I can t make to work… i made the menu but i don t know how to write in procesing my ideas … when i press the button named “apa” to show the wather molecule and when i press the second button to show me the second molecule… i know i need to make with if statements but i don t know how can you help me pls?
Here is my code:
import controlP5.*;
import peasy.*;
color rectColor, circleColor, baseColor;
boolean circleOver = false;
color currentColor;
boolean rectOver = false;
ControlP5 Button;
PeasyCam cam;
Atom oxigen;
Atom hidrogen;
float x, y;
void setup() {
size(600, 600, P3D);
cam=new PeasyCam(this, 400);
Button=new ControlP5(this);
oxigen= new Atom(80);
hidrogen= new Atom(50);
//Button.addButton("Apa (H2O)")
//.setValue(0)
//.setPosition(100,100)
//.setSize(200,19) ;
}
void draw() {
background(0);
lights();
translate(x, y);
fill(255,0,0);
oxigen.show();
translate(75, 75);
fill(255);
hidrogen.show();
translate(-140, 0);
hidrogen.show();
}
void keyPressed() {
if (key == CODED) {
if (keyCode == RIGHT) {
x++;
} else if (keyCode == LEFT) {
x--;
}
if (keyCode == DOWN) {
y++;
} else if (keyCode == UP) {
y--;
}
} else {
}
}
here is the class:
class Atom{
float radius;
Atom(float r){
radius=r;
}
void show(){
noStroke();
sphere(radius);
}
and here is the my menu…:
import controlP5.*;
ControlP5 buton;
void setup() {
size(400,600);
buton = new ControlP5(this);
buton.addButton("Apa")
.setValue(0)
.setPosition(100,100)
.setSize(200,19)
;
buton.addButton("Oxigen")
.setValue(0)
.setPosition(100,150)
.setSize(200,19)
;
buton.addButton("Oxidul Nitric")
.setValue(0)
.setPosition(100,200)
.setSize(200,19)
;
buton.addButton("sulfoxid")
.setValue(0)
.setPosition(100,250)
.setSize(200,19)
;
buton.addButton("Acidhidrocloric")
.setValue(0)
.setPosition(100,300)
.setSize(200,19)
;
}
void draw() {
background(0);
}