behavior for playing movies depending on user selected level of difficulty.
--global level keep tracks
--if level is 1 then game is taken from "games1" folder
--if level is 2 then game is taken from "games2" folder etc.
--games should have equal names in different folders.
--Folders should have indexes 1, 2 and 3 in their names.
--here is a listing of root folder
-- -- -- --So principle is simple:
--make one game (for example memory1.dir) with level=1 difficulty and put in games1 folder
--make same but little harder game with same name and put in games2 folder
--make same but hardest game with same name and put in games3 folder
--call the game from mainMovie.dir
--depends on global "level" behavior will play movie from those three folders
--(if "level=1" from "games1" folder etc.)
--when you create buttons in mainMovie you should always select movie only from
--Apply this behavior to button and select game from first folder.
--make all buttons with all games from first folder
--during runtime when user select level of difficulty, behavior will play movie
--according to value of "level"
--global LEVEL previously selected by user. Always on start of the whole game.
--replaces index of folder with index from Level global
mydistantMovie=searchAndReplace(mydistantMovie, "1", rep)
play movie mydistantMovie
--handler to replace index with level value
on searchAndReplace input, oldStr, newStr
-- searches the input (string) for oldStr and replaces it with newStr
set output = ""
set posn = offset(oldStr, input)-1
if posn > 0 then put char 1 to posn of input after output
put newStr after output
delete char 1 to (posn + length(oldStr)) of input
put input after output
--part for selecting movie from Jump to movie behavior from director library
on getPropertyDescriptionList me
if not the currentSpriteNum then exit
-- Choose a movie with FileIO Xtra or allow
-- user to Cancel and maintain current choice
theSprite = sprite(the currentSpriteNum)
theScriptList = theSprite.scriptList
behaviorCount = theScriptList.count
if theScriptList.count() then
-- Check if behavior has already been initialized
currentMovie = GetCurrentMovie (me, theScriptList, behaviorCount)
-- Use fileIO to find the movie to jump to
fileIOChild = new (xtra "fileIO")
setFilterMask (fileIOChild, "Director movies,*.d*r")
chosenMovie = displayOpen (fileIOChild)
if chosenMovie = EMPTY then
if not stringP (currentMovie) then
return ErrorAlert (me, #getPDL_NoMovie)
movieList = [currentMovie]
movieList = [GetRelativePathTo (me, chosenMovie)]
movieList = [#noMovieChosen]
#myDistantMovie : ¬
#comment :"On mouseUp, go to movie", ¬
#format :#movie, ¬
#range :movieList, ¬
#default :movieList ¬
on GetCurrentMovie me, theScriptList, behaviorCount
-- Reads the scriptList for the current sprite to determine if a movie has
-- previously been selected returns the current value of #myDistantMovie
-- theScriptList = sprite(the currentSpriteNum).scriptList
-- behaviorCount = theScriptList.count
thisScript = string (me)
put "member ("into thisScript.word
thisScript = value (thisScript)
repeat while behaviorCount
if theScriptList[behaviorCount] = thisScript then
behaviorInitializers = value (theScriptList[behaviorCount])
if behaviorInitializers.findPos(#myDistantMovie) then
behaviorCount = behaviorCount - 1
on GetRelativePathTo me, distantMovie
-- Calculates the relative path to the target movie, by comparing its
-- full path name with that of the current movie.
thatMoviePath = distantMovie
thisMoviePath = the moviePath
saveItemDelimiter = the itemDelimiter
if the machineType = 256 then
newItemDelimiter = "\"
newItemDelimiter = ""
the itemDelimiter = newItemDelimiter
repeat while TRUE
thisFile = thisMoviePath.item
thatFile = thatMoviePath.item
if thisFile <> thatFile then exit repeat
if thatMoviePath = distantMovie then
relativePath = distantMovie
relativePath = "@"
thisDeep = thisMoviePath.item.count
repeat while thisDeep
relativePath = relativePath&newItemDelimiter
thisDeep = thisDeep - 1
relativePath = relativePath&thatMoviePath
the itemDelimiter = saveItemDelimiter
36 South Court Sq
Newnan, GA 30263