diff options
Diffstat (limited to 'res/scripts')
-rw-r--r-- | res/scripts/common.lua | 24 | ||||
-rw-r--r-- | res/scripts/map2.lua | 9 |
2 files changed, 32 insertions, 1 deletions
diff --git a/res/scripts/common.lua b/res/scripts/common.lua index 3db1b26..04f6c5a 100644 --- a/res/scripts/common.lua +++ b/res/scripts/common.lua | |||
@@ -25,6 +25,11 @@ CharacterState = { | |||
25 | RUNNING = 3 | 25 | RUNNING = 3 |
26 | } | 26 | } |
27 | 27 | ||
28 | SpriteLayer = { | ||
29 | NORMAL = 0, | ||
30 | ABOVE = 1 | ||
31 | } | ||
32 | |||
28 | function StartCutscene() | 33 | function StartCutscene() |
29 | local playerId = getPlayerSprite() | 34 | local playerId = getPlayerSprite() |
30 | local playerSprite = getSprite(playerId) | 35 | local playerSprite = getSprite(playerId) |
@@ -59,6 +64,12 @@ function HideCutsceneBars() | |||
59 | playerSprite.controllable = true | 64 | playerSprite.controllable = true |
60 | end | 65 | end |
61 | 66 | ||
67 | function GetPosition(spriteName) | ||
68 | local spriteId = getSpriteByAlias(spriteName) | ||
69 | local sprite = getSprite(spriteId) | ||
70 | return sprite.loc | ||
71 | end | ||
72 | |||
62 | function SetDirection(spriteName, dir) | 73 | function SetDirection(spriteName, dir) |
63 | local spriteId = getSpriteByAlias(spriteName) | 74 | local spriteId = getSpriteByAlias(spriteName) |
64 | animation():setSpriteDirection(spriteId, dir) | 75 | animation():setSpriteDirection(spriteId, dir) |
@@ -137,3 +148,16 @@ function ChangeMap(map, warp) | |||
137 | RemoveFadeout(150) | 148 | RemoveFadeout(150) |
138 | newPlayerSprite.controllable = true | 149 | newPlayerSprite.controllable = true |
139 | end | 150 | end |
151 | |||
152 | function CreateAnimatedSpriteAtPosition(alias, character, x, y, animName, direction, layer) | ||
153 | local spriteId = emplaceSprite(alias) | ||
154 | transform():initSprite(spriteId, x, y, layer) | ||
155 | animation():initSprite(spriteId, "../res/sprites/" .. character .. "_anim.txt") | ||
156 | animation():setSpriteDirection(spriteId, direction) | ||
157 | animation():setSpriteAnimation(spriteId, animName) | ||
158 | end | ||
159 | |||
160 | function DestroyNamedSprite(alias) | ||
161 | local spriteId = getSpriteByAlias(alias) | ||
162 | destroySprite(spriteId) | ||
163 | end | ||
diff --git a/res/scripts/map2.lua b/res/scripts/map2.lua index 3bc9eff..1ef1235 100644 --- a/res/scripts/map2.lua +++ b/res/scripts/map2.lua | |||
@@ -29,8 +29,15 @@ function map2.mailbox_lightning() | |||
29 | DisplayMessage("* ...?", "", SpeakerType.NONE) | 29 | DisplayMessage("* ...?", "", SpeakerType.NONE) |
30 | WaitForEndOfMessage() | 30 | WaitForEndOfMessage() |
31 | 31 | ||
32 | local lucasPos = GetPosition("lucas") | ||
33 | CreateAnimatedSpriteAtPosition("lightning_from_mailbox", "lightning", lucasPos:x() + 56, lucasPos:y() - 72, "strike", Direction.DOWN_LEFT, SpriteLayer.ABOVE) | ||
34 | |||
32 | SetDirection("lucas", Direction.DOWN) | 35 | SetDirection("lucas", Direction.DOWN) |
33 | SetAnimation("lucas", "electrocute!") | 36 | SetAnimation("lucas", "lightning_electrocute!") |
37 | WaitForAnimation("lucas") | ||
38 | |||
39 | DestroyNamedSprite("lightning_from_mailbox") | ||
40 | SetAnimation("lucas", "lightning_collapse!") | ||
34 | WaitForAnimation("lucas") | 41 | WaitForAnimation("lucas") |
35 | 42 | ||
36 | DisplayMessage("* It was lightning.\n\fAh.", "", SpeakerType.NONE) | 43 | DisplayMessage("* It was lightning.\n\fAh.", "", SpeakerType.NONE) |