diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-13 20:50:21 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-13 20:50:21 -0500 |
commit | 470b1d43fb6f8e17624ee90f87270de5bd6ff77e (patch) | |
tree | 966f1e18d496f12c3273684be299573e4bf443ec /res | |
parent | ed933607765a6e010689aaaf85184053ff6e8a2b (diff) | |
download | tanetane-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')
-rw-r--r-- | res/maps/map2.tmx | 5 | ||||
-rw-r--r-- | res/scripts/common.lua | 24 | ||||
-rw-r--r-- | res/scripts/map2.lua | 9 | ||||
-rw-r--r-- | res/sprites/lightning.png | bin | 0 -> 11405 bytes | |||
-rw-r--r-- | res/sprites/lightning_anim.txt | 3 | ||||
-rw-r--r-- | res/sprites/lightning_frames.txt | 14 | ||||
-rw-r--r-- | res/sprites/lucas_anim.txt | 3 |
7 files changed, 55 insertions, 3 deletions
diff --git a/res/maps/map2.tmx b/res/maps/map2.tmx index 6316ef5..f6d6dd2 100644 --- a/res/maps/map2.tmx +++ b/res/maps/map2.tmx | |||
@@ -1,5 +1,5 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="64" height="64" tilewidth="16" tileheight="16" infinite="0" nextlayerid="3" nextobjectid="6"> | 2 | <map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="64" height="64" tilewidth="16" tileheight="16" infinite="0" nextlayerid="3" nextobjectid="7"> |
3 | <tileset firstgid="1" name="fromRom" tilewidth="16" tileheight="16" tilecount="180" columns="10"> | 3 | <tileset firstgid="1" name="fromRom" tilewidth="16" tileheight="16" tilecount="180" columns="10"> |
4 | <image source="map2_tiles.png" width="160" height="288"/> | 4 | <image source="map2_tiles.png" width="160" height="288"/> |
5 | <tile id="61"> | 5 | <tile id="61"> |
@@ -657,6 +657,9 @@ | |||
657 | </properties> | 657 | </properties> |
658 | <point/> | 658 | <point/> |
659 | </object> | 659 | </object> |
660 | <object id="6" name="debugWarp_mailboxes" type="warp" x="598.667" y="420.667"> | ||
661 | <point/> | ||
662 | </object> | ||
660 | </objectgroup> | 663 | </objectgroup> |
661 | <layer id="1" name="Layer 0" width="64" height="64"> | 664 | <layer id="1" name="Layer 0" width="64" height="64"> |
662 | <data encoding="csv"> | 665 | <data encoding="csv"> |
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) |
diff --git a/res/sprites/lightning.png b/res/sprites/lightning.png new file mode 100644 index 0000000..c456338 --- /dev/null +++ b/res/sprites/lightning.png | |||
Binary files differ | |||
diff --git a/res/sprites/lightning_anim.txt b/res/sprites/lightning_anim.txt new file mode 100644 index 0000000..bafb68d --- /dev/null +++ b/res/sprites/lightning_anim.txt | |||
@@ -0,0 +1,3 @@ | |||
1 | ../res/sprites/lightning.png | ||
2 | ../res/sprites/lightning_frames.txt | ||
3 | strike[down_left]: 0,1,3,2 \ No newline at end of file | ||
diff --git a/res/sprites/lightning_frames.txt b/res/sprites/lightning_frames.txt new file mode 100644 index 0000000..4a8fee5 --- /dev/null +++ b/res/sprites/lightning_frames.txt | |||
@@ -0,0 +1,14 @@ | |||
1 | 160,128 cell size | ||
2 | 10 frames per row | ||
3 | 10 frames | ||
4 | |||
5 | 112,128,60,56 | ||
6 | 128,128,72,64 | ||
7 | 116,128,64,64 | ||
8 | 116,128,64,64 | ||
9 | 88,96,40,96 | ||
10 | 88,96,40,96 | ||
11 | 80,96,40,96 | ||
12 | 160,32,123,83 | ||
13 | 160,32,123,91 | ||
14 | 160,32,123,91 | ||
diff --git a/res/sprites/lucas_anim.txt b/res/sprites/lucas_anim.txt index 12a373e..d03e213 100644 --- a/res/sprites/lucas_anim.txt +++ b/res/sprites/lucas_anim.txt | |||
@@ -32,4 +32,5 @@ run[up]: 71,79,87,95 | |||
32 | run[up_right]: 72,80,88,96 | 32 | run[up_right]: 72,80,88,96 |
33 | run[right]: 73,81,89,97 | 33 | run[right]: 73,81,89,97 |
34 | run[down_right]: 74,82,90,98 | 34 | run[down_right]: 74,82,90,98 |
35 | electrocute![down]: 116,117,118,116,117,118,116,117,118,119,120,121,122 \ No newline at end of file | 35 | lightning_electrocute![down]: 116,117,118,116,117,118,116,117,118,116 |
36 | lightning_collapse![down]: 119,120,121,122 \ No newline at end of file | ||