diff options
Diffstat (limited to 'src')
-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 |
4 files changed, 7 insertions, 4 deletions
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 */ |