diff options
-rw-r--r-- | res/scripts/common.lua | 18 | ||||
-rw-r--r-- | res/scripts/map2.lua | 27 | ||||
-rw-r--r-- | res/sprites/expression.png | bin | 0 -> 216 bytes | |||
-rw-r--r-- | res/sprites/expression_anim.txt | 3 | ||||
-rw-r--r-- | res/sprites/expression_frames.txt | 5 | ||||
-rw-r--r-- | src/script_system.cpp | 10 |
6 files changed, 62 insertions, 1 deletions
diff --git a/res/scripts/common.lua b/res/scripts/common.lua index f88c4c1..8a9445b 100644 --- a/res/scripts/common.lua +++ b/res/scripts/common.lua | |||
@@ -207,3 +207,21 @@ function DestroyNamedSprite(alias) | |||
207 | local spriteId = getSpriteByAlias(alias) | 207 | local spriteId = getSpriteByAlias(alias) |
208 | destroySprite(spriteId) | 208 | destroySprite(spriteId) |
209 | end | 209 | end |
210 | |||
211 | function AliasForSpriteExpression(spriteName) | ||
212 | return "expression (" .. spriteName .. ")" | ||
213 | end | ||
214 | |||
215 | function ShowExpression(spriteName, expression) | ||
216 | local spriteId = getSpriteByAlias(spriteName) | ||
217 | local sprite = getSprite(spriteId) | ||
218 | local animFrame = sprite:getCurrentFrame() | ||
219 | local x = sprite.loc:x() | ||
220 | local y = sprite.loc:y() - animFrame.center:y() | ||
221 | |||
222 | CreateAnimatedSpriteAtPosition(AliasForSpriteExpression(spriteName), "expression", x, y, expression, Direction.DOWN, SpriteLayer.ABOVE) | ||
223 | end | ||
224 | |||
225 | function RemoveExpression(spriteName) | ||
226 | DestroyNamedSprite(AliasForSpriteExpression(spriteName)) | ||
227 | end | ||
diff --git a/res/scripts/map2.lua b/res/scripts/map2.lua index c929e8d..295a0c1 100644 --- a/res/scripts/map2.lua +++ b/res/scripts/map2.lua | |||
@@ -74,12 +74,36 @@ function map2.approach_doria() | |||
74 | gamestate.approached_doria = true | 74 | gamestate.approached_doria = true |
75 | 75 | ||
76 | StartCutscene() | 76 | StartCutscene() |
77 | SetDirection("boney", Direction.LEFT) | ||
78 | SetAnimation("boney", "barking") | ||
79 | local barkingNoise = LoopSound("barking_at_hallucination.wav") | ||
80 | Delay(200) | ||
81 | |||
82 | ShowExpression("lucas", "surprise") | ||
83 | SetDirection("lucas", Direction.LEFT) | ||
84 | Delay(100) | ||
85 | |||
86 | ShowExpression("kuma", "surprise") | ||
87 | ShowExpression("duster", "surprise") | ||
88 | SetDirection("kuma", Direction.LEFT) | ||
89 | SetDirection("duster", Direction.LEFT) | ||
90 | Delay(1000) | ||
91 | |||
77 | PanToSprite("doria", 2000) | 92 | PanToSprite("doria", 2000) |
93 | Delay(500) | ||
94 | |||
95 | RemoveExpression("lucas") | ||
96 | RemoveExpression("kuma") | ||
97 | RemoveExpression("duster") | ||
78 | WaitForPan() | 98 | WaitForPan() |
79 | 99 | ||
80 | SetDirection("doria", Direction.DOWN_RIGHT) | 100 | SetDirection("doria", Direction.DOWN_RIGHT) |
81 | SetAnimation("doria", "talk") | 101 | SetAnimation("doria", "talk") |
102 | ShowExpression("doria", "surprise") | ||
82 | DisplayMessage("* Oh my!\n\f* Is that our little Kumatora I spy? `", "Doria", SpeakerType.MAN) | 103 | DisplayMessage("* Oh my!\n\f* Is that our little Kumatora I spy? `", "Doria", SpeakerType.MAN) |
104 | Delay(1000) | ||
105 | |||
106 | RemoveExpression("doria") | ||
83 | WaitForEndOfMessage() | 107 | WaitForEndOfMessage() |
84 | 108 | ||
85 | SetAnimation("doria", "still") | 109 | SetAnimation("doria", "still") |
@@ -89,6 +113,9 @@ function map2.approach_doria() | |||
89 | DisplayMessage("* Doria...?\n\f* What the hell... You're still alive?", "Kumatora", SpeakerType.WOMAN) | 113 | DisplayMessage("* Doria...?\n\f* What the hell... You're still alive?", "Kumatora", SpeakerType.WOMAN) |
90 | WaitForEndOfMessage() | 114 | WaitForEndOfMessage() |
91 | 115 | ||
116 | SetAnimation("boney", "crouch") | ||
117 | StopSound(barkingNoise) | ||
118 | PlaySound("boney_growl.wav") | ||
92 | SetAnimation("kuma", "still") | 119 | SetAnimation("kuma", "still") |
93 | Delay(1000) | 120 | Delay(1000) |
94 | 121 | ||
diff --git a/res/sprites/expression.png b/res/sprites/expression.png new file mode 100644 index 0000000..1cc2500 --- /dev/null +++ b/res/sprites/expression.png | |||
Binary files differ | |||
diff --git a/res/sprites/expression_anim.txt b/res/sprites/expression_anim.txt new file mode 100644 index 0000000..299f32c --- /dev/null +++ b/res/sprites/expression_anim.txt | |||
@@ -0,0 +1,3 @@ | |||
1 | ../res/sprites/expression.png | ||
2 | ../res/sprites/expression_frames.txt | ||
3 | surprise[down]: 0 \ No newline at end of file | ||
diff --git a/res/sprites/expression_frames.txt b/res/sprites/expression_frames.txt new file mode 100644 index 0000000..692cde2 --- /dev/null +++ b/res/sprites/expression_frames.txt | |||
@@ -0,0 +1,5 @@ | |||
1 | 16,16 cell size | ||
2 | 10 frames per row | ||
3 | 1 frames | ||
4 | |||
5 | 16,16,8,16 | ||
diff --git a/src/script_system.cpp b/src/script_system.cpp index 3ac04ac..8674f97 100644 --- a/src/script_system.cpp +++ b/src/script_system.cpp | |||
@@ -20,6 +20,11 @@ ScriptSystem::ScriptSystem(Game& game) : game_(game) { | |||
20 | "x", [] (const vec2i& v) { return v.x(); }, | 20 | "x", [] (const vec2i& v) { return v.x(); }, |
21 | "y", [] (const vec2i& v) { return v.y(); }); | 21 | "y", [] (const vec2i& v) { return v.y(); }); |
22 | 22 | ||
23 | engine_.new_usertype<SpriteFrame>( | ||
24 | "spriteframe", | ||
25 | "center", &SpriteFrame::center, | ||
26 | "size", &SpriteFrame::size); | ||
27 | |||
23 | engine_.new_usertype<Sprite>( | 28 | engine_.new_usertype<Sprite>( |
24 | "sprite", | 29 | "sprite", |
25 | "loc", &Sprite::loc, | 30 | "loc", &Sprite::loc, |
@@ -27,7 +32,10 @@ ScriptSystem::ScriptSystem(Game& game) : game_(game) { | |||
27 | "followers", &Sprite::followers, | 32 | "followers", &Sprite::followers, |
28 | "characterState", &Sprite::characterState, | 33 | "characterState", &Sprite::characterState, |
29 | "controllable", &Sprite::controllable, | 34 | "controllable", &Sprite::controllable, |
30 | "animFinished", &Sprite::animFinished); | 35 | "animFinished", &Sprite::animFinished, |
36 | "getCurrentFrame", [] (const Sprite& sprite) -> const SpriteFrame& { | ||
37 | return sprite.frames[sprite.animations[sprite.animationId].frameIndices[sprite.animationFrame]]; | ||
38 | }); | ||
31 | 39 | ||
32 | engine_.new_usertype<MessageSystem>( | 40 | engine_.new_usertype<MessageSystem>( |
33 | "message", | 41 | "message", |