Jump to content


Displaying random colour in Director


  • You cannot reply to this topic
No replies to this topic

#1 GuessWho

    Young Padawan

  • Members
  • Pip
  • 1 posts

Posted 23 April 2006 - 11:17 AM

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 :D

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

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

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





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users