summary refs log tree commit diff stats
path: root/src/main.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2021-02-17 20:34:59 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2021-02-17 20:34:59 -0500
commitaac57db782718bf40a7adea15baf8d6b899ea925 (patch)
treec9f32563cdb9a06e6e24343946c5bb35dc254b76 /src/main.cpp
parentb3720c4a401f345c49eadabdb852968e273e7077 (diff)
downloadtanetane-aac57db782718bf40a7adea15baf8d6b899ea925.tar.gz
tanetane-aac57db782718bf40a7adea15baf8d6b899ea925.tar.bz2
tanetane-aac57db782718bf40a7adea15baf8d6b899ea925.zip
Made some sprites persist between map changes
The player party characters are now initialised at the start of the game and are no longer re-created after every map change. The script system takes care of moving the player into the correct position on the new map.

Deleted sprite IDs are now reused the next time a sprite is created, instead of throwing out everything between maps.
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp42
1 files changed, 40 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp index 79fa306..f220dc0 100644 --- a/src/main.cpp +++ b/src/main.cpp
@@ -24,8 +24,46 @@ void loop(Renderer& renderer) {
24 game.emplaceSystem<MessageSystem>(); 24 game.emplaceSystem<MessageSystem>();
25 game.emplaceSystem<EffectSystem>(); 25 game.emplaceSystem<EffectSystem>();
26 26
27 game.loadMap("map2", "debugWarp_mailboxes", Direction::down); 27 game.loadMap("map2");
28 game.getSprite(game.getSpriteByAlias("lucas")).controllable = true; 28
29 vec2i warpLoc = game.getMap().getWarpPoint("debugWarp_mailboxes");
30
31 int lucasSprite = game.emplaceSprite("lucas");
32 game.getSystem<TransformSystem>().initSprite(lucasSprite, warpLoc);
33 game.getSystem<TransformSystem>().setUpCollision(lucasSprite, {-8, -8}, {12, 8}, true);
34 game.getSystem<AnimationSystem>().initSprite(lucasSprite, "../res/sprites/lucas_anim.txt");
35 game.getSystem<AnimationSystem>().setSpriteDirection(lucasSprite, Direction::down);
36 game.getSprite(lucasSprite).hasShadow = true;
37 game.getSprite(lucasSprite).player = true;
38 game.getSprite(lucasSprite).controllable = true;
39 game.getSprite(lucasSprite).persistent = true;
40 game.getSystem<CharacterSystem>().initSprite(lucasSprite);
41 game.getSystem<CameraSystem>().setFollowingSprite(lucasSprite);
42 game.getSystem<CameraSystem>().unlockCamera();
43
44 int kumaSprite = game.emplaceSprite("kuma");
45 game.getSystem<TransformSystem>().initSprite(kumaSprite, warpLoc);
46 game.getSystem<AnimationSystem>().initSprite(kumaSprite, "../res/sprites/kuma_anim.txt");
47 game.getSystem<AnimationSystem>().setSpriteDirection(kumaSprite, Direction::down);
48 game.getSprite(kumaSprite).hasShadow = true;
49 game.getSprite(kumaSprite).persistent = true;
50 game.getSystem<CharacterSystem>().addSpriteToParty(lucasSprite, kumaSprite);
51
52 int dusterSprite = game.emplaceSprite("duster");
53 game.getSystem<TransformSystem>().initSprite(dusterSprite, warpLoc);
54 game.getSystem<AnimationSystem>().initSprite(dusterSprite, "../res/sprites/duster_anim.txt");
55 game.getSystem<AnimationSystem>().setSpriteDirection(dusterSprite, Direction::down);
56 game.getSprite(dusterSprite).hasShadow = true;
57 game.getSprite(dusterSprite).persistent = true;
58 game.getSystem<CharacterSystem>().addSpriteToParty(lucasSprite, dusterSprite);
59
60 int boneySprite = game.emplaceSprite("boney");
61 game.getSystem<TransformSystem>().initSprite(boneySprite, warpLoc);
62 game.getSystem<AnimationSystem>().initSprite(boneySprite, "../res/sprites/boney_anim.txt");
63 game.getSystem<AnimationSystem>().setSpriteDirection(boneySprite, Direction::down);
64 game.getSprite(boneySprite).hasShadow = true;
65 game.getSprite(boneySprite).persistent = true;
66 game.getSystem<CharacterSystem>().addSpriteToParty(lucasSprite, boneySprite);
29 67
30 renderer.render(game); 68 renderer.render(game);
31 69