Hi, Rich.

Thanks for your help, but I will explain more cleary what I need:

Imagine a card game. I need move some cards (intersecteds) over the table.
I will use the rightMouseDown and rightMouseUp to do this. When I press the
right botton over a card, is verifyed all the cards what make intersection
with this card (spriteNum). The result is a list what contain the number
and coord of each sprite intersected. I need analyse this fast! If I use 2
loops the result is slow because I will count of 160 to 264 (I have 104
cards) * 160 to 264. 

I don't know why this not work with my script...

My complete script is:


property spriteNum
on rightMouseDown me
  global coordAntiga, listaSpritesMovidos, spriteAnal, spriteAnal2
  set listaSpritesMovidos=[:]
  ---listaSpritesMovidos.addProp(spriteNum,(sprite(spriteNum).loc))
  set coordAntiga= sprite(spriteNum).loc
  set spriteAnal= spriteNum
  set spriteAnal2= spriteNum
  repeat with i=160 to 264
    if (sprite(i).intersects(spriteAnal)) and
(findPos(listaSpritesMovidos,i)=void) then 
      listaSpritesMovidos.addProp(i,(sprite(i).loc))
      if findPos(listaSpritesMovidos,spriteAnal)=void then
listaSpritesMovidos.addProp(spriteAnal,(sprite(spriteAnal).loc))
      spriteAnal=i
      i=160
    end if    
  end repeat
  
  sort(listaSpritesMovidos)
  put listaSpritesMovidos
  put "numero="&count(listaSpritesMovidos)
  
  repeat while the stillDown
    sprite(spriteNum).loc=the mouseLoc
  end repeat
  
end

on rightMouseUp me
  global coordAntiga, listaSpritesMovidos, spriteAnal, spriteAnal2
  set coordNova=sprite(spriteNum).loc
  difCoord=coordNova-coordAntiga
  repeat with i=1 to count(listaSpritesMovidos)
    sprite(getPropAt(listaSpritesMovidos,
i)).loc=((getAt(listaSpritesMovidos, i))+difCoord)
    updateStage
  end repeat
  updateStage
  set listaSpritesMovidos2=[:]
  
  repeat with i=160 to 264
    if (sprite(i).intersects(spriteAnal2)) and
(findPos(listaSpritesMovidos2,i)=void) then 
      listaSpritesMovidos2.addProp(i,(sprite(i).loc))
      if findPos(listaSpritesMovidos2,spriteAnal2)=void then
listaSpritesMovidos2.addProp(spriteAnal2,(sprite(spriteAnal2).loc))
      spriteAnal2=i
      i=160
    end if    
  end repeat
  sort(listaSpritesMovidos2)
  put listaSpritesMovidos2
  put "numero="&count(listaSpritesMovidos2)
  
  if (count(listaSpritesMovidos2)) > (count(listaSpritesMovidos)) then
    alert "Evite que duas canastras se intersectem"    
    repeat with i=1 to count(listaSpritesMovidos)
      sprite(getPropAt(listaSpritesMovidos,
i)).loc=(getAt(listaSpritesMovidos, i))
      updateStage
    end repeat    
  end if
  
end





At 13:17 18/01/01 -0500, you wrote:
>
>
>On 1/31/01 12:36 AM, Fabricio G. Bissoli ([EMAIL PROTECTED]) sent:
>
>>spriteAna= spriteNum
>>set listaSpritesMovidos2=[:]
>>repeat with i=160 to 264
>>    if (sprite(i).intersects(spriteAna)) and 
>findPos(listaSpritesMovidos2,i)=void) then 
>>      listaSpritesMovidos2.addProp(i,(sprite(i).loc))
>>      spriteAna=i
>>      i=160
>>    end if    
>>end repeat
>
>
>Fabricio,
>
>I'm not sure exactly what you want, but I think the script has some 
>problems. 
>
>First, there is an unbalanced paranthesis in the if statement after the 
>void.
>
>Second, you can avoid the findPos = void step by using setaProp instead 
>of addProp. 
>
>Third, there there are problems in the loop logic. What this script does 
>is:
>
>1) check if the first i (160) intersects with spriteNum (you didn't say 
>what that value is)
>2) (if intersection) reassign spriteAna to i (160)
>3) (if intersection) reassign i to 160 again
>
>then
>
>1) check if the first i (160 again due to reassignment) intersects with 
>last i (160)
>2) (if intersection) reassign spriteAna to i (160)
>3) (if intersection) reassign i to 160 again
>
>The reassignments are not good. In fact, the only reason this isn't an 
>infinite loop is that if there is no intersection, the i is not 
>reassigned.
>
>Try this:
>
>on exitFrame me
>  listaSpritesMovidos2=[:]
>  --listaSpritesMovidos2.sort()
>  repeat with spriteAna = 160 to 264
>    repeat with i=160 to 264
>      if sprite(i).intersects(spriteAna) AND i <> spriteAna then 
>        listaSpritesMovidos2.setaProp(i,(sprite(i).loc))
>      end if    
>    end repeat
>  end repeat
>end
>
>This checks if each sprite intersects with any other sprite in the 
>range--except itself, obviously. I sorted the list just to test the 
>results, but you may not want that so I commented that line. I hope 
>that's what you want.
>
>Rich Shupe
>
>[To remove yourself from this list, or to change to digest mode, go to
>http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
>email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
>Lingo-L is for learning and helping with programming Lingo.  Thanks!]
>
Fabricio Guedes Bissoli
Phasis Multimidia

55 32 3218-5343
55 32 9103-7978


[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to