| --moves sprite over stage while holding mousedown on exitFrame repeat while the mousedown set the loch of sprite 1 = the loch of sprite 1 + 4 updatestage end repeat go the frame end ------------------------- --moves sprite 14 pixels then back on exitFrame set the loch of sprite 1 = the loch of sprite 1 + 14 updatestage go the frame end ------------------------- -- sprite with in another sprite on exitFrame if sprite 1 within 2 then beep end if go the frame end -------------------------- -- when sprite touchs another sprite on exitFrame if sprite 1 intersects 2 then beep end if go the frame end ------------------------ --moves the sprite across the screen to reappear from its origin on exitFrame put 10 into hinc repeat with h = 1 to 640 set the loch of sprite 1 to h updatestage end repeat go the frame end ------------------------- Timing events in Director; Every time you start a director movie an internal clock starts within that movie or projector. The timer counts in ticks, 60 ticks = one minute. The lingo command Starttimer resets ticks back to zero. -- script to restart a movie in thrity seconds if the timer > 1800 then go "start" clear globals end if note timer is a global it so dosen't have to be declared unless you wish to carry the information to another movie.Two other items go hand in hand with timer and starttimer tese are the timeoutlength and the timeoutscript for exsample: on startmovie set the timeoutlength = (1*60) * 60 { a minute set the timeoutscript = "my handler" on handler go "start" clear globals cursor 432 end to make the timeoutscript do nothing set it to empty. ------------------------- RESEDIT: is a programme for altering resources, allowing you to embed fonts, cursors and X - objects into Director movies and projectors. Some important notes, Director won't recognise any I.D. number lower than 400 so any resource you choose to utillise will need to have all id numbers upped to ones higher than 400, also any e4mbeded resources will still have to be called by a handler. Resedit describes its resources in four letter charictors as in FOND and NFNT the only exception being sound spelt as SND The underlined is a space and must be included if sounds are to work. Each font or sound will have an I.D. number (16497 for exsample) which you will also need to copy. In Resedit :- Create a new file in resedit. Use command K to create a new resource. Find "CURS" in the resource list. Click O.K. Create cursor and mask with the graphics tools. Remember to mark the hotspot. Close the curs edit window. Selct the curs icon and press command I - info. Change the I.D. number to 400 or above. Save the file. Open director movie ( it can't be open at the same time ). Resedit will ask you if you want to add a resource fork - say yes. Paste in the cursor resource. Save and close. Open in Director and hey presto - cursor. ( Further reading Resedit Complete ) In Director 4 any resources added will appear in the projector. In Director 5 the resources must be assed to the finnal projector. ------------------------- LINGO Movies in a Window - MIAW's © on beginMyWindow -- We need to able to talk to the movie in a window -- so it has to be a global variable to stay in memory. global myWindow -- Check to see wether one exists and get rid of it if it does -- (ie after a lingo error). When you create a miaw or xobject -- it creates an 'object' in RAM - objectP tests to see wether the -- object named in brackets exists. if objectp(myWindow) then forget myWindow end if set HozOrigin to 30 set VertOrigin to 48 -- Create a rect variable to hold the four coodinates of the miaw. set myWindowRect to rect(HozOrigin, VertOrigin,¬ HozOrigin + 512, VertOrigin + 151) -- Give the miaw's window a name, the one visible in the titlebar. set myWindow to window "Window's Name" -- Each miaw has a property called 'the rect' which tells the miaw where -- to appear. Set this property equal to our myWindowRect variable. set the rect of myWindow to myWindowRect -- Each miaw has a property called 'the fileName' which tells the miaw -- which file on disk to use. It must be the exact name of the file, -- as it's a string. set the fileName of myWindow to "Window.dir" -- Each miaw has a property called 'the titleVisible' which controls wether you -- can see the title bar. TRUE is visible. set the titleVisible of myWindow to FALSE -- Each miaw has a property called 'the windowType' which is an integer calling -- one the mac's set type of windows. set the windowtype of myWindow = 4 -- Finally open the window open mywindow end beginMyWindow on finishMyWindow global myWindow if objectp(myWindow) then -- The keyword 'forget' removes the object from ram and screen, -- 'close' only hides it on the screen, leaving it in ram. -- 'open' will reopen it if it's hidden. forget myWindow -- You can hide the miaw with 'the visible' property but the miaw -- will still respond to any mouse / roll-over conditions you have -- created. If the miaw is closed either with the 'close' keyword or -- clicking it's close box then the object is still in ram and can -- have any of it's global variables set. end if end on stopMovie finishMyWindow end Further keywords and notes:- Both these phrases are equal:- set the stagecolor of window "Name" to 215 or global myWindow set the stagecolor of myWindow to 215 'the drawRect' property tells you the area of the stage (starting at 0, 0,), ie the stage size. 'the rect' property tells you where the rect of where the stage is currently on the screen. 'the sourceRect' tells you the rect set in the miaws movie by it's prefrences, regardless of any lingo changes. moveToFront window "Name" moveToBack window "Name" - NOTE: The window will go behind the stage. 'tell' - Keyword to get a miaw to respond to an event tell window "Name" to go frame 5 tell the stage to go frame 5 'the windowList' returns a list of all currently open miaws (in ram). You can use the 'getat' keyword or an integer instead of the "Name" string in window commands, window 2 is the second item in the windowList. 'the modal' property if set to FALSE will stop anything but the miaw responding to events outside of the miaw window (like dialog boxes), watch out for tell statements from the stage - there seems to be a conflict! Window types:- 0 - Moveable, sizeable window without zoom box 1 - Alert box or modal dialog box 2 - Plain box, no title bar 3 - Plain box with shadow, no title bar 4 - Moveable window without size box on the Mac or max / min boxes in Windows 5 - Moveable modal gialog box 8 - Standard document window 12 - Zoomable, nonresizable window 16 - Rounded corner window 49 - Floating palette --Script for screen saver. Produce a ball which randomly moves about the screen changing --colour when striking the mouse.( Note in this instance there is not even a frame script) global bounce, slide,flag on startmovie puppetsprite(2),true set flag=1 set the loch of sprite 2 to 320 set the locv of sprite 2 to -30 set bounce to random(5) set slide to random(10)-5 end on idle cursor [4,5] put the loch of sprite(2) into XC put the locv of sprite(2) into YC put the mouseH into X put the mouseV into Y Set D to power((X-XC),2) + power((Y-YC),2) if D <= power(40,2) and D >= power(0,2) then set the forecolor of sprite(2) = the forecolor of sprite(2) +5 if the mousev >the locv of sprite(2) then set bounce to -(random(5)) if the mousev <the locv of sprite(2) then set bounce to random(5) if the mouseh >the loch of sprite(2) then set slide to -(random(5)) if the mouseh <the loch of sprite(2) then set slide to random(5) end if set the loch of sprite(2)=the loch of sprite(2) + (slide) set the locv of sprite(2)=the locv of sprite(2) + (bounce) if the loch of sprite 2<40 then set slide to random(5) if the locv of sprite 2<40 then set bounce to random(5) if the loch of sprite 2>600 then set slide to -(random(5)) if the locv of sprite 2>440 then set bounce to -(random(5)) updatestage go the frame end on stopmovie --cursor -1 end ---------------------------------------- --Lists the card game list note this is not complete as it does not take into account ace's --may be high or low or any other of the oddities of 21 global packlist,suits, player1, score1 on startmovie set suits = ["H","S","D","C"] set packlist = [] set player1 = [] dealpack put "" into field "hand1" put "" into field "score1" end on dealpack repeat with i = 1 to 4 repeat with j = 1 to 13 addat packlist, getat(suits,i) & j end repeat end repeat put packlist into field "packlist" put "" into field "hand1" put "" into field "score1" end on dealhand if count(packlist) < 52 then dealpack repeat with i = 1 to 2 put count(packlist) into total put random(total) into choice put getat(packlist, choice) into card setat player1, i, card put getat(player1, i)&"," after field "hand1" deleteat packlist, choice put packlist into field "packlist" end repeat repeat with i = 1 to the number of items in field "hand1"-1 set score = score + value(char 2 to the number of chars in item i ¬ of field "hand1" of item i of field "hand1") end repeat if score > 21 then put "BUST" into field "score1" else if score = 21 then put "HUGE WIN" into field "score1" else put score into field "score1" end if end if set score1 = score end on dealcard put count(packlist) into total put random(total) into choice put getat(packlist, choice) into card setat player1, count(player1)+1, card put getat(player1, count(player1))&"," after field "hand1" deleteat packlist, choice put packlist into field "packlist" repeat with i = 1 to the number of items in field "hand1" -1 set score = score + value(char 2 to the number of chars in item i ¬ of field "hand1" of item i of field "hand1") end repeat if score > 21 then put "BUST"&&score into field "score1" else if score = 21 then put "HUGE WIN"&&score into field "score1" else put score into field "score1" end if end if set score1 = score end on stopmovie set packlist=[] put "" into field "packlist" end -- LISTS, lists need to be made a global if they're to -- be refered to during the movie -- set mylist = [] -- sets up an empty list or clears an exsisting list -- count(listName) -- returns the number of entries in the list -- getAt(listName, listPosition) -- gets a value from a specific place in a list -- settAt listNname, listPosition, listValue or "string" -- sets a value in a specific place in the list -- it will replace an earlier value if one exists -- or create blank 'earlier' places if needed -- addAt listname, listPosition, listValue or "string" -- sets a value in a specific place in the list but... -- it will make a duplicate entry if an earlier value exists! -- and also creates blank 'earlier' places if needed -- deleteAt listname, listPosition -- deletes a entry in a specific place in the list ------------------------------------------ --A simple puzzle script on startmovie repeat with i = 4 to 33 set the puppet of sprite i to false set the visible of sprite i to true end repeat cursor [20,21] end on checkpieces repeat with i = 18 to 33 if sprite i within (i - 15) and the mouseup then set the visible of sprite (i - 15) to false set the visible of sprite i to false else nothing end if end repeat end |
|||||