Few basic Q's
in
Programming Questions
•
1 year ago
Edit: Look at my latest post for new Q's
- void setup()
- {
- size( 1000, 700 );
- stroke( 255 );
- }
- void missiles()
- {
- float endX = random(0, 1000 );
- float endY = 700;
- float randomStartX = random( 0, 1000 );
- float realX = randomStartX;
- float realY = 0;
- drawMissiles( randomStartX, endX, endY, realX, realY );
- }
- void drawMissiles( float randomStartX, float endX, float endY, float realX, float realY )
- {
- if( endX < randomStartX ) {
- while( realX > endX ) {
- realX--;
- realY++;
- }
- line( randomStartX, 0, realX, realY );
- }
- else if ( endX > randomStartX ) {
- while( realX < endX ) {
- realX++;
- realY++;
- }
- line( randomStartX, 0, realX, realY );
- }
- }
- boolean bStop;
- void keyPressed()
- {
- bStop = !bStop;
- if (bStop)
- noLoop();
- else
- loop();
- }
- void draw()
- {
- background( 192, 64, 0 );
- for( int i = 0; i < 5; i++ )
- missiles();
- keyPressed();
- }
Basically, trying to only allow 5 missiles on the screen at one time. Right now it just draws 5, then I have to press a key for it to draw another 5. Not sure how I'll do that...
Also, how do I make it so these lines are not already fully drawn by the time the program starts? I'd like you to actually WATCH the lines be draw. I'm assuming it's because it's in a while loop, but not sure how to do it otherwise...
Thanks.
1