summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2021-03-09 13:49:03 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2021-03-09 13:49:03 -0500
commitaac3b1bc1ba48b6e50f661b97326ef191cce3e6c (patch)
treedff16d2e26332a09576ff4965d0126070efa1b63 /src
parent032f60bc2686364f4df5bfb6c9faf86b84de31a6 (diff)
downloadtanetane-aac3b1bc1ba48b6e50f661b97326ef191cce3e6c.tar.gz
tanetane-aac3b1bc1ba48b6e50f661b97326ef191cce3e6c.tar.bz2
tanetane-aac3b1bc1ba48b6e50f661b97326ef191cce3e6c.zip
switch_claus starts talking when he gets ya
Kumatora, Duster, and Boney had to be given hitboxes, but they are not considered solid.

#10
Diffstat (limited to 'src')
-rw-r--r--src/character_system.cpp17
-rw-r--r--src/game.cpp3
-rw-r--r--src/main.cpp3
-rw-r--r--src/map.cpp2
-rw-r--r--src/map.h1
-rw-r--r--src/sprite.h2
6 files changed, 28 insertions, 0 deletions
diff --git a/src/character_system.cpp b/src/character_system.cpp index 48d2a33..548bd9d 100644 --- a/src/character_system.cpp +++ b/src/character_system.cpp
@@ -18,6 +18,7 @@ void CharacterSystem::addSpriteToParty(int leaderId, int followerId) {
18 Sprite& leader = game_.getSprite(leaderId); 18 Sprite& leader = game_.getSprite(leaderId);
19 Sprite& follower = game_.getSprite(followerId); 19 Sprite& follower = game_.getSprite(followerId);
20 follower.orientable = false; 20 follower.orientable = false;
21 follower.leaderId = leaderId;
21 22
22 vec2i targetPos = leader.loc; 23 vec2i targetPos = leader.loc;
23 24
@@ -83,6 +84,7 @@ void CharacterSystem::breakUpParty(int leaderId) {
83 for (int followerId : followers) { 84 for (int followerId : followers) {
84 Sprite& follower = game_.getSprite(followerId); 85 Sprite& follower = game_.getSprite(followerId);
85 follower.trail.clear(); 86 follower.trail.clear();
87 follower.leaderId = -1;
86 } 88 }
87} 89}
88 90
@@ -153,6 +155,7 @@ void CharacterSystem::tick(double dt) {
153 // Check collision. 155 // Check collision.
154 CollisionResult collision = game_.getSystem<TransformSystem>().checkCollision(spriteId, sprite.loc, pLoc, sprite.movementDir); 156 CollisionResult collision = game_.getSystem<TransformSystem>().checkCollision(spriteId, sprite.loc, pLoc, sprite.movementDir);
155 bool blocked = collision.horiz.blocked || collision.vert.blocked; 157 bool blocked = collision.horiz.blocked || collision.vert.blocked;
158 int colliderSpriteId = (collision.horiz.colliderSprite == -1) ? collision.vert.colliderSprite : collision.horiz.colliderSprite;
156 159
157 if (collision.horiz.blocked && !sprite.clipping) { 160 if (collision.horiz.blocked && !sprite.clipping) {
158 pLoc.x() = sprite.loc.x();//(newColPosDR * map.getTileSize() - (collisionBox / 2)).x() - 1; 161 pLoc.x() = sprite.loc.x();//(newColPosDR * map.getTileSize() - (collisionBox / 2)).x() - 1;
@@ -179,6 +182,20 @@ void CharacterSystem::tick(double dt) {
179 game_.getMixer().playSound("../res/sfx/bump.wav"); 182 game_.getMixer().playSound("../res/sfx/bump.wav");
180 } 183 }
181 184
185 if (colliderSpriteId != -1 && !sprite.bumpPlayerScript.empty()) {
186 Sprite& collider = game_.getSprite(colliderSpriteId);
187 bool bumpedPlayer = collider.player;
188
189 if (!bumpedPlayer && collider.leaderId != -1) {
190 Sprite& colliderLeader = game_.getSprite(collider.leaderId);
191 bumpedPlayer = colliderLeader.player;
192 }
193
194 if (bumpedPlayer) {
195 game_.getSystem<ScriptSystem>().runScript(game_.getMap().getName(), sprite.bumpPlayerScript);
196 }
197 }
198
182 // Move everything 199 // Move everything
183 if (pLoc != sprite.loc) { 200 if (pLoc != sprite.loc) {
184 game_.getSystem<TransformSystem>().moveSprite(spriteId, pLoc); 201 game_.getSystem<TransformSystem>().moveSprite(spriteId, pLoc);
diff --git a/src/game.cpp b/src/game.cpp index bedd934..80ff506 100644 --- a/src/game.cpp +++ b/src/game.cpp
@@ -72,6 +72,9 @@ void Game::loadMap(std::string filename) {
72 if (p.wander) { 72 if (p.wander) {
73 getSprite(spriteId).behaviourType = BehaviourType::Wander; 73 getSprite(spriteId).behaviourType = BehaviourType::Wander;
74 } 74 }
75 if (!p.bumpPlayerScript.empty()) {
76 getSprite(spriteId).bumpPlayerScript = p.bumpPlayerScript;
77 }
75 } 78 }
76 if (!p.enclosureZone.empty()) { 79 if (!p.enclosureZone.empty()) {
77 getSprite(spriteId).enclosureZone = p.enclosureZone; 80 getSprite(spriteId).enclosureZone = p.enclosureZone;
diff --git a/src/main.cpp b/src/main.cpp index 9cc25bb..051c4d1 100644 --- a/src/main.cpp +++ b/src/main.cpp
@@ -48,6 +48,7 @@ void loop(Renderer& renderer, std::mt19937& rng) {
48 48
49 int kumaSprite = game.emplaceSprite("kuma"); 49 int kumaSprite = game.emplaceSprite("kuma");
50 game.getSystem<TransformSystem>().initSprite(kumaSprite, warpLoc); 50 game.getSystem<TransformSystem>().initSprite(kumaSprite, warpLoc);
51 game.getSystem<TransformSystem>().setUpCollision(kumaSprite, {-8, -8}, {12, 8}, false);
51 game.getSystem<AnimationSystem>().initSprite(kumaSprite, "../res/sprites/kuma_anim.txt"); 52 game.getSystem<AnimationSystem>().initSprite(kumaSprite, "../res/sprites/kuma_anim.txt");
52 game.getSystem<AnimationSystem>().setSpriteDirection(kumaSprite, Direction::down); 53 game.getSystem<AnimationSystem>().setSpriteDirection(kumaSprite, Direction::down);
53 game.getSprite(kumaSprite).normallyHasShadow = true; 54 game.getSprite(kumaSprite).normallyHasShadow = true;
@@ -56,6 +57,7 @@ void loop(Renderer& renderer, std::mt19937& rng) {
56 57
57 int dusterSprite = game.emplaceSprite("duster"); 58 int dusterSprite = game.emplaceSprite("duster");
58 game.getSystem<TransformSystem>().initSprite(dusterSprite, warpLoc); 59 game.getSystem<TransformSystem>().initSprite(dusterSprite, warpLoc);
60 game.getSystem<TransformSystem>().setUpCollision(dusterSprite, {-8, -8}, {12, 8}, false);
59 game.getSystem<AnimationSystem>().initSprite(dusterSprite, "../res/sprites/duster_anim.txt"); 61 game.getSystem<AnimationSystem>().initSprite(dusterSprite, "../res/sprites/duster_anim.txt");
60 game.getSystem<AnimationSystem>().setSpriteDirection(dusterSprite, Direction::down); 62 game.getSystem<AnimationSystem>().setSpriteDirection(dusterSprite, Direction::down);
61 game.getSprite(dusterSprite).normallyHasShadow = true; 63 game.getSprite(dusterSprite).normallyHasShadow = true;
@@ -64,6 +66,7 @@ void loop(Renderer& renderer, std::mt19937& rng) {
64 66
65 int boneySprite = game.emplaceSprite("boney"); 67 int boneySprite = game.emplaceSprite("boney");
66 game.getSystem<TransformSystem>().initSprite(boneySprite, warpLoc); 68 game.getSystem<TransformSystem>().initSprite(boneySprite, warpLoc);
69 game.getSystem<TransformSystem>().setUpCollision(boneySprite, {-8, -8}, {12, 8}, false);
67 game.getSystem<AnimationSystem>().initSprite(boneySprite, "../res/sprites/boney_anim.txt"); 70 game.getSystem<AnimationSystem>().initSprite(boneySprite, "../res/sprites/boney_anim.txt");
68 game.getSystem<AnimationSystem>().setSpriteDirection(boneySprite, Direction::down); 71 game.getSystem<AnimationSystem>().setSpriteDirection(boneySprite, Direction::down);
69 game.getSprite(boneySprite).normallyHasShadow = true; 72 game.getSprite(boneySprite).normallyHasShadow = true;
diff --git a/src/map.cpp b/src/map.cpp index 32203e5..a170288 100644 --- a/src/map.cpp +++ b/src/map.cpp
@@ -119,6 +119,8 @@ Map::Map(std::string_view name) : name_(name) {
119 p.mirrorAxis = property.getIntValue(); 119 p.mirrorAxis = property.getIntValue();
120 } else if (property.getName() == "mirrorSprite") { 120 } else if (property.getName() == "mirrorSprite") {
121 p.spriteToMirror = property.getStringValue(); 121 p.spriteToMirror = property.getStringValue();
122 } else if (property.getName() == "bumpPlayerScript") {
123 p.bumpPlayerScript = property.getStringValue();
122 } 124 }
123 } 125 }
124 126
diff --git a/src/map.h b/src/map.h index eb926c7..9418aad 100644 --- a/src/map.h +++ b/src/map.h
@@ -27,6 +27,7 @@ struct Prototype {
27 std::string animName; 27 std::string animName;
28 Direction dir = Direction::down; 28 Direction dir = Direction::down;
29 std::string interactionScript; 29 std::string interactionScript;
30 std::string bumpPlayerScript;
30 bool shadow = false; 31 bool shadow = false;
31 bool wander = false; 32 bool wander = false;
32 int movementSpeed = -1; 33 int movementSpeed = -1;
diff --git a/src/sprite.h b/src/sprite.h index 10dd3a8..f631652 100644 --- a/src/sprite.h +++ b/src/sprite.h
@@ -81,6 +81,7 @@ public:
81 vec2i collisionSize; 81 vec2i collisionSize;
82 std::string interactionScript; 82 std::string interactionScript;
83 std::string walkthroughScript; 83 std::string walkthroughScript;
84 std::string bumpPlayerScript;
84 std::string enclosureZone; 85 std::string enclosureZone;
85 86
86 // Animation (internals) 87 // Animation (internals)
@@ -109,6 +110,7 @@ public:
109 bool orientable = false; 110 bool orientable = false;
110 int movementSpeed = 0; // 1 is slow (good for NPCs), 2 is Lucas's default walking speed 111 int movementSpeed = 0; // 1 is slow (good for NPCs), 2 is Lucas's default walking speed
111 std::vector<int> followers; 112 std::vector<int> followers;
113 int leaderId = -1;
112 std::deque<Movement> trail; 114 std::deque<Movement> trail;
113 bool trailsAreHalved = false; 115 bool trailsAreHalved = false;
114 CharacterState characterState = CharacterState::Still; 116 CharacterState characterState = CharacterState::Still;