blob: b506e59f24fd0898d096bf3eb5cb762a85536758 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include "mirror_system.h"
#include "game.h"
#include "transform_system.h"
#include "animation_system.h"
#include "vector.h"
#include "sprite.h"
void MirrorSystem::tick(double dt) {
for (int spriteId : game_.getSprites()) {
Sprite& sprite = game_.getSprite(spriteId);
if (!sprite.paused) {
switch (sprite.mirrorType) {
case MirrorType::None: break;
case MirrorType::Vertical: {
Sprite& mirroredSprite = game_.getSprite(sprite.mirroredSpriteId);
vec2i mirroredLoc = mirroredSprite.loc;
mirroredLoc.y() = 2 * sprite.mirrorAxis - mirroredLoc.y();
game_.getSystem<TransformSystem>().moveSprite(spriteId, mirroredLoc);
game_.getSystem<AnimationSystem>().setSpriteAnimation(spriteId, mirroredSprite.animationName);
game_.getSystem<AnimationSystem>().setSpriteDirection(spriteId, directionMirroredVertically(mirroredSprite.dir));
break;
}
}
}
}
}
|