Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
Making a simple game
Password Field
Glu32
Jaw Wars
Bitbull
Wondershare Flash SlideShow Builder
Fill Gradient to a Vector Shape
zScript
Hybrid CD
Director 8 Demystified
 

 

 

Behavior Basic 4 direction environment navigation

Added on 6/17/1999

 

Compatibilities:
behavior D7 D8 Mac PC

This item has not yet been rated

Author: MediaMacros (website)

This will provide basic navigation of a Myst-like environment. To generate the markers for each grid location check out the Build Environment script.

--Copyright 1999 Chuck Neal
--chuck@mediamacros.com
--If you find this code helpful, send me an e-mail and let me know.  :-)

property whichHotSpot, spriteNum

global maxX, maxY

on getPropertyDescriptionList me
  p_list = [:]
  addProp p_list, #whichHotSpot, [#format : #symbol, #comment : "What navigation hotspot:", #default: #ahead, #range : [#ahead, #turnleft, #turnright, #back]]
  return p_list
end

on mouseUp me
  --get the current marker
  currentLoc = findLastLabel()
  --set the delimiter to brak the location by
  the itemDelimiter = "-"
  currentX = integer(currentLoc.item[1])
  currentY = integer(currentLoc.item[2])
  currentD = integer(currentLoc.item[3])
  newLocList = [currentX, currentY, currentD]
  case whichHotSpot of `
    #ahead:
      --go foward 1 based upon the current direction
      case currentD of
        1:
          --Facing North
          newLocList[2] = (currentY - 1)
          if newLocList[2] < 1 then newLocList[2] = 1
        2:
          --Facing East
          newLocList[1] = (currentX + 1)
          if newLocList[1] > maxX then newLocList[1] = maxX  
        3:
          --Facing South
          newLocList[2] = (currentY + 1)
          if newLocList[2] > maxY then newLocList[2] = maxY
        4:
          --Facing West
          newLocList[1] = (currentX - 1)
          if newLocList[1] < 1 then newLocList[1] = 1
      end case
    #turnLeft:
      newLocList[3] = currentD - 1
      if newLocList[3] < 1 then newLocList[3] = 4
    #turnRight:
      newLocList[3] = currentD + 1
      if newLocList[3] > 4 then newLocList[3] = 1
    #back:
      case currentD of
        1:
          --Facing North
          newLocList[2] = (currentY + 1)
          if newLocList[2] > maxY then newLocList[2] = maxY
        2:
          --Facing East
          newLocList[1] = (currentX + 1)
          if newLocList[1] < 1 then newLocList[1] = 1  
        3:
          --Facing South
          newLocList[2] = (currentY + 1)
          if newLocList[2] < 1 then newLocList[2] = 1
        4:
          --Facing West
          newLocList[1] = (currentX - 1)
          if newLocList[1] > maxX then newLocList[1] = maxX
      end case
  end case
  goTo = string(newLocList[1]) & "-" & string(newLocList[2]) & "-" & string(newLocList[3])
  if marker(goTo) <> 0 then
    go goTo
  end if  
end

on getBehaviorDescription me
  describe = "This behavior can be dropped on hot-spots to navigate a 3d/Myst like environment.  Use the Build Environment Script to generate the markers for the environment, then set the maxX and maxY values as globals."
  return describe
end

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail