diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-10 19:57:23 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-10 19:57:23 -0500 |
commit | 05ee221cd31a782b699cc6d62e0d275364cfd7cc (patch) | |
tree | 4ee6c769fd65ae38edc117f02e98455b43bfd677 | |
parent | 213203fbe3352e084c8875acfbf435a948824c08 (diff) | |
download | tanetane-05ee221cd31a782b699cc6d62e0d275364cfd7cc.tar.gz tanetane-05ee221cd31a782b699cc6d62e0d275364cfd7cc.tar.bz2 tanetane-05ee221cd31a782b699cc6d62e0d275364cfd7cc.zip |
Player is no longer controllable during map transitions
-rw-r--r-- | res/scripts/common.lua | 7 | ||||
-rw-r--r-- | src/game.cpp | 2 | ||||
-rw-r--r-- | src/main.cpp | 1 | ||||
-rw-r--r-- | src/script_system.cpp | 7 | ||||
-rw-r--r-- | src/sprite.h | 1 |
5 files changed, 12 insertions, 6 deletions
diff --git a/res/scripts/common.lua b/res/scripts/common.lua index 23c07cc..1841662 100644 --- a/res/scripts/common.lua +++ b/res/scripts/common.lua | |||
@@ -86,19 +86,22 @@ function SetPartyDirection(spriteId, direction) | |||
86 | end | 86 | end |
87 | 87 | ||
88 | function ChangeMap(map, warp) | 88 | function ChangeMap(map, warp) |
89 | local playerId = getControllableSprite() | 89 | local playerId = getPlayerSprite() |
90 | local playerSprite = getSprite(playerId) | 90 | local playerSprite = getSprite(playerId) |
91 | local direction = playerSprite.dir | 91 | local direction = playerSprite.dir |
92 | local oldState = playerSprite.characterState | 92 | local oldState = playerSprite.characterState |
93 | 93 | ||
94 | playerSprite.controllable = false | ||
94 | FadeToBlack(150) | 95 | FadeToBlack(150) |
95 | loadMap("../res/maps/" .. map .. ".tmx", warp, direction) | 96 | loadMap("../res/maps/" .. map .. ".tmx", warp, direction) |
96 | 97 | ||
97 | local newPlayerId = getControllableSprite() | 98 | local newPlayerId = getPlayerSprite() |
99 | local newPlayerSprite = getSprite(newPlayerId) | ||
98 | if oldState == CharacterState.RUNNING then | 100 | if oldState == CharacterState.RUNNING then |
99 | character():startRunning(newPlayerId) | 101 | character():startRunning(newPlayerId) |
100 | end | 102 | end |
101 | 103 | ||
102 | coroutine.yield() | 104 | coroutine.yield() |
103 | RemoveFadeout(150) | 105 | RemoveFadeout(150) |
106 | newPlayerSprite.controllable = true | ||
104 | end | 107 | end |
diff --git a/src/game.cpp b/src/game.cpp index 4d44a63..8b6ef8f 100644 --- a/src/game.cpp +++ b/src/game.cpp | |||
@@ -34,7 +34,7 @@ void Game::loadMap(std::string filename, std::string warpPoint, Direction dir) { | |||
34 | getSystem<TransformSystem>().setUpCollision(lucasSprite, {-8, -8}, {12, 8}, true); | 34 | getSystem<TransformSystem>().setUpCollision(lucasSprite, {-8, -8}, {12, 8}, true); |
35 | getSystem<AnimationSystem>().initSprite(lucasSprite, "../res/sprites/lucas_anim.txt"); | 35 | getSystem<AnimationSystem>().initSprite(lucasSprite, "../res/sprites/lucas_anim.txt"); |
36 | getSystem<AnimationSystem>().setSpriteDirection(lucasSprite, dir); | 36 | getSystem<AnimationSystem>().setSpriteDirection(lucasSprite, dir); |
37 | getSprite(lucasSprite).controllable = true; | 37 | getSprite(lucasSprite).player = true; |
38 | getSystem<CharacterSystem>().initSprite(lucasSprite); | 38 | getSystem<CharacterSystem>().initSprite(lucasSprite); |
39 | 39 | ||
40 | int kumaSprite = emplaceSprite("kuma"); | 40 | int kumaSprite = emplaceSprite("kuma"); |
diff --git a/src/main.cpp b/src/main.cpp index ddc8df2..387f7e3 100644 --- a/src/main.cpp +++ b/src/main.cpp | |||
@@ -23,6 +23,7 @@ void loop(Renderer& renderer) { | |||
23 | game.emplaceSystem<MessageSystem>(); | 23 | game.emplaceSystem<MessageSystem>(); |
24 | 24 | ||
25 | game.loadMap("../res/maps/map1.tmx", "spawn", Direction::down); | 25 | game.loadMap("../res/maps/map1.tmx", "spawn", Direction::down); |
26 | game.getSprite(game.getSpriteByAlias("lucas")).controllable = true; | ||
26 | 27 | ||
27 | renderer.render(game); | 28 | renderer.render(game); |
28 | 29 | ||
diff --git a/src/script_system.cpp b/src/script_system.cpp index e388c6e..8fd5028 100644 --- a/src/script_system.cpp +++ b/src/script_system.cpp | |||
@@ -15,7 +15,8 @@ ScriptSystem::ScriptSystem(Game& game) : game_(game) { | |||
15 | "sprite", | 15 | "sprite", |
16 | "dir", &Sprite::dir, | 16 | "dir", &Sprite::dir, |
17 | "followers", &Sprite::followers, | 17 | "followers", &Sprite::followers, |
18 | "characterState", &Sprite::characterState); | 18 | "characterState", &Sprite::characterState, |
19 | "controllable", &Sprite::controllable); | ||
19 | 20 | ||
20 | engine_.new_usertype<MessageSystem>( | 21 | engine_.new_usertype<MessageSystem>( |
21 | "message", | 22 | "message", |
@@ -69,11 +70,11 @@ ScriptSystem::ScriptSystem(Game& game) : game_(game) { | |||
69 | }); | 70 | }); |
70 | 71 | ||
71 | engine_.set_function( | 72 | engine_.set_function( |
72 | "getControllableSprite", | 73 | "getPlayerSprite", |
73 | [&] () -> int { | 74 | [&] () -> int { |
74 | for (int id : game_.getSprites()) { | 75 | for (int id : game_.getSprites()) { |
75 | Sprite& sprite = game_.getSprite(id); | 76 | Sprite& sprite = game_.getSprite(id); |
76 | if (sprite.controllable) { | 77 | if (sprite.player) { |
77 | return id; | 78 | return id; |
78 | } | 79 | } |
79 | } | 80 | } |
diff --git a/src/sprite.h b/src/sprite.h index 283fb65..6ef2f57 100644 --- a/src/sprite.h +++ b/src/sprite.h | |||
@@ -61,6 +61,7 @@ public: | |||
61 | 61 | ||
62 | // Input | 62 | // Input |
63 | bool controllable = false; | 63 | bool controllable = false; |
64 | bool player = false; | ||
64 | }; | 65 | }; |
65 | 66 | ||
66 | #endif /* end of include guard: SPRITE_H_70503825 */ | 67 | #endif /* end of include guard: SPRITE_H_70503825 */ |