summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/behaviour_system.cpp1
-rw-r--r--src/character_system.cpp1
-rw-r--r--src/direction.h17
-rw-r--r--src/main.cpp4
-rw-r--r--src/script_system.cpp7
5 files changed, 27 insertions, 3 deletions
diff --git a/src/behaviour_system.cpp b/src/behaviour_system.cpp index 4a194f0..a05912c 100644 --- a/src/behaviour_system.cpp +++ b/src/behaviour_system.cpp
@@ -59,6 +59,7 @@ void BehaviourSystem::tick(double dt) {
59 59
60void BehaviourSystem::directSpriteToLocation(int spriteId, vec2i pos, PathfindingOptions options) { 60void BehaviourSystem::directSpriteToLocation(int spriteId, vec2i pos, PathfindingOptions options) {
61 Sprite& sprite = game_.getSprite(spriteId); 61 Sprite& sprite = game_.getSprite(spriteId);
62 sprite.orientable = true;
62 sprite.behaviourType = BehaviourType::Path; 63 sprite.behaviourType = BehaviourType::Path;
63 sprite.pathfindingDestination = pos; 64 sprite.pathfindingDestination = pos;
64 sprite.cardinalDirectionsOnly = pathfindingOptionsContains(options, PathfindingOptions::CardinalDirectionsOnly); 65 sprite.cardinalDirectionsOnly = pathfindingOptionsContains(options, PathfindingOptions::CardinalDirectionsOnly);
diff --git a/src/character_system.cpp b/src/character_system.cpp index 53debb2..48d2a33 100644 --- a/src/character_system.cpp +++ b/src/character_system.cpp
@@ -17,6 +17,7 @@ void CharacterSystem::initSprite(int spriteId, int movementSpeed) {
17void CharacterSystem::addSpriteToParty(int leaderId, int followerId) { 17void 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 21
21 vec2i targetPos = leader.loc; 22 vec2i targetPos = leader.loc;
22 23
diff --git a/src/direction.h b/src/direction.h index 3dd95f9..595693f 100644 --- a/src/direction.h +++ b/src/direction.h
@@ -90,4 +90,21 @@ inline Direction directionFacingPoint(vec2i point) {
90 } 90 }
91} 91}
92 92
93inline Direction cardinalDirectionFacingPoint(vec2i point) {
94 double theta = atan2(point.y(), point.x());
95 theta /= M_PI;
96
97 if (theta < -3.0/4.0) {
98 return Direction::left;
99 } else if (theta < -1.0/4.0) {
100 return Direction::down;
101 } else if (theta < 1.0/4.0) {
102 return Direction::right;
103 } else if (theta < 3.0/4.0) {
104 return Direction::up;
105 } else {
106 return Direction::left;
107 }
108}
109
93#endif /* end of include guard: DIRECTION_H_AB66A90E */ 110#endif /* end of include guard: DIRECTION_H_AB66A90E */
diff --git a/src/main.cpp b/src/main.cpp index b98c8f1..d0220fc 100644 --- a/src/main.cpp +++ b/src/main.cpp
@@ -27,9 +27,9 @@ void loop(Renderer& renderer, std::mt19937& rng) {
27 game.emplaceSystem<MessageSystem>(); 27 game.emplaceSystem<MessageSystem>();
28 game.emplaceSystem<EffectSystem>(); 28 game.emplaceSystem<EffectSystem>();
29 29
30 game.loadMap("hallucination_interior"); 30 game.loadMap("pink_shell");
31 31
32 vec2i warpLoc = game.getMap().getWarpPoint("debugWarp_rightside"); 32 vec2i warpLoc = game.getMap().getWarpPoint("fromOutside");
33 33
34 int lucasSprite = game.emplaceSprite("lucas"); 34 int lucasSprite = game.emplaceSprite("lucas");
35 game.getSystem<TransformSystem>().initSprite(lucasSprite, warpLoc); 35 game.getSystem<TransformSystem>().initSprite(lucasSprite, warpLoc);
diff --git a/src/script_system.cpp b/src/script_system.cpp index 931759d..a3686b4 100644 --- a/src/script_system.cpp +++ b/src/script_system.cpp
@@ -44,7 +44,10 @@ ScriptSystem::ScriptSystem(Game& game) : game_(game) {
44 "cantCrouch", &Sprite::cantCrouch, 44 "cantCrouch", &Sprite::cantCrouch,
45 "bobsWhenNormal", &Sprite::bobsWhenNormal, 45 "bobsWhenNormal", &Sprite::bobsWhenNormal,
46 "animSlowdown", &Sprite::animSlowdown, 46 "animSlowdown", &Sprite::animSlowdown,
47 "enclosureZone", &Sprite::enclosureZone); 47 "enclosureZone", &Sprite::enclosureZone,
48 "movementSpeed", &Sprite::movementSpeed,
49 "solid", &Sprite::solid,
50 "behaviourType", &Sprite::behaviourType);
48 51
49 engine_.new_usertype<MessageSystem>( 52 engine_.new_usertype<MessageSystem>(
50 "message", 53 "message",
@@ -230,6 +233,8 @@ ScriptSystem::ScriptSystem(Game& game) : game_(game) {
230 loadMapScripts(filename); 233 loadMapScripts(filename);
231 }); 234 });
232 235
236 engine_.set_function("cardinalDirectionFacingPoint", &cardinalDirectionFacingPoint);
237
233 engine_.script_file("../res/scripts/common.lua"); 238 engine_.script_file("../res/scripts/common.lua");
234} 239}
235 240