summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/script_system.cpp7
-rw-r--r--src/transform_system.cpp9
-rw-r--r--src/transform_system.h2
3 files changed, 16 insertions, 2 deletions
diff --git a/src/script_system.cpp b/src/script_system.cpp index 090bf46..d4ee0ce 100644 --- a/src/script_system.cpp +++ b/src/script_system.cpp
@@ -35,7 +35,8 @@ ScriptSystem::ScriptSystem(Game& game) : game_(game) {
35 "animFinished", &Sprite::animFinished, 35 "animFinished", &Sprite::animFinished,
36 "getCurrentFrame", [] (const Sprite& sprite) -> const SpriteFrame& { 36 "getCurrentFrame", [] (const Sprite& sprite) -> const SpriteFrame& {
37 return sprite.frames[sprite.animations[sprite.animationId].frameIndices[sprite.animationFrame]]; 37 return sprite.frames[sprite.animations[sprite.animationId].frameIndices[sprite.animationFrame]];
38 }); 38 },
39 "persistent", &Sprite::persistent);
39 40
40 engine_.new_usertype<MessageSystem>( 41 engine_.new_usertype<MessageSystem>(
41 "message", 42 "message",
@@ -54,6 +55,7 @@ ScriptSystem::ScriptSystem(Game& game) : game_(game) {
54 55
55 engine_.new_usertype<CharacterSystem>( 56 engine_.new_usertype<CharacterSystem>(
56 "character", 57 "character",
58 "addSpriteToParty", &CharacterSystem::addSpriteToParty,
57 "transplantParty", &CharacterSystem::transplantParty, 59 "transplantParty", &CharacterSystem::transplantParty,
58 "startRunning", &CharacterSystem::startRunning, 60 "startRunning", &CharacterSystem::startRunning,
59 "halt", &CharacterSystem::halt); 61 "halt", &CharacterSystem::halt);
@@ -62,7 +64,8 @@ ScriptSystem::ScriptSystem(Game& game) : game_(game) {
62 "transform", 64 "transform",
63 "initSprite", [] (TransformSystem& transform, int spriteId, int x, int y, SpriteLayer layer) { 65 "initSprite", [] (TransformSystem& transform, int spriteId, int x, int y, SpriteLayer layer) {
64 transform.initSprite(spriteId, vec2i{x, y}, layer); 66 transform.initSprite(spriteId, vec2i{x, y}, layer);
65 }); 67 },
68 "undoCollision", &TransformSystem::undoCollision);
66 69
67 engine_.new_usertype<EffectSystem>( 70 engine_.new_usertype<EffectSystem>(
68 "effect", 71 "effect",
diff --git a/src/transform_system.cpp b/src/transform_system.cpp index 144477b..1d4a9f3 100644 --- a/src/transform_system.cpp +++ b/src/transform_system.cpp
@@ -19,6 +19,15 @@ void TransformSystem::setUpCollision(int spriteId, vec2i offset, vec2i size, boo
19 addCollidable(spriteId); 19 addCollidable(spriteId);
20} 20}
21 21
22void TransformSystem::undoCollision(int spriteId) {
23 Sprite& sprite = game_.getSprite(spriteId);
24
25 sprite.collidable = false;
26 sprite.solid = false;
27
28 removeCollidable(spriteId);
29}
30
22void TransformSystem::moveSprite(int spriteId, vec2i newLoc) { 31void TransformSystem::moveSprite(int spriteId, vec2i newLoc) {
23 Sprite& sprite = game_.getSprite(spriteId); 32 Sprite& sprite = game_.getSprite(spriteId);
24 if (sprite.collidable) { 33 if (sprite.collidable) {
diff --git a/src/transform_system.h b/src/transform_system.h index 4ee481e..d894b30 100644 --- a/src/transform_system.h +++ b/src/transform_system.h
@@ -35,6 +35,8 @@ public:
35 35
36 void setUpCollision(int spriteId, vec2i offset, vec2i size, bool solid); 36 void setUpCollision(int spriteId, vec2i offset, vec2i size, bool solid);
37 37
38 void undoCollision(int spriteId);
39
38 void moveSprite(int spriteId, vec2i newLoc); 40 void moveSprite(int spriteId, vec2i newLoc);
39 41
40 auto getSpritesByY(SpriteLayer layer) const { 42 auto getSpritesByY(SpriteLayer layer) const {