basic programming issue

For tomorrow im making a small board game, what I need to write is the following:
A software that uses two sensors (piezo’s) and adds a timelimit to the game, everything regarding the very game is compleatly irrelevant. So, when player1 made his move he activates the sensor, a timelimit starts and player2 needs to make his move and activate his sensor before time runs out. If he manages, player1 needs to do the same thing and so on. If a player fails to activate his sensor in time he doesnt get to use his turn and the other player gets 2 turns in a row.
I will be able to write the output for whos turn it is etc, I just have an issue creating the part were one needs to hand over the turn. I got some help in school, but wasnt enough. Therefor I have a half-finished code that looks wierd. I guess im looking for some help with the general layout of the code, actually anything would help me at this state. As you may understand from looking at it I havent written all of it on my own.
All kind of comments and help is very very appriteated!

    // these constants won't change:

    const int treshold = 100;  // threshold value to decide when the detected sound is a knock or not

    int timer = 30000; //timer of 30 seconds
    int val = 0;
    int player = 0; //declared to be able to identify player1 and 2
    int led1 = 2; // LED1,
    int led2 = 3; //LED2
    int peizoIn1 = 0; //the speaker AND sensor for player1
    int peizoIn2 = 1; //for player 2
    long time; //not sure what this is, something for millis..

    void setup() {
      Serial.begin(9600);       // use the serial port
    }
//trying to create the 30 sec timelimit here, using the LEDs to indicate //it I havent figured out how to "pass the turn" to the next player tho.
// So all they do is activating the LEDs so far.
    void loop() {
      if((millis()-time)>30000){
        digitalWrite(led1,LOW);
        digitalWrite(led2,LOW);
        if(player == 1){
          digitalWrite(led2, HIGH);
          delay(500);
        }
        else{
          digitalWrite(led1, HIGH);
          delay(500);
        }

      }
//This two IF's was actually taken from a code we wrote in school, all //they do is play a beepsound from the piezo if it got activated.
      val = 0;
      delay(10);
      val = analogRead(peizoIn1);

      if(val>treshold){
        player = 1;
        time=millis();
        pinMode(peizoIn1+14, OUTPUT);
        for(int i=0; i<100; i++){
          digitalWrite(peizoIn1+14, HIGH);
          delayMicroseconds(1500);
          digitalWrite(peizoIn1+14, LOW);
          delayMicroseconds(200);
        }
        pinMode(peizoIn1+14, INPUT);
      }



      val = 0;
      delay(10);
      val = analogRead(peizoIn2);

      if(val>treshold){
        time=millis();
        player = 2;
        pinMode(peizoIn2+14, OUTPUT);
        for(int i=0; i<100; i++){
          digitalWrite(peizoIn2+14, HIGH);
          delayMicroseconds(1000);
          digitalWrite(peizoIn2+14, LOW);
          delayMicroseconds(200);
        }
        pinMode(peizoIn2+14, INPUT);
      }


    }

Some comments and some #defines/const int would be helpful.

Tried to explain it as good as I can!

I was just wondering why this

peizoIn2+14

and this:

if(val>treshold){
        player = 1;
        time=millis();
        pinMode(peizoIn1+14, OUTPUT);
        for(int i=0; i<100; i++){
          digitalWrite(peizoIn1+14, HIGH);
          delayMicroseconds(1500);
          digitalWrite(peizoIn1+14, LOW);
          delayMicroseconds(200);
        }
        pinMode(peizoIn1+14, INPUT);
      }

are repeated - they should be off in a subroutine.

I honestly don't know, maybe it would be better if I didnt even show any code and just stated my issue. I guess what im looking for is a direction or a path to follow when writing the code, since this is sort of a merge of many codes, which I do not fully understand.

In some wierd way I made progress tho, in it's current state it does pass the light and turn over to the other player after 30 seconds, so I only need to add something forcing him or her to activate the sensor before time runs out.

The best way of trying to work out what you want to do is to forget what happens when you do it; that bit is probably 90%+ there, so put it out of your mind (or better still, into a subroutine) and concentrate on thinking of how [u]you[/u] would do it, not the Arduino.

Think about a cycle of events, looking at the clock every loop to see if your time is up. Use flags to remember what you need to do.

(I'm sorry, you've already said it was for school, so I can't write it for you)

ait, I'll give it a try. thanks for the fast anwsers and help so far, if I'll drop a post if I solve it. Peace