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
Closing a MIAW
Import from Access - Valentina
Detecting Quicktime
DM Transitions Pack 2
StartFramesScript
BrowserController
Slider behaviour v2.2
DragPicture
Buddy API
Components XObject
 

 

 

Behavior space crawling

Added on 6/30/2002

 

Compatibilities:
D8 D8_5 PC

This item has not yet been rated

Author: vlau

To simulate driving a spaceship flying in the space.

Download PC Source
-- Move forward or backward

property pOrigLocV1, pOrigLocV2, pMax, pLocV
global g_speed, g_direction

on getPropertyDescriptionList me
  list = [:]
  addProp list, #pMax, [#comment:"Maximum pixels to be moved",#format:#integer,#default:0]
  return list
end

on beginSprite me
  pOrigLocV1 = sprite(me.spriteNum).locV
  pOrigLocV2 = sprite(me.spriteNum).locV + pMax
  reset(me)
end

on reset me
  pLocV = 0
  if g_direction = "Forward" then
    sprite(me.spriteNum).locV = pOrigLocV1
  else
    if g_direction = "Backward" then
      sprite(me.spriteNum).locV = pOrigLocV2
    end if
  end if
end

on exitFrame me
  pLocV = pLocV + pMax / g_speed
  if g_direction = "Forward" then
    sprite(me.spriteNum).locV = pOrigLocV1 + pLocV
  else
    if g_direction = "Backward" then
      sprite(me.spriteNum).locV = pOrigLocV2 - pLocV
    end if
  end if
  
  if g_direction = "Forward" then
    if sprite(me.spriteNum).locV >= pOrigLocV1 + pMax then
      reset(me)
    end if
  else
    if g_direction = "Backward" then
      if sprite(me.spriteNum).locV <= pOrigLocV1 then
        reset(me)
      end if
    end if
  end if
end
-------------------------------------------------------------------
-- Move left or right

property pOrigLocH1, pOrigLocH2, pOrigAngle, pLocH, pAngle
property pMaxL, pMaxR, pMaxAR, pMaxAL
global g_speed, g_direction

on getPropertyDescriptionList me
  list = [:]
  addProp list, #pMaxL,   [#comment:"Maximum pixels moved to the left",#format:#integer,#default:0]
  addProp list, #pMaxR,   [#comment:"Maximum pixels moved to the right",#format:#integer,#default:0]
  addProp list, #pMaxAR, [#comment:"Maximum angle rotated to the right",#format:#integer,#default:0]
  addProp list, #pMaxAL, [#comment:"Maximum angle rotated to the left",#format:#integer,#default:0]
  return list
end

on beginSprite me
  pOrigLocH1 = sprite(me.spriteNum).locH
  pOrigLocH2 = sprite(me.spriteNum).locH - pMaxL
  pOrigAngle = sprite(me.spriteNum).rotation
  reset(me)  
end

on reset me
  pLocH = 0
  sprite(me.spriteNum).locH = pOrigLocH1
  sprite(me.spriteNum).rotation = pOrigAngle
end

on exitFrame me
  if g_direction = "Left" then
    pLocH = pLocH + pMaxR / g_speed
    pAngle = (pMaxAL - pOrigAngle) / g_speed
    sprite(me.spriteNum).locH = pOrigLocH1 + pLocH
    sprite(me.spriteNum).rotation = sprite(me.spriteNum).rotation + pAngle
  
  else
    
    if g_direction = "Right" then
      pLocH = pLocH + pMaxL / g_speed
      pAngle = (pMaxAR - pOrigAngle) / g_speed
      sprite(me.spriteNum).locH = pOrigLocH1 - pLocH
      sprite(me.spriteNum).rotation = sprite(me.spriteNum).rotation + pAngle
    end if
  end if
  
  if g_direction = "Left" then
    if sprite(me.spriteNum).locH >= pOrigLocH1 + pMaxR then
      reset(me)
    end if
  else
    if g_direction = "Right" then
      if sprite(me.spriteNum).locH <= pOrigLocH2 then
        reset(me)
      end if
    end if
  end if
end
-------------------------- end ---------------------------------



 


Contact

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

Send e-mail