We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello guys, i am bad at english, hope you guys understand what i'm talking about. I am working on my assignment of processing, i would like to create a mini game like NS SHAFT. I want 3 object move from the bottom to the top,
in my code , obsX is the x position, obsY is y position:
obsX=int(random(-50, width-200));
obsY=height-100;
obsX2=int(random(-50, width-200));
obsY2=height+200;
obsX3=int(random(-50, width-200));
obsY3=height+400;
obsWidth=200;
obsHeight=100;
obsSpeed=5;
and i write a function call wood to make it move those objects upward:
void wood() {
image(cloud,obsX, obsY, obsWidth, obsHeight); obsY=obsY-obsSpeed;
image(cloud,obsX2, obsY2, obsWidth, obsHeight); obsY2=obsY2-obsSpeed;
image(cloud,obsX3, obsY3, obsWidth, obsHeight); obsY3=obsY3-obsSpeed;
}
How could i use array and for loop to simplify the code??
Comments
excuse me, can you teach me how to detect the rectangle when it touch the character? ^:)^
See other thread
Just use dist() in a for-loop with i