Program won't update
Card[] a;
int numcards = 20;
void setup(){
size(650, 400);
rectMode(CENTER);
f = createFont("Arial",16,true);
textFont(f);
a = new Card[numcards];
for(int i = 0; i < numcards; i++){
a[i] = new Card(i*30 + 15, 60, i+1);
}
}
void draw(){
update();
switchcards(0,1);
}
void waittime(int i){
int time = millis();
while(millis() - time < i){}
}
void update(){
background(255);
for(int i = 0; i < numcards; i++){
a[i].carddraw();
}
}
void selectionSort(){
for(int i = 0; i < numcards; i++){
int m = i;
int j;
for(j = i+1; j < numcards; j++){
if(a[j].num < a[m].num){
m = j;
}
}
switchcards(i, m);
}
}
void switchcards(int i, int j){
int w = a[i].y;
int v = a[j].y;
for(int k = 0; k <= 200; k++){
a[i].y = w + k;
a[j].y = v + k;
update();
waittime(5);
}
w = a[i].x;
v = a[j].x;
for(int k = 0; k <= v-w; k++){
a[i].x = w + k;
a[j].x = v - k;
update();
waittime(5);
}
w = a[i].y;
v = a[j].y;
for(int k = 0; k <= 200; k++){
a[i].y = w - k;
a[j].y = v - k;
update();
waittime(5);
}
}
class Card{
int x;
int y;
int num;
Card(int num_){
num = num_;
}
Card(int x_, int y_, int num_){
x = x_;
y = y_;
num = num_;
}
Card(Card c){
this.x = c.x;
this.y = c.y;
this.num = c.num;
}
void carddraw(){
fill(255, 180, 60);
stroke(0);
rect(x, y, 28, 50);
fill(0);
text("" + num, x-10, y);
}
}