Hi,
I want my program to create a new "card" every time I click on an icon in the left corner.
I made two versions:
http://001.00.funpic.de/processing/
Version 1 is working but only creates one card.
Version 2 does not work. I am getting these errors:
- Temporary_6057_5044.java:17:8:17:18: Semantic Error: The type of the right sub-expression, "int", is not assignable to the variable, of type "int[]".
- Temporary_4380_5324.java:25:3:25:22: Semantic Error: The type of the right sub-expression, "processing.core.PImage", is not assignable to the variable, of type "processing.core.PImage[]".
This is the source code of version 2:
PFont schrift;
PFont schrift2;
PImage portrait;
PImage [] iportrait;
int rectx;
int recty;
int numberofcards = 0;
int [] cardx = 160;
int [] cardy = 20;
void setup() {
size(800,600);
schrift = loadFont("BitstreamVeraSans-Roman-14.vlw");
schrift2 = loadFont("BitstreamVeraSans-Bold-24.vlw");
portrait = loadImage("portrait.jpg");
iportrait = portrait;
rectx = width-100;
recty = height-100;
}
void draw() {
background(255);
noFill();
rect(20,20,111,151);
image(portrait, 21, 21);
textFont(schrift2, 24);
fill(255);
text("NEW",42,166);
me();
card();
}
void me() {
stroke(0);
fill(180,0,0);
rect(rectx,recty,50,50);
textFont(schrift2, 24);
fill(255);
text("ME",rectx+6,recty+35);
}
void card(){
if (numberofcards != 0) {
/*This is a card*/
stroke(0);
fill(255);
line(cardx[numberofcards], cardy[numberofcards], cardx[numberofcards], cardy[numberofcards]+150);
line(cardx[numberofcards], cardy[numberofcards], cardx[numberofcards]+340, cardy[numberofcards]);
line(cardx[numberofcards]+340, cardy[numberofcards], cardx[numberofcards]+340, cardy[numberofcards]+150);
line(cardx[numberofcards]+340, cardy[numberofcards]+151, cardx[numberofcards], cardy[numberofcards]+151);
image(iportrait[numberofcards], cardx[numberofcards]+1, cardy[numberofcards]+1);
line(cardx[numberofcards]+110, cardy[numberofcards], cardx[numberofcards]+110, cardy[numberofcards]+150);
textFont(schrift, 14);
fill(0);
text("Name:",cardx[numberofcards]+120,cardy[numberofcards]+30);
text("Tags:",cardx[numberofcards]+120,cardy[numberofcards]+55);
text("Notes:",cardx[numberofcards]+120,cardy[numberofcards]+80);
}
}
void mousePressed() {
/* Create a new card */
if (mousePressed == (mouseX > 20) && (mouseX < 131) && (mouseY > 20) && (mouseY < 171)) {
numberofcards++;
card();
}
}
void mouseDragged() {
/* Moving me */
if (mousePressed == (mouseX > rectx) && (mouseY > recty) && (mouseX < rectx+50) && (mouseY < recty+50))
{
rectx = mouseX-25;
recty = mouseY-25;
}
/* Moving card */
if (mousePressed == (mouseX > cardx[numberofcards]) && (mouseY > cardy[numberofcards]) && (mouseX < cardx[numberofcards]+331) && (mouseY < cardy[numberofcards]+151))
{
cardx[numberofcards] = mouseX-25;
cardy[numberofcards] = mouseY-25;
}
}
Why does the program not work? What do I have to change to get it working?