What I need is to develop a room with some furniture
and my character that will walk in this room and don't cross throw walls
neither tables etc. It will turn around or take another way.
You could use loc (or locH and locV) and/or the keyword "intersects" to tell the character sprite where walls and tables, etc. are. The code would be something like an expansion of -

global gMoveRight
on exitFrame me
go to the frame
if sprite 1 intersects sprite 2 then
gMoveRight = FALSE
else if sprite(1).locH < 46 then -- left edge of screen (or a wall)
gMoveRight = TRUE
end if
if gMoveRight = TRUE then
sprite(1).locH = sprite(1).locH + 2
else
sprite(1).locH = sprite(1).locH - 2
end if
end

I applied this to a couple of geometric shapes and the result is that the square (sprite 1) moves across the stage until it meets the circle (sprite 2), then goes back the other way until it reaches the edge of the stage and turns around again. A little bit of mathematics, and it is quite easy to make a sprite "bounce" off another sprite at an angle that is relative to the angle at which it approached - as would happen on say a pool table.
Hope this helps
Alan

[To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/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