summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/character_system.cpp6
-rw-r--r--src/game.cpp6
-rw-r--r--src/game.h2
-rw-r--r--src/main.cpp2
-rw-r--r--src/script_system.cpp4
5 files changed, 14 insertions, 6 deletions
diff --git a/src/character_system.cpp b/src/character_system.cpp index 94833a8..781b50d 100644 --- a/src/character_system.cpp +++ b/src/character_system.cpp
@@ -24,7 +24,11 @@ void CharacterSystem::addSpriteToParty(int leaderId, int followerId) {
24 targetPos = backFollower.loc; 24 targetPos = backFollower.loc;
25 } 25 }
26 26
27 Direction toFace = directionFacingPoint(targetPos - follower.loc); 27 Direction toFace = leader.dir;
28 if (targetPos != follower.loc) {
29 toFace = directionFacingPoint(targetPos - follower.loc);
30 }
31
28 for (int i=0; i<PARTY_FRAME_DELAY; i++) { 32 for (int i=0; i<PARTY_FRAME_DELAY; i++) {
29 vec2i tween = ((follower.loc - targetPos) * i) / static_cast<double>(PARTY_FRAME_DELAY) + targetPos; 33 vec2i tween = ((follower.loc - targetPos) * i) / static_cast<double>(PARTY_FRAME_DELAY) + targetPos;
30 follower.trail.push_front({.pos = tween, .dir = toFace}); 34 follower.trail.push_front({.pos = tween, .dir = toFace});
diff --git a/src/game.cpp b/src/game.cpp index dc3a5ba..4d44a63 100644 --- a/src/game.cpp +++ b/src/game.cpp
@@ -22,7 +22,7 @@ void Game::clearSprites() {
22 spritesByAlias_.clear(); 22 spritesByAlias_.clear();
23} 23}
24 24
25void Game::loadMap(std::string filename, std::string warpPoint) { 25void Game::loadMap(std::string filename, std::string warpPoint, Direction dir) {
26 clearSprites(); 26 clearSprites();
27 27
28 map_ = std::make_unique<Map>(filename); 28 map_ = std::make_unique<Map>(filename);
@@ -33,22 +33,26 @@ void Game::loadMap(std::string filename, std::string warpPoint) {
33 getSystem<TransformSystem>().initSprite(lucasSprite, warpLoc); 33 getSystem<TransformSystem>().initSprite(lucasSprite, warpLoc);
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 getSprite(lucasSprite).controllable = true; 37 getSprite(lucasSprite).controllable = true;
37 getSystem<CharacterSystem>().initSprite(lucasSprite); 38 getSystem<CharacterSystem>().initSprite(lucasSprite);
38 39
39 int kumaSprite = emplaceSprite("kuma"); 40 int kumaSprite = emplaceSprite("kuma");
40 getSystem<TransformSystem>().initSprite(kumaSprite, warpLoc); 41 getSystem<TransformSystem>().initSprite(kumaSprite, warpLoc);
41 getSystem<AnimationSystem>().initSprite(kumaSprite, "../res/sprites/kuma_anim.txt"); 42 getSystem<AnimationSystem>().initSprite(kumaSprite, "../res/sprites/kuma_anim.txt");
43 getSystem<AnimationSystem>().setSpriteDirection(kumaSprite, dir);
42 getSystem<CharacterSystem>().addSpriteToParty(lucasSprite, kumaSprite); 44 getSystem<CharacterSystem>().addSpriteToParty(lucasSprite, kumaSprite);
43 45
44 int dusterSprite = emplaceSprite("duster"); 46 int dusterSprite = emplaceSprite("duster");
45 getSystem<TransformSystem>().initSprite(dusterSprite, warpLoc); 47 getSystem<TransformSystem>().initSprite(dusterSprite, warpLoc);
46 getSystem<AnimationSystem>().initSprite(dusterSprite, "../res/sprites/duster_anim.txt"); 48 getSystem<AnimationSystem>().initSprite(dusterSprite, "../res/sprites/duster_anim.txt");
49 getSystem<AnimationSystem>().setSpriteDirection(dusterSprite, dir);
47 getSystem<CharacterSystem>().addSpriteToParty(lucasSprite, dusterSprite); 50 getSystem<CharacterSystem>().addSpriteToParty(lucasSprite, dusterSprite);
48 51
49 int boneySprite = emplaceSprite("boney"); 52 int boneySprite = emplaceSprite("boney");
50 getSystem<TransformSystem>().initSprite(boneySprite, warpLoc); 53 getSystem<TransformSystem>().initSprite(boneySprite, warpLoc);
51 getSystem<AnimationSystem>().initSprite(boneySprite, "../res/sprites/boney_anim.txt"); 54 getSystem<AnimationSystem>().initSprite(boneySprite, "../res/sprites/boney_anim.txt");
55 getSystem<AnimationSystem>().setSpriteDirection(boneySprite, dir);
52 getSystem<CharacterSystem>().addSpriteToParty(lucasSprite, boneySprite); 56 getSystem<CharacterSystem>().addSpriteToParty(lucasSprite, boneySprite);
53 57
54 for (const Prototype& p : map_->getPrototypes()) { 58 for (const Prototype& p : map_->getPrototypes()) {
diff --git a/src/game.h b/src/game.h index bb88dec..84114ca 100644 --- a/src/game.h +++ b/src/game.h
@@ -73,7 +73,7 @@ public:
73 }); 73 });
74 } 74 }
75 75
76 void loadMap(std::string filename, std::string warpPoint); 76 void loadMap(std::string filename, std::string warpPoint, Direction dir);
77 77
78 const Map& getMap() const { return *map_; } 78 const Map& getMap() const { return *map_; }
79 79
diff --git a/src/main.cpp b/src/main.cpp index 8487077..ddc8df2 100644 --- a/src/main.cpp +++ b/src/main.cpp
@@ -22,7 +22,7 @@ void loop(Renderer& renderer) {
22 game.emplaceSystem<CameraSystem>(); 22 game.emplaceSystem<CameraSystem>();
23 game.emplaceSystem<MessageSystem>(); 23 game.emplaceSystem<MessageSystem>();
24 24
25 game.loadMap("../res/maps/map1.tmx", "spawn"); 25 game.loadMap("../res/maps/map1.tmx", "spawn", Direction::down);
26 26
27 renderer.render(game); 27 renderer.render(game);
28 28
diff --git a/src/script_system.cpp b/src/script_system.cpp index d8d93e3..e388c6e 100644 --- a/src/script_system.cpp +++ b/src/script_system.cpp
@@ -88,8 +88,8 @@ ScriptSystem::ScriptSystem(Game& game) : game_(game) {
88 88
89 engine_.set_function( 89 engine_.set_function(
90 "loadMap", 90 "loadMap",
91 [&] (std::string filename, std::string warpPoint) { 91 [&] (std::string filename, std::string warpPoint, Direction dir) {
92 game_.loadMap(filename, warpPoint); 92 game_.loadMap(filename, warpPoint, dir);
93 }); 93 });
94 94
95 engine_.set_function( 95 engine_.set_function(