4 Replies Latest reply on Apr 24, 2006 9:36 AM by Bhavzzz

    Displaying random colour in director

      Hi, I hope someone can help me with this. Basically I’m creating a game which consists of empty squares on the screen that the user fills in with colours, this would be done by the user pressing different keys, for example if ‘A’ was pressed the program would identify the key that was pressed and also identify the colour that is has been allocated ‘RED’ for instance, then it would randomly select an empty square and fill it with the colour red.

      The following code randomly selects a square from a global list and eliminates it from the list once it has been selected, so that the program does not select the same square again, as well as check if any squares are empty.

      However I have a problem in terms of getting the program to fill the selected square with a colour, I have tried everything but seem to get nowhere . Hope someone can help me with this.

      Thanks in advance

      on keydown
      global gList
      vMax = gList.count
      if not vMax then
      end if

      vIndex = random(vMax)
      vSquare = gList[vIndex>

      if the keypressed="A" then vColour = rgb(255,0,0)and vColour=vSquare
      if the keypressed="B" then vColour = rgb(255,128,0)and vColour=vSquare
      end if
      end if
      end keyDown