Codice
float x=300;
float y=150;
PImage[] images = new PImage[79];
PFont font;
void setup() {
background(255);
fullScreen();
smooth();
}
void draw () {
font = createFont(“Code Saver”, 32);
textFont(font);
textAlign(CENTER);
fill(200);
text(“Write something.”, width/2, height-150);
}
void keyPressed() {
images[0] =loadImage(“am.png”);
if (key == ‘A’) {
image(images[0], x, y);
x=x+40;
}
if (x>=width-340) {
image(images[0], x-40, y);
x=300;
y=y+80;
}
//Same code for each type//
images[78] =loadImage(“spazio.png”);
if (key == ‘ ‘) {
//image(images[78], x, y);
fill(255);
noStroke();
rect(x, y, 40, 80);
x=x+40;
}
if (x>=width-340) {
//image(images[78], x, y);
fill(255);
noStroke();
rect(x, y, 40, 80);
x=300;
y=y+80;
}
if (key == ENTER) {
x=300;
y=y+80;
}
if (key == ‘’) {
background(255);
x=300;
y=150;
}
if (key == BACKSPACE) {
fill(255);
noStroke();
rect(x-40, y, 40, 80);
x=x-40;
if (x<=260) {
fill(255);
noStroke();
rect(x, y, 40, 80);
x=1100;
y=y-80;
if (x<=1100) {
fill(255);
noStroke();
rect(x-40, y, 40, 80);
x=x-40;
if (y<150) {
rect(x, y, 40, 80);
x=300;
y=150;
}
}
}
}
println(x);
println(“key: ” + key);
}