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
Shocking the Web : Windows
Fraction Scripts
[#Lingo: Programmer.com]
Lingo MarkUp Service
Centipede
Vdig Xtra for Windows by Abstract Plane
Copy and Paste inside non-editable fields
3D games online. New cosmic world of Tensoric.
ZoomIn/ZoomOut QTVR Sprite
Cinemac
 

 

 

Behavior Fake-3D Motion

Added on 7/31/1999

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

Rating:

Author: RobertWingate

Drop this behavior onto a bitmap sprite (or Flash, vector, etc.) for PITCH, YAW, and ROLL motion simulation effects. Motion is based on cursor position relative to a center point, constrained by a rect you define.

-- Fake-3d Motion Behavior
-- v1.0 6999
-- 1999 Robert K Wingate

-- This is a fun behavior I did for a recent |
-- online game, in lieu of a Shockwave7-safe |
-- real-time 3d rendering Xtra. Drop it onto |
-- a bitmap or vector shape, etc. castMember |
-- and see what happens. It"s short & sweet. |
-- Not true 3d, but it did the job I wanted. |
--                                           |
-- This code is emailware:  email me if you  |
-- use it. What could be cheaper?            |
-- Send comments to:  rwingate@mindmagic.com |
--                                           |_____
-- Check out the online game at:                   |
-- http://www.mindmagic.com/TFN/warp/warpchase.htm |
----------------------------------------------------

property fMoving    -- turns the effect on and off
property fRoll      -- dive / climb effect toggle
property fPitch     -- pan left / right effect toggle
property fYaw       -- roll / rotation effect toggle
property rMouseRect -- rect within which mouse movement affects motion
property pCenter    -- point around which to roll, pitch, and yaw
property spriteNum

-----------------------
on prepareFrame me
  -- Here"s where the work gets done, when the effect is on.
  -- Motion & rotation are based on current mouse position
  -- relative to the center point (as defined by you).
  -- You can tweak individual motion speeds by adjusting
  -- the floats
  
  if fMoving then
    if fPitch then
      newV = sprite(spriteNum).locV + (( pCenter[2]-mouseV() ) *.01 )
      if newV < rMouseRect.top    then newV = rMouseRect.top
      if newV > rMouseRect.bottom then newV = rMouseRect.bottom
      sprite(spriteNum).locV = newV
    end if
    
    if fYaw then
      newH = sprite(spriteNum).locH + (( pCenter[1]-mouseH() ) * .01 )
      if newH < rMouseRect.left  then newH = rMouseRect.left
      if newH > rMouseRect.right then newH = rMouseRect.right
      sprite(spriteNum).locH = newH
    end if
    
    if fRoll then
      newR = sprite(spriteNum).rotation + (( pCenter[1]-mouseH() ) * .001 )
      sprite(spriteNum).rotation = newR
    end if
  end if
end

-----------------------
on mToggle me
  -- useful for turning the effect on and off; just call
  -- this method from a keyDown script or wherever
  fMoving = not fMoving
end

-----------------------
on getPropertyDescriptionList
  r = the stage.rect
  pDef = point ( r.width / 2, r.height / 2 )
  rDef = rect  ( 0,0, r.right - r.left, r.bottom - r.top )
  
  ls = [:]
  addProp ls, #fPitch, [ #comment:"Pitch (X axis)?",
              #format:#boolean, #default:TRUE ]
  addProp ls, #fYaw, [ #comment:"Yaw (Y axis)?",
              #format:#boolean, #default:TRUE ]
  addProp ls, #fRoll, [ #comment:"Roll (Z axis)?",
              #format:#boolean, #default:TRUE ]
  addProp ls, #fMoving, [ #comment:"Start moving on beginSprite?",
              #format:#boolean, #default:TRUE ]
  addProp ls, #pCenter, [ #comment:"Center point around which to move",
              #format:#point, #default:pDef ]
  addProp ls, #rMouseRect, [ #comment:"Mouse movement hot rect",
              #format:#rect, #default:rDef ]
  return ls
end

-----------------------
on getBehaviorDescription me
  txt = "Drop this behavior onto a bitmap sprite (or Flash,"
  txt = txt && "vector, etc.) for PITCH, YAW, and ROLL motion"
  txt = txt && "simulation effects." & RETURN&RETURN & "Motion"
  txt = txt && "is based on cursor position relative to a center"
  txt = txt && "point, constrained by a rect you define."
  return txt
end

 


Contact

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

Send e-mail