home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Boot Disc 7
/
boot-disc-1997-03.iso
/
Director.5
/
DATA.Z
/
ANIMWIZ.DIR
/
00011_Script_Bullets
< prev
next >
Wrap
Text File
|
1996-03-15
|
20KB
|
592 lines
-- Bullets script
property ioFieldList
property iFieldFocus
property ioFieldFocus
property iCurrentMotionStyleIndex
property iCurrentVisualStyleIndex
-- The motion styles are:
property ikMotionInstant -- 1
property ikMotionWipe -- 2
property ikMotionRoll -- 3
property ikMotionRipple -- 4
property iFirstTIme
property iSaveSeconds
property iSaveFPS
property iSaveDelayEnter
property iSaveDelayHold
property iSaveMark
--property iSaveCycles
property iSaveAnimateTitle
on birth me
global goBulletsText
global goSeconds
global goFPS
global goDelayEnter
global goDelayHold
-- global goCycles
set ioFieldList = [goBulletsText, goSeconds, goFPS, goDelayEnter, goDelayHold]
set ikMotionInstant = 1
set ikMotionWipe = 2
set ikMotionRoll = 3
set ikMotionRipple = 4
set iCurrentMotionStyleIndex = ikMotionInstant
set iCurrentVisualStyleIndex = 1
set iFieldFocus = 1
set iFirstTime = TRUE
return me
end birth
on mInit me
global goSeconds
global goFPS
global goDelayEnter
global goDelayHold
--global goCycles
global goBullets
global goMarkFrame
global goAnimateTitle
global goVisualStyles
global goMotionStyles
global goScoreMgr
-- CheckMark parameter: channel
mInit(goMarkFrame, 4) -- channel
-- CheckMark parameter: channel
mInit(goAnimateTitle, 22) -- channel
if iFirstTime then -- use intellegent defaults
mSetValue(goSeconds, 5)
mSetValue(goFPS, 5)
mSetValue(goDelayEnter, 5)
mSetValue(goDelayHold, 5)
-- mSetValue(goCycles, 1)
mSetValue(goMarkFrame, TRUE)
mSetValue(goAnimateTitle, TRUE)
set iFirstTime = FALSE
else -- use values saved from when we last left
mSetValue(goSeconds, iSaveSeconds)
mSetValue(goFPS, iSaveFPS)
mSetValue(goDelayEnter, iSaveDelayEnter)
mSetValue(goDelayHold, iSaveDelayHold)
-- mSetValue(goCycles, iSaveCycles)
mSetValue(goMarkFrame, iSaveMark)
mSetValue(goAnimateTitle, iSaveAnimateTitle)
end if
set ioFieldFocus = GetAt(ioFieldList, iFieldFocus)
-- RadioButtons parameters: channel, nChannels, rightAnswer, default
set goMotionStyles = 0
set goMotionStyles = birth(script "RadioButton", 26, 4, 0, iCurrentMotionStyleIndex)
-- VisualStyles Params: castNum, default, nItems, channel
if the machineType < 256 then
mInit(goVisualStyles, the number of cast "BulletsVisualStylesMac", ¼
iCurrentVisualStyleIndex, 8, 19)
else
mInit(goVisualStyles, the number of cast "BulletsVisualStylesPC", ¼
iCurrentVisualStyleIndex, 8, 19)
end if
-- For keystroke validity checking
set the keydownscript = "mCheckKey(goBullets)"
end mInit
on mSetFieldFocus me, oWhom
set where = getOne(ioFieldList, oWhom)
if where = 0 then
alert("Internal error - mSetFieldFocus could not find object")
return
end if
set iFieldFocus = where
set ioFieldFocus = GetAt(ioFieldList, iFieldFocus)
end mSetFieldFocus
on mCheckKey me
if the Key = TAB then -- change focus to the next field
set iFieldFocus = IncrMod(iFieldFocus, count(ioFieldList))
set ioFieldFocus = GetAt(ioFieldList, iFieldFocus)
pass -- pass the event so the hilight goes to the next field
else
if iFieldFocus = 1 then -- the text entry field, allow anything
pass
else -- numeric fields, only allow digits
if (offset(the key, "0123456789") > 0) or (the key = BACKSPACE) then
pass
else
dontPassEvent -- restrict only to digits.
end if
end if
end if
end mCheckKey
on mSetNewMotionStyle me, theNewStyleIndex
set iCurrentMotionStyleIndex = theNewStyleIndex
end mSetNewMotionStyle
on mSetNewVisualStyle me, theNewStyleIndex
set iCurrentVisualStyleIndex = theNewStyleIndex
end mSetNewVisualStyle
on mValidate me
-- Attempt to validate the last field of focus
set lastFieldOKFlag = mValidate(ioFIeldFocus)
return lastFieldOKFlag
end mValidate
on mParseField me, theTextToParse, theHeaderFont, theHeaderSize, ¼
theBodyFont, theBodySize
global gCastNumTextAsBitmap
set castNumHeader = mModifyRichTextCM(goCastMgr, ¼
line 1 of theTextToParse, theHeaderFont, theHeaderSize)
if castNumHeader = 0 then -- error
return FALSE
end if
-- Create a cast member in the stage movie
set castNumHeaderTarget = mFindFreeCastRun(goCastMgr, 1, 1)
copyToClipBoard member castNumHeader
tell the stage
pasteClipboardInto member castNumHeaderTarget
set the name of member castNumHeaderTarget = "RichText" && string(the ticks)
end tell
set castNumList = [castNumHeaderTarget]
set maxWidth = 0
-- The following does an effective "Convert to bitmap" into a
-- known bitmap cast member to get size info.
set the picture of member gCastNumTextAsBitmap = ¼
the picture of member castNumHeader
set maxWidth = the width of member gCastNumTextAsBitmap
set heightHeader = the height of member castNumHeader / ¼
the number of lines in (the text of member castNumHeader)
repeat with thisLine = 2 to the number of lines in theTextToParse
set thisBodyLine = line thisLine of theTextToParse
-- And again for each line of the Body
set castNumBody = mModifyRichTextCM(goCastMgr, ¼
thisBodyLine, theBodyFont, theBodySize)
if castNumBody = 0 then -- error
return FALSE
end if
-- Create a cast member in the stage movie
set castNumBodyTarget = mFindFreeCastRun(goCastMgr, 1, 1)
copyToClipBoard member castNumBody
tell the stage
pasteClipboardInto member castNumBodyTarget
set the name of member castNumBodyTarget = "RichText" && string(the ticks)
end tell
add(castNumList, castNumBodyTarget)
-- The following does an effective "Convert to bitmap" into a
-- known bitmap cast member to get size info.
set the picture of member gCastNumTextAsBitmap = ¼
the picture of member castNumBody
set thisWidth = the width of member gCastNumTextAsBitmap
if thisWidth > maxWidth then
set maxWidth = thisWidth
end if
end repeat
set heightBody = the height of member castNumBody / ¼
the number of lines in (the text of member castNumBody)
-- Finally add the maximum height and width onto the end of the list
set maxHeight = Max(heightHeader, heightBody)
add(castNumList, maxHeight)
add(castNumList, maxWidth)
return castNumList
end mParseField
on mCreate me
global goMarkFrame
global goMotionStyles
global goVisualStyles
global goScoreMgr
global goCastMgr
global gDevelopmentFlag
global gCastNumTextAsBitmap
global goAnimateTitle
if not(mValidate(me)) then
return
end if
if the last char of field "BulletsText" = RETURN then
delete the last char of field "BulletsText"
end if
if field("BulletsText") = EMPTY then
alert("Please enter some text for the Bullet.")
return
end if
if the number of lines in field("BulletsText") < 2 then
alert("Bullets requires at least two lines of text, one header and any number of bullets.")
return
end if
tell the stage
set theStageFrame = the frame
end tell
set castNumVisualStyle = mGetCastNum(goVisualStyles, iCurrentVisualStyleIndex)
set theVisualStyleName = the name of cast castNumVisualStyle
set theHeaderFont = word 2 of theVisualStyleName
set theHeaderSize = word 3 of theVisualStyleName
set theBodyFont = word 4 of theVisualStyleName
set theBodySize = word 5 of theVisualStyleName
set theSeconds = integer(field "Seconds")
set animateTitleFlag = mGetValue(goAnimateTitle)
set fps = integer(field "FPS")
set nFrames = integer(theSeconds * fps)
set delayEnter = integer(field "DelayEnter")
set delayHold = integer(field "DelayHold")
-- set nCycles = integer(field "Cycles")
set markFirst = mGetValue(goMarkFrame)
set theForeColor = 255
set theBackColor = 0
--Insert bullet characters (or dashes) before bullets lines
if the machineType < 256 then
set charsToPrepend = "ò "
else
set charsToPrepend = "- "
end if
set nSourceLines = the number of lines in field "BulletsText"
set theSourceText = field "BulletsText"
repeat with thisLine = 2 to nSourceLines
put charsToPrepend before line thisLine of theSourceText
end repeat
-- The returned List contains a list of generated cast members to display
-- item 1 is the Header, all others are bullets
-- the last item is the maximum width
set bulletsList = mParseField(me, theSourceText,¼
theHeaderFont, theHeaderSize, theBodyFont, theBodySize)
if bulletsList = FALSE then --error
return
end if
-- Pull maxWidth off the end of the list
set widthIndex = count(bulletsList)
set maxWidth = getAt(bulletsList, widthIndex)
deleteAt(bulletsList, widthIndex)
-- Pull maxHeight off end of the list
set heightIndex = count(bulletsList)
set maxHeight = getAt(bulletsList, heightIndex)
deleteAt(bulletsList, heightIndex)
set theStageWidth = mGetStageWidth(goScoreMgr)
set leftEdge = integer((theStageWidth / 2) - (maxWidth / 2))
set theStageHeight = mGetStageHeight(goScoreMgr)
set nextV = integer((theStageHeight / 2) - ((nSourceLines * value(maxHeight))/ 2))
set locVList = []
repeat with thisLine = 1 to nSourceLines
add(locVList, nextV)
set nextV = nextV + value(maxHeight)
end repeat
case iCurrentMotionStyleIndex of
ikMotionInstant:
set thisTransition = "Dissolve, Pixels Fast"
if animateTitleFlag then
-- set nFrames = delayEnter
set nFrames = 1
else
-- set nFrames = delayEnter + delayHold
set nFrames = 2
end if
ikMotionWipe:
set thisTransition = "Wipe Down"
if animateTitleFlag then
-- set nFrames = delayEnter
set nFrames = 1
else
-- set nFrames = delayEnter + delayHold
set nFrames = 2
end if
ikMotionRoll:
set thisTransition = 0
-- set nFramesPerTransition = (theSeconds * fps) + delayHold
set nFramesPerTransition = (theSeconds * fps) + 1
if animateTitleFlag then
set nFrames = nFramesPerTransition * nSourceLines
else
-- set nFrames = (nFramesPerTransition * (nSourceLines - 1)) + delayEnter
set nFrames = (nFramesPerTransition * (nSourceLines - 1)) + 1
end if
ikMotionRipple:
set thisTransition = 0
set nAnimationFrames = (theSeconds * fps)
if animateTitleFlag then
-- set nFrames = nAnimationFrames + delayHold
set nFrames = nAnimationFrames + 1
else
set nFrames = nAnimationFrames + 2
-- set nFrames = nAnimationFrames + delayEnter + delayHold
end if
end case
-- Call the ScoreMgr to set up the score, # of frames, and nSourceLines channels
if not(mInit(goScoreMgr, nFrames, nSourceLines)) then
return
end if
-- Create a list of available channels from the users selection
set chList = []
repeat with i = 1 to nSourceLines
set chNext = mGetNextSelectedChannel(goScoreMgr)
add(chList, chNext)
end repeat
set theFrameNum = mGetStartFrame(goScoreMgr)
-- Mark first frame upon request
if markFirst then
set theLabel = "AW.Bullet." & word 1 of the text of field "BulletsText" & " " & ¼
mGetGeneratedScoreSelection(goScoreMgr)
mWriteFrameLabel(goScoreMgr, theFrameNum, theLabel)
end if
-- If we're not animating the title, put it into the score
if not(animateTitleFlag) then
if thisTransition <> 0 then
mWriteFrameControl(goScoreMgr, theFrameNum, #Transition, thisTransition)
end if
set chHeader = getAt(chList, 1)
set castNumHeader = getAt(bulletsList, 1)
set locVHeader = getAt(locVList, 1)
-- repeat with i = 1 to delayEnter
-- mWriteFrameControl(goScoreMgr, theFrameNum, #Tempo, 1)
-- mWriteSprite(goScoreMgr, theFrameNum, chHeader, castNumHeader, ¼
-- theForeColor, theBackColor, leftEdge, locVHeader, 0, 0)
-- set theFrameNum = theFrameNum + 1
-- end repeat
mWriteFrameControl(goScoreMgr, theFrameNum, #Tempo, -delayEnter)
mWriteSprite(goScoreMgr, theFrameNum, chHeader, castNumHeader, ¼
theForeColor, theBackColor, leftEdge, locVHeader, 0, 0)
set theFrameNum = theFrameNum + 1
end if
if (iCurrentMotionStyleIndex = ikMotionInstant) or ¼
(iCurrentMotionStyleIndex = ikMotionWipe) then
mWriteFrameControl(goScoreMgr, theFrameNum, #Transition, thisTransition)
-- ***** repeat with i = 1 to delayHold
repeat with thisItem = 1 to nSourceLines
set chItem = getAt(chList, thisItem)
set castNumItem = getAt(bulletsList, thisItem)
set locVItem = getAt(locVList, thisItem)
-- *****mWriteFrameControl(goScoreMgr, theFrameNum, #Tempo, 1)
mWriteFrameControl(goScoreMgr,theFrameNum,#Tempo, -delayHold)
mWriteSprite(goScoreMgr, theFrameNum, chItem, castNumItem, ¼
theForeColor, theBackColor, leftEdge, locVItem, 0, 0)
end repeat
set theFrameNum = theFrameNum + 1
-- ***** end repeat
else -- ikMotionRoll or ikMotionRipple
set theStageRight = mGetStageRight(goScoreMgr)
set offStagePos = theStageRight + 10
if animateTitleFlag then
set startItem = 1
set locHList = []
else
set startItem = 2
set locHList = [leftEdge] -- start the title already at the left edge
end if
if (iCurrentMotionStyleIndex = ikMotionRoll) then -- Roll
-- Create the starting locH list, start all offstage right
repeat with i = startItem to nSourceLines
add(locHList, offStagePos)
end repeat
set nFramesPerAnimation = theSeconds * fps
set hInc = float(leftEdge - offStagePos) / float(nFramesPerAnimation)
repeat with thisBullet = startItem to nSourceLines
set thisH = getAt(locHList, thisBullet)
mWriteFrameControl(goScoreMgr, theFrameNum, #Tempo, fps)
tell the stage
beginRecording
repeat while thisH > leftEdge
-- Move the affected bullet
set thisH = integer(thisH + hInc)
if thisH < leftEdge then
set thisH = leftEdge
end if
setAt(locHList, thisBullet, thisH)
-- Write out all sprites in this frame
repeat with thisItem = 1 to nSourceLines
set chItem = getAt(chList, thisItem)
set castNumItem = getAt(bulletsList, thisItem)
set locVItem = getAt(locVList, thisItem)
set locHItem = getAt(locHList, thisItem)
mWriteSpriteRange(goScoreMgr, theFrameNum, chItem, castNumItem, ¼
theForeColor, theBackColor, locHItem, locVItem, 0, 0)
end repeat -- this Item
set theFrameNum = theFrameNum + 1
end repeat -- thisH
endRecording
end tell
-- Now generate hold frames at the end
--**** repeat with i = 1 to delayHold
--**** mWriteFrameControl(goScoreMgr, theFrameNum, #Tempo, 1)
mWriteFrameControl(goScoreMgr, theFrameNum, #Tempo, -delayHold)
repeat with thisItem = 1 to nSourceLines
set chItem = getAt(chList, thisItem)
set castNumItem = getAt(bulletsList, thisItem)
set locVItem = getAt(locVList, thisItem)
set locHItem = getAt(locHList, thisItem)
mWriteSprite(goScoreMgr, theFrameNum, chItem, castNumItem, ¼
theForeColor, theBackColor, locHItem, locVItem, 0, 0)
end repeat
set theFrameNum = theFrameNum + 1
--**** end repeat -- delay Frames
end repeat -- thisBullet
else -- ikMotionRipple
-- Build the locH starting list staggered
-- nAnimationFrames tell you how many frames of animation we have
-- from this, we calculate the staggerOffset, and the horizontal increment.
set nBulletsToMove = nSourceLines - startItem + 1
set pctOverlap = 0.25 -- percentage of overlap
set hDistance1Line = float(leftEdge - offStagePos)
set effectiveNLines = 1.0 + (pctOverLap * nBulletsToMove)
set totalHDistance = effectiveNLines * hDistance1Line
set hInc = totalHDistance / float(nAnimationFrames)
set staggerOffset = -1 * integer(hDistance1Line * pctOverLap)
set multiplier = 0
repeat with thisItem = startItem to nSourceLines
set startingPos = offStagePos + (multiplier * staggerOffset)
add(locHList, startingPos)
set multiplier = multiplier + 1
end repeat
mWriteFrameControl(goScoreMgr, theFrameNum, #Tempo, fps)
tell the stage
beginrecording
repeat with animFrame = 1 to nAnimationFrames
-- Write out all sprites in this frame using their h and v loc's
repeat with thisBullet = 1 to nSourceLines
set chItem = getAt(chList, thisBullet)
set castNumItem = getAt(bulletsList, thisBullet)
set locVItem = getAt(locVList, thisBullet)
set locHItem = getAt(locHList, thisBullet)
mWriteSpriteRange(goScoreMgr, theFrameNum, chItem, castNumItem, ¼
theForeColor, theBackColor, locHItem, locVItem, 0, 0)
-- Now, slide that bullet if needed
if locHItem > leftEdge then
set thisH = integer(locHItem + hInc)
if thisH < leftEdge then
set thisH = leftEdge
end if
setAt(locHList, thisBullet, thisH)
end if
end repeat -- thisBullet
set theFrameNum = theFrameNum + 1
end repeat -- animFrame
endRecording
end tell
-- Now generate hold frames at the end
--**** repeat with i = 1 to delayHold
--**** mWriteFrameControl(goScoreMgr, theFrameNum, #Tempo, 1)
mWriteFrameControl(goScoreMgr, theFrameNum, #Tempo, -delayHold)
repeat with thisItem = 1 to nSourceLines
set chItem = getAt(chList, thisItem)
set castNumItem = getAt(bulletsList, thisItem)
set locVItem = getAt(locVList, thisItem)
mWriteSprite(goScoreMgr, theFrameNum, chItem, castNumItem, ¼
theForeColor, theBackColor, leftEdge, locVItem, 0, 0)
end repeat
set theFrameNum = theFrameNum + 1
--**** end repeat -- delay Frames
end if -- ikMotionRipple
end if -- ikMotionRoll or ikMotionRipple
go label("Bullets") + 2 -- to display reselect button
if not(gDevelopmentFlag) then
tell the stage
go frame theStageFrame
end tell
end if
mClean(goScoreMgr)
end mCreate
on mCleanup me
global goMotionStyles
global goAnimateTitle
global goSeconds
global goFPS
global goDelayEnter
global goDelayHold
--global goCycles
global goMarkFrame
mCleanup(goMotionStyles)
set iSaveSeconds = mGetValue(goSeconds)
set iSaveFPS = mGetValue(goFPS)
set iSaveDelayEnter = mGetValue(goDelayEnter)
set iSaveDelayHold = mGetValue(goDelayHold)
--set iSaveCycles = mGetValue(goCycles)
set iSaveMark = mGetValue(goMarkFrame)
set iSaveAnimateTitle = mGetValue(goAnimateTitle)
mCleanup(goMarkFrame)
mCleanup(goAnimateTitle)
end mCleanup