Arrays? (Overlapping images)
in
Programming Questions
•
1 year ago
I am having trouble with the falling apples. When the cart overlaps with the apple, I would want it to disappear or move to a certain location on the screen (such as top left corner).
void FallingApple()
{
for (int i=0; i<7; i++)
{
a[i].show();
a[i].move();
if ( a[i].y > height)
{
a[i].x = random (50, width-50);
a[i].y = random(-5, 0);
}
}
}
class Apple
{
int n;
float x, y, v, vx, vy ;
// float r;
Apple()
{
// x = random(40, 500);
y = random(-5, 0);
// r = random(24, 30);
vx = 0;
vy = random(2, 3);
n =(int)random(0, 15);
}
void show()
{
image(thing01s1, x, y);
textFont(myFont2, 30);
fill(255);
text (n, x+30, y+55);
}
void move()
{
x += vx;
y += vy;
}
}
void drawPlayers()
{
image (cart, u, v); //0, height-145
}
1