I had the sprite bouncing off the other one and thought it was working later
to dicover that it would only work on one side of the sprite its intersecing
with. would you take a look at the script and try telling me what i am doing
wrong?
this is the only script in the movie:
property crash
on crash
if the locv of sprite(1) < the locv of sprite(2) then
sprite(1).loch = sprite(1).loch -5
sprite(1).locv = sprite(1).locv -5
end if
if the locv of sprite(1) > the locv of sprite(2) then
sprite(1).locv = sprite(1).locv +5
sprite(1).loch = sprite(1).loch +5
end if
if the loch of sprite(1) < the loch of sprite(2) then
sprite(1).locv = sprite(1).locv -5
sprite(1).loch = sprite(1).loch -5
end if
if the loch of sprite(1) > the loch of sprite(2) then
sprite(1).loch = sprite(1).loch +5
sprite(1).locv = sprite(1).locv +5
end if
end
on enterframe me
---------------------Keyboard movements----------------------------
------------------------And Crashes--------------------------------
-- left ----------------------------------------------------------
if keyPressed(123) then
sprite(me.spritenum).loch = sprite(me.spritenum).loch -5
sprite(me.spritenum).locv = sprite(me.spritenum).locv -3
if sprite 1 intersects sprite 2 then
crash
end if
-- left ----------------------------------------------------------
else
-- right ----------------------------------------------------------
if keyPressed(124) then
sprite(me.spritenum).loch = sprite(me.spritenum).loch +5
sprite(me.spritenum).locv = sprite(me.spritenum).locv +3
if sprite 1 intersects sprite 2 then
crash
end if
-- right ----------------------------------------------------------
else
-- Down ----------------------------------------------------------
if keyPressed(125) then -- down
sprite(me.spritenum).locv = sprite(me.spritenum).locv +3
sprite(me.spritenum).loch = sprite(me.spritenum).loch -5
if sprite 1 intersects sprite 2 then
crash
end if
-- Down ----------------------------------------------------------
else
-- Up ----------------------------------------------------------
if keyPressed(126) then -- up
sprite(me.spritenum).locv = sprite(me.spritenum).locv -3
sprite(me.spritenum).loch = sprite(me.spritenum).loch +5
if sprite 1 intersects sprite 2 then
crash
end if
-- Up ----------------------------------------------------------
end if
end if
end if
end if
---------------------Keyboard movements----------------------------
------------------------And Crashes--------------------------------
end
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of Jonas Brink Wors�e
Sent: 25 November 2000 03:47
To: [EMAIL PROTECTED]
Subject: Re: <lingo-l> To move or not to move. ( that is the
question!!!!!!! )
You're not giving much information on how you're moving the stuff, but
perhaps these comments will help you.
When moving something (i.e. a sprite) by keypresses, it is always a good
idea to set a variable according to the keypressing and then move the sprite
according to that variable. That way you can easily, when certain conditions
have been met, like collision or bounderycrossing of some sort, change that
variable. Like "myMovement=0" or "myMovement=-myMovement". The last example
will make the sprite move in the opposite direction. Sort of like bouncing,
I guess. Well, not quite, but perhaps enough to suit your needs.
Furthermore, upon methods of collisiondetection, it is always a good idea to
store the previous postion just before moving the object, so that you can
restore the object back to where it was before the collision.
I hope this helps. If not, you might want to post your code in order to get
a more accurate answer.
Fare well into the world of Lingo.
/jonas
----- Original Message -----
From: Rees, Jonathan <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, November 25, 2000 2:45 AM
Subject: <lingo-l> To move or not to move. ( that is the question!!!!!!! )
> The sprite is moving across the stage, it interacts with another object.
How
> do I prevent it from going over the the other object or making it bounce
> back say 2 pixels in the reverse direction.
[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!]
[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!]