summary refs log tree commit diff stats
path: root/src/main.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2021-02-09 22:28:27 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2021-02-09 22:28:27 -0500
commit5931470800c43260f600303d1231dbaf586f26fc (patch)
treeaaaa30ee6bae81c1badc8b70d2fbdce33a058d5a /src/main.cpp
parent315ca2fb388f790791c9ce372cf44e00d51e0e7f (diff)
downloadtanetane-5931470800c43260f600303d1231dbaf586f26fc.tar.gz
tanetane-5931470800c43260f600303d1231dbaf586f26fc.tar.bz2
tanetane-5931470800c43260f600303d1231dbaf586f26fc.zip
Map changing!
Also removed some dependencies on the Renderer. More changes need to be made. Fading to black before the change would be good. And making sure the characters are facing the right direction. Maybe that code shouldn't live in Game, either. Later we also want to combine the tilesets for these two maps (and any others that are on Tanetane).
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp43
1 files changed, 1 insertions, 42 deletions
diff --git a/src/main.cpp b/src/main.cpp index a350c8d..5f28408 100644 --- a/src/main.cpp +++ b/src/main.cpp
@@ -22,48 +22,7 @@ void loop(Renderer& renderer) {
22 game.emplaceSystem<MessageSystem>(); 22 game.emplaceSystem<MessageSystem>();
23 game.emplaceSystem<ScriptSystem>(); 23 game.emplaceSystem<ScriptSystem>();
24 24
25 auto map = std::make_unique<Map>("../res/maps/map1.tmx", renderer); 25 game.loadMap("../res/maps/map1.tmx", "spawn");
26 game.setMap(std::move(map));
27
28 int lucasSprite = game.emplaceSprite("lucas");
29 game.getSystem<TransformSystem>().initSprite(lucasSprite, game.getMap().getWarpPoint("spawn"));
30 game.getSystem<TransformSystem>().setUpCollision(lucasSprite, {-8, -8}, {12, 8}, true);
31 game.getSystem<AnimationSystem>().initSprite(lucasSprite, "../res/sprites/lucas_anim.txt", renderer);
32 game.getSprite(lucasSprite).controllable = true;
33 game.getSystem<CharacterSystem>().initSprite(lucasSprite);
34
35 int kumaSprite = game.emplaceSprite("kuma");
36 game.getSystem<TransformSystem>().initSprite(kumaSprite, {32, 32});
37 game.getSystem<AnimationSystem>().initSprite(kumaSprite, "../res/sprites/kuma_anim.txt", renderer);
38 game.getSystem<CharacterSystem>().addSpriteToParty(lucasSprite, kumaSprite);
39
40 int dusterSprite = game.emplaceSprite("duster");
41 game.getSystem<TransformSystem>().initSprite(dusterSprite, {32, 32});
42 game.getSystem<AnimationSystem>().initSprite(dusterSprite, "../res/sprites/duster_anim.txt", renderer);
43 game.getSystem<CharacterSystem>().addSpriteToParty(lucasSprite, dusterSprite);
44
45 int boneySprite = game.emplaceSprite("boney");
46 game.getSystem<TransformSystem>().initSprite(boneySprite, {32, 32});
47 game.getSystem<AnimationSystem>().initSprite(boneySprite, "../res/sprites/boney_anim.txt", renderer);
48 game.getSystem<CharacterSystem>().addSpriteToParty(lucasSprite, boneySprite);
49
50 for (const Prototype& p : game.getMap().getPrototypes()) {
51 int spriteId = game.emplaceSprite(p.name);
52 game.getSystem<TransformSystem>().initSprite(spriteId, p.pos);
53 game.getSystem<TransformSystem>().setUpCollision(spriteId, p.collisionOffset, p.collisionSize, true);
54 game.getSystem<AnimationSystem>().initSprite(spriteId, p.animationFilename, renderer);
55 game.getSprite(spriteId).interactionScript = p.interactionScript;
56 }
57
58 for (const Trigger& t : game.getMap().getTriggers()) {
59 int spriteId = game.emplaceSprite(t.name);
60 game.getSystem<TransformSystem>().initSprite(spriteId, t.pos);
61 game.getSystem<TransformSystem>().setUpCollision(spriteId, {0, 0}, t.size, false);
62 game.getSprite(spriteId).walkthroughScript = t.script;
63 }
64
65 game.getSystem<CameraSystem>().setFollowingSprite(lucasSprite);
66 game.getSystem<CameraSystem>().unlockCamera();
67 26
68 renderer.render(game); 27 renderer.render(game);
69 28