Initial commit
This commit is contained in:
143
engines/director/lingo/tests/factory.lingo
Normal file
143
engines/director/lingo/tests/factory.lingo
Normal file
@@ -0,0 +1,143 @@
|
||||
AimGun2
|
||||
|
||||
aim1(mDispose)
|
||||
|
||||
set notAMethod = 0
|
||||
scummvmAssertError aim2(notAMethod) -- should error
|
||||
aim2("notAMethod") -- should run fallback handler
|
||||
|
||||
-- method call syntax without parens
|
||||
GrammarFactory mSetStatusToArg "foo"
|
||||
scummvmAssertEqual status "foo"
|
||||
GrammarFactory mSetStatusToArg2 "foo", "bar"
|
||||
scummvmAssertEqual status "bar"
|
||||
|
||||
-- method call syntax with parens and a comma
|
||||
GrammarFactory(mSetStatusToArg, "foo")
|
||||
scummvmAssertEqual status "foo"
|
||||
GrammarFactory(mSetStatusToArg2, "foo", "bar")
|
||||
scummvmAssertEqual status "bar"
|
||||
scummvmAssertEqual GrammarFactory(mReturnArg, "foo") "foo"
|
||||
scummvmAssertEqual GrammarFactory(mReturnArg2, "foo", "bar") "bar"
|
||||
|
||||
-- method call syntax with parens and no comma
|
||||
GrammarFactory(mSetStatusToArg "foo")
|
||||
scummvmAssertEqual status "foo"
|
||||
GrammarFactory(mSetStatusToArg2 "foo", "bar")
|
||||
scummvmAssertEqual status "bar"
|
||||
scummvmAssertEqual GrammarFactory(mReturnArg "foo") "foo"
|
||||
scummvmAssertEqual GrammarFactory(mReturnArg2 "foo", "bar") "bar"
|
||||
|
||||
--
|
||||
macro AimGun2
|
||||
global aim1
|
||||
set aim1 = aim2(mNew)
|
||||
--
|
||||
factory aim2
|
||||
method mNew
|
||||
dontpassevent
|
||||
global aim1
|
||||
when mousedown then aim1(fire)
|
||||
when keydown then aim1(mExit)
|
||||
set the locv of sprite 24 to 540
|
||||
method mMove x, y
|
||||
global aimCopy
|
||||
set the locH of sprite 15 to x
|
||||
set the locV of sprite 15 to y-250
|
||||
set aimCopy = me
|
||||
method mAtFrame
|
||||
dontpassevent
|
||||
me(mMove, the mouseH, the mouseV)
|
||||
method fire
|
||||
global fire1, targeth, targetv
|
||||
set fire1 = fire2(mNew)
|
||||
set the perframehook to fire1
|
||||
me(mDispose)
|
||||
method mExit
|
||||
set the perframehook to false
|
||||
postfire
|
||||
me(mDispose)
|
||||
method mDispose
|
||||
global aim1
|
||||
set aim1 = 1
|
||||
when keydown then nothing
|
||||
--
|
||||
factory fire2
|
||||
method mNew
|
||||
dontpassevent
|
||||
when mousedown then nothing
|
||||
set the castnum of sprite 14 to f15
|
||||
method mAtFrame
|
||||
Global StartH, StartV, targetv, stepH, stepV, bcast
|
||||
dontpassevent
|
||||
set the castnum of sprite 14 to bcast
|
||||
set the LocV of sprite 14 to (startV-stepV)
|
||||
if sprite 14 intersects 10 and (startV-6) <= targetV then
|
||||
set the castnum of sprite 14 to f16
|
||||
set the perframehook to false
|
||||
me(hit)
|
||||
exit
|
||||
end if
|
||||
if startV < targetV or bcast>g17 then
|
||||
set the perframehook to false
|
||||
set the locV of sprite 14 to 340
|
||||
aimgun2
|
||||
exit
|
||||
end if
|
||||
set startV to (startV-stepV)
|
||||
set bcast = bcast + 1
|
||||
method hit
|
||||
global KillLoc
|
||||
set killloc to the loch of sprite 3
|
||||
go "Death"
|
||||
set the locV of sprite 14 to 400
|
||||
aimgun2
|
||||
if factory(killloc) then put "boo"
|
||||
method mDispose
|
||||
global fire1
|
||||
set fire1 = 0
|
||||
Method mNew2 theSprite, startCastRight, endCastRight, startCastLeft, endCastLeft
|
||||
instance startDrawLeft, endDrawLeft, startDrawRight, endDrawRight, multiDrawP
|
||||
|
||||
if startCastLeft and endCastLeft then set multiDrawP to TRUE
|
||||
set startDrawLeft to startCastRight
|
||||
set endDrawLeft to endCastRight
|
||||
set startDrawRight to startCastLeft
|
||||
set endDrawRight to endCastLeft
|
||||
|
||||
me(mInitBirdPart, theSprite, startCastRight)
|
||||
Method mAtFrame2 frame, subFrame
|
||||
global gMouseH, gMouseV
|
||||
set gMouseH = mouseH()
|
||||
set gMouseV = mouseV()
|
||||
|
||||
-- Exit when "Done" button, which resides upon score channel 6.
|
||||
if (the clickOn = 6) then exit
|
||||
|
||||
put the mouseDown into mouseClick
|
||||
Body(mEveryFrame, mouseClick)
|
||||
RightWing(mEveryFrame, mouseClick)
|
||||
LeftWing(mEveryFrame, mouseClick)
|
||||
|
||||
|
||||
--
|
||||
macro KillIt2
|
||||
global KillLoc
|
||||
set the locH of sprite 3 to KillLoc
|
||||
|
||||
on aim2 test
|
||||
put "fallback worked!"
|
||||
end
|
||||
|
||||
--
|
||||
factory GrammarFactory
|
||||
method mSetStatusToArg arg
|
||||
global status
|
||||
set status = arg
|
||||
method mSetStatusToArg2 arg1, arg2
|
||||
global status
|
||||
set status = arg2
|
||||
method mReturnArg arg
|
||||
return arg
|
||||
method mReturnArg2 arg1, arg2
|
||||
return arg2
|
||||
Reference in New Issue
Block a user