summary refs log tree commit diff stats
path: root/res/scripts/common.lua
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2021-02-13 20:50:21 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2021-02-13 20:50:21 -0500
commit470b1d43fb6f8e17624ee90f87270de5bd6ff77e (patch)
tree966f1e18d496f12c3273684be299573e4bf443ec /res/scripts/common.lua
parented933607765a6e010689aaaf85184053ff6e8a2b (diff)
downloadtanetane-470b1d43fb6f8e17624ee90f87270de5bd6ff77e.tar.gz
tanetane-470b1d43fb6f8e17624ee90f87270de5bd6ff77e.tar.bz2
tanetane-470b1d43fb6f8e17624ee90f87270de5bd6ff77e.zip
Added lightning sprite to mailbox event
Sprites can be destroyed now, which really just means that their index is removed from the list of active sprites. The actual memory is not freed until all sprites are deleted on map change.

Sprite layers are introduced. All sprites by default are on layer 0 (Normal) which renders them in between the lower and upper map layers. There is also a layer 1 (Above) that renders above the upper map layer, and the sprite for the lightning strike uses this layer in order to not be hidden by the trees.

Fixed a bug where waiting for the end of a non-looping animation would trip the flag immediately upon the final frame activating, instead of waiting the length of the last frame.
Diffstat (limited to 'res/scripts/common.lua')
-rw-r--r--res/scripts/common.lua24
1 files changed, 24 insertions, 0 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
28SpriteLayer = {
29 NORMAL = 0,
30 ABOVE = 1
31}
32
28function StartCutscene() 33function 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
60end 65end
61 66
67function GetPosition(spriteName)
68 local spriteId = getSpriteByAlias(spriteName)
69 local sprite = getSprite(spriteId)
70 return sprite.loc
71end
72
62function SetDirection(spriteName, dir) 73function 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
139end 150end
151
152function 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)
158end
159
160function DestroyNamedSprite(alias)
161 local spriteId = getSpriteByAlias(alias)
162 destroySprite(spriteId)
163end