randomList

  how make random things appear on random positions
list random




  randomList
At 18:03 29.03.98 -0500, Patricia Espinosa wrote:

>I think I didn't make myself clear with the poject specifications.
>I need to have 3 lists  with a specific order of elements (castmembers)

on setupTheLists
  global gListofLists
  set gListOfLists = []
  
  set La = ["pi","pa","po","pu"]
  set Lb = ["hi","ha","ho","hu"]
  set Lc = ["ti","ta","to","tu"]
  
  append gListofLists,La
  append gListofLists,Lb
  append gListofLists,Lc
end

-->
-->The first step is to get from each list, the first 3 castmembers, and
-->locate those castmembers in a RANDOM position in the stage.

The handler below takes the first of a list , puts that member into the sprite
you pass to the handler, makes that sprite appear on a random position on the stage 
and gives that member a member script that takes care of the further action. 


on putTheFirstOfListXintoSpriteY whichList, whichSprite
  -- this assumes you hve some off stage bitmap placeholder 
  -- living in sprite Y (puppetsprite = 1 if its director 5)
  global gListOfLists
  set dList = getat( gListOfLists, whichList)

  if count (dList) = 0 then exit  -- if nothings left, do nothing

  set dMbr = getat(dList,1)
  deleteAt dList,1
  set the member of Sprite whichSprite to member dMbr
  set the loc of sprite whichSprite to getRandomLocOnStage()
  set the scripttext of member dMbr = getScripttext (whichList, whichSprite)
end

on getRandomLocOnStage
  -- returns a random point on the stage
  set dRect=the rect of the stage
  set dH = the width of dRect
  set dV = the height of dRect
  return point(random(dH),random(dV))  
end

on getScripttext whichList, whichSprite
  set t1 = "on mouseUp"
  set t2 = "  putTheFirstOfListXintoSpriteY " & whichList & ", " & whichSprite
  set t3 = "end"
  
  return t1  & RETURN & t2  & RETURN & t3  & RETURN
end


Home shock + cgi Bits 'n pieces Director Lingo Shocklets Contact










pageID=l_randomList