summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2021-02-07 22:20:48 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2021-02-07 22:20:48 -0500
commit3f6a071f6728b4d08553220d4174018a4080b176 (patch)
treed0276bf86d48931e5781957c8a431a970215d0d9
parenta990e4921820fe7b27c645639fba903329dba6b8 (diff)
downloadtanetane-3f6a071f6728b4d08553220d4174018a4080b176.tar.gz
tanetane-3f6a071f6728b4d08553220d4174018a4080b176.tar.bz2
tanetane-3f6a071f6728b4d08553220d4174018a4080b176.zip
Added "no problem here"
-rw-r--r--res/scripts/default.lua5
-rw-r--r--src/input_system.cpp13
2 files changed, 18 insertions, 0 deletions
diff --git a/res/scripts/default.lua b/res/scripts/default.lua new file mode 100644 index 0000000..6188c36 --- /dev/null +++ b/res/scripts/default.lua
@@ -0,0 +1,5 @@
1function default()
2 DisplayMessage("No problem here.", "", SpeakerType.NONE)
3 WaitForEndOfMessage()
4 HideCutsceneBars()
5end
diff --git a/src/input_system.cpp b/src/input_system.cpp index 5133e27..5158724 100644 --- a/src/input_system.cpp +++ b/src/input_system.cpp
@@ -34,12 +34,19 @@ void InputSystem::tick(double dt) {
34 game_.getSystem<MessageSystem>().advanceText(); 34 game_.getSystem<MessageSystem>().advanceText();
35 } else { 35 } else {
36 // Otherwise, check if there is a sprite in front of the player. 36 // Otherwise, check if there is a sprite in front of the player.
37 bool inFrontOfSomething = false;
38 bool activated = false;
39
37 for (int spriteId : game_.getSprites()) { 40 for (int spriteId : game_.getSprites()) {
38 Sprite& sprite = game_.getSprite(spriteId); 41 Sprite& sprite = game_.getSprite(spriteId);
39 if (sprite.controllable) { 42 if (sprite.controllable) {
40 vec2i checkLoc = sprite.loc + (unitVecInDirection(sprite.dir) * MOVEMENT_SPEED); 43 vec2i checkLoc = sprite.loc + (unitVecInDirection(sprite.dir) * MOVEMENT_SPEED);
41 CollisionResult collision = game_.getSystem<TransformSystem>().checkCollision(spriteId, checkLoc, sprite.dir); 44 CollisionResult collision = game_.getSystem<TransformSystem>().checkCollision(spriteId, checkLoc, sprite.dir);
42 45
46 if (collision.horiz.blocked || collision.vert.blocked) {
47 inFrontOfSomething = true;
48 }
49
43 // If there is a sprite to be interacted with, rotate that sprite so it is facing the player. 50 // If there is a sprite to be interacted with, rotate that sprite so it is facing the player.
44 // Then, run its interaction script if present. 51 // Then, run its interaction script if present.
45 if (collision.horiz.colliderSprite != -1) { 52 if (collision.horiz.colliderSprite != -1) {
@@ -48,6 +55,7 @@ void InputSystem::tick(double dt) {
48 Sprite& collider = game_.getSprite(collision.horiz.colliderSprite); 55 Sprite& collider = game_.getSprite(collision.horiz.colliderSprite);
49 if (collider.interactionScript != "") { 56 if (collider.interactionScript != "") {
50 game_.getSystem<ScriptSystem>().runScript(collider.interactionScript); 57 game_.getSystem<ScriptSystem>().runScript(collider.interactionScript);
58 activated = true;
51 } 59 }
52 } else if (collision.vert.colliderSprite != -1) { 60 } else if (collision.vert.colliderSprite != -1) {
53 game_.getSystem<AnimationSystem>().setSpriteDirection(collision.vert.colliderSprite, oppositeDirection(sprite.dir)); 61 game_.getSystem<AnimationSystem>().setSpriteDirection(collision.vert.colliderSprite, oppositeDirection(sprite.dir));
@@ -55,10 +63,15 @@ void InputSystem::tick(double dt) {
55 Sprite& collider = game_.getSprite(collision.vert.colliderSprite); 63 Sprite& collider = game_.getSprite(collision.vert.colliderSprite);
56 if (collider.interactionScript != "") { 64 if (collider.interactionScript != "") {
57 game_.getSystem<ScriptSystem>().runScript(collider.interactionScript); 65 game_.getSystem<ScriptSystem>().runScript(collider.interactionScript);
66 activated = true;
58 } 67 }
59 } 68 }
60 } 69 }
61 } 70 }
71
72 if (inFrontOfSomething && !activated) {
73 game_.getSystem<ScriptSystem>().runScript("default");
74 }
62 } 75 }
63 } 76 }
64 } else if (e.type == SDL_KEYUP && (e.key.keysym.sym == SDLK_LSHIFT || e.key.keysym.sym == SDLK_RSHIFT)) { 77 } else if (e.type == SDL_KEYUP && (e.key.keysym.sym == SDLK_LSHIFT || e.key.keysym.sym == SDLK_RSHIFT)) {