From c1a62ba1459cf849b5ee965aa461e10695bb0b01 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Thu, 18 Feb 2021 12:32:53 -0500 Subject: Started adding event where Claus joins the party --- res/maps/map2.tmx | 14 ++++++++++- res/scripts/map2.lua | 26 ++++++++++++++++++++ res/sprites/claus.png | Bin 0 -> 9024 bytes res/sprites/claus_anim.txt | 42 +++++++++++++++++++++++++++++++ res/sprites/claus_frames.txt | 57 +++++++++++++++++++++++++++++++++++++++++++ src/script_system.cpp | 7 ++++-- src/transform_system.cpp | 9 +++++++ src/transform_system.h | 2 ++ 8 files changed, 154 insertions(+), 3 deletions(-) create mode 100644 res/sprites/claus.png create mode 100644 res/sprites/claus_anim.txt create mode 100644 res/sprites/claus_frames.txt diff --git a/res/maps/map2.tmx b/res/maps/map2.tmx index 1ea8c00..19d3727 100644 --- a/res/maps/map2.tmx +++ b/res/maps/map2.tmx @@ -1,5 +1,5 @@ - + @@ -676,6 +676,18 @@ + + + + + + + + + + + + diff --git a/res/scripts/map2.lua b/res/scripts/map2.lua index 295a0c1..3c3a5d9 100644 --- a/res/scripts/map2.lua +++ b/res/scripts/map2.lua @@ -24,6 +24,32 @@ function map2.mailbox1() HideCutsceneBars() end +function map2.join_claus() + StartCutscene() + SetAnimation("join_claus", "talk") + DisplayMessage("* Say, Lucas. Whatcha up to?\n\f* It looks so fun! Let me join you!", "Claus", SpeakerType.MAN) + ShowChoice("Yes", "No") + WaitForEndOfMessage() + + if GetChoiceSelection() == 0 then + DisplayMessage("* Yes!\n\f* Okay, then I'll be at the very end!\n* Thanks!", "Claus", SpeakerType.MAN) + WaitForEndOfMessage() + + local clausId = getSpriteByAlias("join_claus") + character():addSpriteToParty(getPlayerSprite(), clausId) + transform():undoCollision(clausId) + + local clausSprite = getSprite(clausId) + clausSprite.persistent = true + else + DisplayMessage("* You won't let me join in?\nWhy not? Why not?\n\f* Why won't you let me join in?", "Claus", SpeakerType.MAN) + WaitForEndOfMessage() + end + + SetAnimation("join_claus", "still") + HideCutsceneBars() +end + function map2.mailbox_lightning() StartCutscene() DisplayMessage("* The mailbox lid is open...\n* Peek inside?", "", SpeakerType.NONE) diff --git a/res/sprites/claus.png b/res/sprites/claus.png new file mode 100644 index 0000000..3e85a01 Binary files /dev/null and b/res/sprites/claus.png differ diff --git a/res/sprites/claus_anim.txt b/res/sprites/claus_anim.txt new file mode 100644 index 0000000..79cb64b --- /dev/null +++ b/res/sprites/claus_anim.txt @@ -0,0 +1,42 @@ +../res/sprites/claus.png +../res/sprites/claus_frames.txt +still[down]: 0 +still[down_left]: 1 +still[left]: 2 +still[up_left]: 3 +still[up]: 4 +still[up_right]: 5 +still[right]: 6 +still[down_right]: 7 +walk[down]: 8,0,16,0 +walk[down_left]: 9,1,17,1 +walk[left]: 10,2,18,2 +walk[up_left]: 11,3,19,3 +walk[up]: 12,4,20,4 +walk[up_right]: 13,5,21,5 +walk[right]: 14,6,22,6 +walk[down_right]: 15,7,23,7 +crouch[down]: 0 +crouch[down_left]: 1 +crouch[left]: 2 +crouch[up_left]: 3 +crouch[up]: 4 +crouch[up_right]: 5 +crouch[right]: 6 +crouch[down_right]: 7 +run[down]: 8,0,16,0 +run[down_left]: 9,1,17,1 +run[left]: 10,2,18,2 +run[up_left]: 11,3,19,3 +run[up]: 12,4,20,4 +run[up_right]: 13,5,21,5 +run[right]: 14,6,22,6 +run[down_right]: 15,7,23,7 +talk[down]: 24,0 +talk[down_left]: 25,1 +talk[left]: 26,2 +talk[up_left]: 27,3 +talk[up]: 28,4 +talk[up_right]: 29,5 +talk[right]: 30,6 +talk[down_right]: 31,7 \ No newline at end of file diff --git a/res/sprites/claus_frames.txt b/res/sprites/claus_frames.txt new file mode 100644 index 0000000..272ddc9 --- /dev/null +++ b/res/sprites/claus_frames.txt @@ -0,0 +1,57 @@ +17,32 cell size +10 frames per row +53 frames + +16,32,8,32 +16,32,8,32 +16,32,8,32 +16,32,8,32 +16,32,9,32 +16,32,9,32 +16,32,9,32 +16,32,9,32 +16,24,8,24 +16,24,8,24 +16,24,8,24 +16,24,8,24 +16,24,9,24 +16,24,9,24 +16,24,9,24 +16,24,9,24 +17,24,9,24 +16,24,8,24 +16,24,8,24 +16,24,8,24 +17,24,9,24 +16,24,9,24 +16,24,9,24 +16,24,9,24 +16,32,8,32 +16,32,8,32 +16,32,8,32 +16,32,8,32 +17,32,9,32 +16,32,9,32 +16,32,9,32 +16,32,9,32 +16,32,8,32 +16,24,8,24 +17,32,9,32 +17,24,9,24 +16,24,8,24 +16,24,8,24 +16,24,8,24 +16,24,8,24 +16,24,8,24 +16,24,8,24 +16,24,8,24 +16,24,8,24 +16,24,9,24 +16,24,9,24 +16,24,9,24 +16,24,9,24 +16,24,9,24 +16,24,9,24 +16,24,9,24 +16,24,9,24 +16,24,9,24 diff --git a/src/script_system.cpp b/src/script_system.cpp index 090bf46..d4ee0ce 100644 --- a/src/script_system.cpp +++ b/src/script_system.cpp @@ -35,7 +35,8 @@ ScriptSystem::ScriptSystem(Game& game) : game_(game) { "animFinished", &Sprite::animFinished, "getCurrentFrame", [] (const Sprite& sprite) -> const SpriteFrame& { return sprite.frames[sprite.animations[sprite.animationId].frameIndices[sprite.animationFrame]]; - }); + }, + "persistent", &Sprite::persistent); engine_.new_usertype( "message", @@ -54,6 +55,7 @@ ScriptSystem::ScriptSystem(Game& game) : game_(game) { engine_.new_usertype( "character", + "addSpriteToParty", &CharacterSystem::addSpriteToParty, "transplantParty", &CharacterSystem::transplantParty, "startRunning", &CharacterSystem::startRunning, "halt", &CharacterSystem::halt); @@ -62,7 +64,8 @@ ScriptSystem::ScriptSystem(Game& game) : game_(game) { "transform", "initSprite", [] (TransformSystem& transform, int spriteId, int x, int y, SpriteLayer layer) { transform.initSprite(spriteId, vec2i{x, y}, layer); - }); + }, + "undoCollision", &TransformSystem::undoCollision); engine_.new_usertype( "effect", diff --git a/src/transform_system.cpp b/src/transform_system.cpp index 144477b..1d4a9f3 100644 --- a/src/transform_system.cpp +++ b/src/transform_system.cpp @@ -19,6 +19,15 @@ void TransformSystem::setUpCollision(int spriteId, vec2i offset, vec2i size, boo addCollidable(spriteId); } +void TransformSystem::undoCollision(int spriteId) { + Sprite& sprite = game_.getSprite(spriteId); + + sprite.collidable = false; + sprite.solid = false; + + removeCollidable(spriteId); +} + void TransformSystem::moveSprite(int spriteId, vec2i newLoc) { Sprite& sprite = game_.getSprite(spriteId); if (sprite.collidable) { diff --git a/src/transform_system.h b/src/transform_system.h index 4ee481e..d894b30 100644 --- a/src/transform_system.h +++ b/src/transform_system.h @@ -35,6 +35,8 @@ public: void setUpCollision(int spriteId, vec2i offset, vec2i size, bool solid); + void undoCollision(int spriteId); + void moveSprite(int spriteId, vec2i newLoc); auto getSpritesByY(SpriteLayer layer) const { -- cgit 1.4.1