Hello Christine,

I didn't get the clear picture of what you are trying to do from your
script. The script below moves the pChip sprite at 45 degrees and when this
sprite intersects with the tree sprite, it repells and move in an opposite
direction.

------Movie script
global gTreeSprite
on prepareMovie
  gTreeSprite = 2
end

------pChip sprite script
global gTreeSprite
property pChip
property pSpeed
property pAngle

on beginSprite me
  pChip = me.spriteNum
  pSpeed = 5
  pAngle = 45
end

on exitFrame me
  checkBoundary me
  checkCollitionTree me
  sprite(pChip).locH = sprite(pChip).locH + cos(pAngle * pi()/180) * pSpeed
  sprite(pChip).locV = sprite(pChip).locV + sin(pAngle * pi()/180) * pSpeed
end

on checkBoundary me
  if sprite(pChip).locH <= 0 OR sprite(pChip).locH >= (the stage).rect.width
OR sprite(pChip).locV <= 0 OR sprite(pChip).locV >= (the stage).rect.height
then
    pAngle = (pAngle - 180)
  end if
end

on checkCollitionTree me
  if sprite(pChip).intersects(gTreeSprite) then
    pAngle = (pAngle - 180)
    sendSprite(gTreeSprite,#changeDirection)
  end if
end

------tree sprite script
property pTree
property pAngle
property pSpeed

on beginSprite me
  pTree = me.spriteNum
  pAngle = 225
  pSpeed = 5
end


on exitFrame me
  checkBoundary me
  sprite(pTree).locH = sprite(pTree).locH + cos(pAngle * pi()/180) * pSpeed
  sprite(pTree).locV = sprite(pTree).locV + sin(pAngle * pi()/180) * pSpeed
end

on changeDirection me
  pAngle = (pAngle - 180)
end

on checkBoundary me
  if sprite(pTree).locH <= 0 OR sprite(pTree).locH >= (the stage).rect.width
OR sprite(pTree).locV <= 0 OR sprite(pTree).locV >= (the stage).rect.height
then
    pAngle = (pAngle - 180)
  end if
end

regards
Ramesh CT

-----Original Message-----
From: Christine Satory <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Wednesday, October 04, 2000 10:42 AM
Subject: <lingo-l> Confusion with intersect, rects, points


>Hi,
>I'm hoping that someone can help this lingo progamming newbie! I have been
>trying to figure out how to use the intersect, rects or points for a small,
>first time "game".  My problem is that I want to stop a sprite(pChip) from
>moving forward when it encounters another sprite(a tree) on the stage--so
>that pChip bounces off it the tree -- like it hit a wall. I also want the
>tree sprite to repel the pChip sprite should come at the tree from any
>angle. (I hope this makes sense!)
>
>Here is my problem:
>
>I can get the pChip sprite to be repelled when it comes from only one
>direction(left to right) by using a hidden rectangle and using the "within"
>keyword. ( if sprite(pChip).within(sprite (2)) then....
>
>but,
>this doesn't really do the trick of repelling pChip from all directions, so
>I have been looking into the intersect, the rect, and the point---I can get
>the coordinates but I am not understanding how to use them. I've looked in
>the Director 7 Bible, Director Demystified and Macromedia's site, but this
>poor old brain is just not understanding how to use them.
>
>here is the part of the script that I have written:
>
>if keyPressed(124) = TRUE then
>    sprite(pChip).member = "chipE"
>    sprite(pChip).locH = sprite(pChip).locH + 30
>    if sprite(pChip).within(sprite(2)) = TRUE then
>      sprite(pChip).member = "chipS"
>      sprite(pChip).locH = sprite(pChip).locH - 75
>      sprite(23).member = "gRShake"
>      upDateStage
>      wait 15
>    else if sprite(pChip).within(sprite(2)) = FALSE then
>      sprite(23).member = "SHAGRASS"
>      upDateStage
>    end if
>    if keyPressed(124) = FALSE then
>      sprite(23).member = "SHAGRASS"
>      upDateStage
>    end if
>  end if
>
>
>If someone could please explain how to use the intersect, rect and points,
I
>would greatly appreciate it! Thanks in advance!
>Christine
>
>[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!]


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


[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