Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
rafang1
rafang1's Profile
1
Posts
0
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
Arrays? (Overlapping images)
[1 Reply]
09-Mar-2012 10:44 AM
Forum:
Programming Questions
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
}
«Prev
Next »
Moderate user : rafang1
Forum