From 31858bebd0bc7ba4ffd4ce56190a06ce73bd0a48 Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 4 Jun 2024 05:35:52 +0200 Subject: [PATCH] adds start instruction state and fixes some issues --- assets/0001WaitingForGameStart.mp3 | 4 +- assets/0002AfterMainstation.mp3 | 4 +- assets/0003HackingStationMuhvella.mp3 | 2 +- assets/0004PickupStationMuhvella.mp3 | 4 +- assets/0005AfterStationMuhvella.mp3 | 4 +- assets/0006HackingStationMagie.mp3 | 4 +- assets/0007PickupStationMagie.mp3 | 4 +- assets/0009HackingBicola.mp3 | 4 +- assets/0010PickupBicola.mp3 | 4 +- assets/0012HackingTobione.mp3 | 4 +- assets/0013PickupTobione.mp3 | 4 +- assets/0014AfterTobione.mp3 | 4 +- assets/0015End.mp3 | 4 +- assets/0016AfterStationMagie.mp3 | 4 +- assets/0029Intro.mp3 | 3 ++ src/main.cpp | 2 +- src/sounds.h | 3 ++ src/states.cpp | 72 ++++++++++++++++++++++++--- src/states.h | 14 ++++++ src/text.h | 3 +- 20 files changed, 115 insertions(+), 36 deletions(-) create mode 100644 assets/0029Intro.mp3 diff --git a/assets/0001WaitingForGameStart.mp3 b/assets/0001WaitingForGameStart.mp3 index 7496557..e8f2b79 100644 --- a/assets/0001WaitingForGameStart.mp3 +++ b/assets/0001WaitingForGameStart.mp3 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:21bf168a9f7630f5c48687a15fbd3d6bdd303b5dabecaea76ac2e994f8839fef -size 889344 +oid sha256:071d551d6e05672be0e2d0164e547251e105547f63ab5a220c4ba81b4ef42a12 +size 953472 diff --git a/assets/0002AfterMainstation.mp3 b/assets/0002AfterMainstation.mp3 index e81d240..40bde85 100644 --- a/assets/0002AfterMainstation.mp3 +++ b/assets/0002AfterMainstation.mp3 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:63371bb5c9d3b2a91588a31de26049c365c737e1561d5a6ea93b20b173bf18ba -size 797184 +oid sha256:121cf70913522060d0dc273c4d7b98d73bc147895e13f3d987108b16515e0a3b +size 185472 diff --git a/assets/0003HackingStationMuhvella.mp3 b/assets/0003HackingStationMuhvella.mp3 index abe5e3a..874a7ce 100644 --- a/assets/0003HackingStationMuhvella.mp3 +++ b/assets/0003HackingStationMuhvella.mp3 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:69febc15f9893be142276849afa471331d9823e76fcf320cb45b6a22f597bb1a +oid sha256:1dbe24aef80632e46f4ded6241d4192c13fa1357a7c38ea3da9d1c2dcab9ac55 size 401280 diff --git a/assets/0004PickupStationMuhvella.mp3 b/assets/0004PickupStationMuhvella.mp3 index 5c37542..2c65546 100644 --- a/assets/0004PickupStationMuhvella.mp3 +++ b/assets/0004PickupStationMuhvella.mp3 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8d85ce2880b0d24df851080426b124527896803acf5143e9ba4c1a5e16243ec3 -size 277248 +oid sha256:3f65d84d2e024526be1b320ca8e816025d089ee8c7ad57f695d8e73b20267345 +size 401280 diff --git a/assets/0005AfterStationMuhvella.mp3 b/assets/0005AfterStationMuhvella.mp3 index 4ccf604..4d81b64 100644 --- a/assets/0005AfterStationMuhvella.mp3 +++ b/assets/0005AfterStationMuhvella.mp3 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:624d43f1a8a05041684cdd9fa3dbf8a23e8775ee57eed7f69ed995ec05cb3beb -size 445440 +oid sha256:dee7d91d478548b08c9ce518d749fa2a9e33f4577e4a496e611fb17fba0a94a2 +size 316032 diff --git a/assets/0006HackingStationMagie.mp3 b/assets/0006HackingStationMagie.mp3 index 53138cf..3b14bc4 100644 --- a/assets/0006HackingStationMagie.mp3 +++ b/assets/0006HackingStationMagie.mp3 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4521f8ca1193c391a097baecc27038241d351ab671ae53f62db697bcd4dcec48 -size 469248 +oid sha256:a3f970cfb76b4b912aa38ff9abdb28921aa9aab7242965d144d8e66316ad5719 +size 465408 diff --git a/assets/0007PickupStationMagie.mp3 b/assets/0007PickupStationMagie.mp3 index 3fc7ada..4abc441 100644 --- a/assets/0007PickupStationMagie.mp3 +++ b/assets/0007PickupStationMagie.mp3 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d7dd0e1a62798011a83f7f0650d7b540d6d1a3fe54dcc9bca57eedee67dffe64 -size 477312 +oid sha256:218e6de26f8ea212edea03f06d249ef135ee11cbea5913ce27b416a3e203dc4a +size 529152 diff --git a/assets/0009HackingBicola.mp3 b/assets/0009HackingBicola.mp3 index f856f57..b5defe9 100644 --- a/assets/0009HackingBicola.mp3 +++ b/assets/0009HackingBicola.mp3 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6972d6fe940dcf817972cbc26e157251f48dd6d93c832147c5ec5a38f1642b3d -size 591840 +oid sha256:49fe3a01005997436144572df11792aeb13f50b83bc5f4ed00fc05f221be34f5 +size 611520 diff --git a/assets/0010PickupBicola.mp3 b/assets/0010PickupBicola.mp3 index 0cf7b7a..cfa97d7 100644 --- a/assets/0010PickupBicola.mp3 +++ b/assets/0010PickupBicola.mp3 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cec0c449f1cf58e6b5b69491783071d5085246d103a5b384886fa6ee014ac923 -size 1161600 +oid sha256:e30d3faa9b214a340828c2d57dbe7681fa98c2e984479f271bcd3663048f7638 +size 1121760 diff --git a/assets/0012HackingTobione.mp3 b/assets/0012HackingTobione.mp3 index bd9154a..b73a808 100644 --- a/assets/0012HackingTobione.mp3 +++ b/assets/0012HackingTobione.mp3 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:64ab0f541e5fe67b9f3663b0fc87ad77ddd217df05dc31bf546138fc0a2e5e9e -size 791520 +oid sha256:42d9b18e9fd14c9a0bc2cd87ffe02fb88c2171eda0133fcb77023f31d8d17f59 +size 801600 diff --git a/assets/0013PickupTobione.mp3 b/assets/0013PickupTobione.mp3 index 88d0b7d..34c4870 100644 --- a/assets/0013PickupTobione.mp3 +++ b/assets/0013PickupTobione.mp3 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:173dbe32eeccba13fa27cd8880bca34f22db63029401f529fc01f66cddd5ab3d -size 1161600 +oid sha256:01e7855ce6c7b8098761f9a66058be20d709f33faf9263ac268aef048b513cb2 +size 1321440 diff --git a/assets/0014AfterTobione.mp3 b/assets/0014AfterTobione.mp3 index 7203f8a..aa96aa4 100644 --- a/assets/0014AfterTobione.mp3 +++ b/assets/0014AfterTobione.mp3 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3d89019ca9477457555209104e2def1d2a6cf5b87625ecbac5f429f8c912d236 -size 441600 +oid sha256:9f848a6ca577d3c5d170cf656bce66d1be66ed4059c28365174a4199c23bd48c +size 461760 diff --git a/assets/0015End.mp3 b/assets/0015End.mp3 index b317e7d..bd9154a 100644 --- a/assets/0015End.mp3 +++ b/assets/0015End.mp3 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e04c9d52e55708c65ceb13d5aefda2a23c53186e33b9740c4f38abe8c23acdc8 -size 921600 +oid sha256:64ab0f541e5fe67b9f3663b0fc87ad77ddd217df05dc31bf546138fc0a2e5e9e +size 791520 diff --git a/assets/0016AfterStationMagie.mp3 b/assets/0016AfterStationMagie.mp3 index fb09a94..02812fe 100644 --- a/assets/0016AfterStationMagie.mp3 +++ b/assets/0016AfterStationMagie.mp3 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1b618ea2a7b01e411f4f8236c7554cbaf846576a8d1dca9a5d5ad233f6382371 -size 429312 +oid sha256:bc9c4ca1e2e0c738e0b6c0323db49da9db2a204796b33f67b2078f5f6cc20769 +size 401280 diff --git a/assets/0029Intro.mp3 b/assets/0029Intro.mp3 new file mode 100644 index 0000000..f1e53c6 --- /dev/null +++ b/assets/0029Intro.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:95f104be43cae044964c6f5a6c159b47e596c5685bcbf1ccf23a80e0a8bdeb59 +size 617472 diff --git a/src/main.cpp b/src/main.cpp index 4bb6e47..02de43d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -182,5 +182,5 @@ void setup(void) } } - dfPlayer.volume(25); + dfPlayer.volume(15); } diff --git a/src/sounds.h b/src/sounds.h index cb7c3c9..12199a2 100644 --- a/src/sounds.h +++ b/src/sounds.h @@ -25,3 +25,6 @@ #define WRONG_STATION_END 23 #define PUT_ME_BACK_START 24 #define PUT_ME_BACK_END 28 + +#define START_INSTRUCTIONS 29 + diff --git a/src/states.cpp b/src/states.cpp index d79f733..5446753 100644 --- a/src/states.cpp +++ b/src/states.cpp @@ -40,7 +40,7 @@ WaitingForGameStart::WaitingForGameStart() = default; State* WaitingForGameStart::pickedUp(const Context context) { - return new OnTheMove(context.stations + 1, context.stations); // first element of the array + return new StartInstructions(context.stations + 1); } State* WaitingForGameStart::update(const Context context) @@ -62,6 +62,51 @@ void WaitingForGameStart::activated(const Context context) //------------------------------------ +StartInstructions::StartInstructions(Station* targetStation): timer(Timer(0, false)) +{ + this->targetStation = targetStation; +} + +State* StartInstructions::putDown(const Context context, Station* newStation) +{ + if (newStation == this->targetStation) + { + return new Hacking(targetStation); + } + + if (newStation == context.stations) + { + return new WaitingForGameStart(); // todo replace with Restarting + } + return new IncorrectStation(targetStation, context.stations); +} + +State* StartInstructions::update(const Context context) +{ + bool done = timer.update(context.delta); + if (done) + { + return new OnTheMove(targetStation, context.stations); + } + return this; +} + +String StartInstructions::updateDisplay(const Context& context) +{ + return INTRO_TEXT; +} + +void StartInstructions::activated(const Context context) +{ + context.dfPlayer->play(START_INSTRUCTIONS); + timer = Timer(10000, false); // todo set correct time + timer.start(); +} + + +//------------------------------------ + + OnTheMove::OnTheMove(Station* targetStation, Station* previousStation) { this->targetStation = targetStation; @@ -72,12 +117,16 @@ State* OnTheMove::putDown(const Context context, Station* newStation) { if (newStation == this->targetStation) { - if (targetStation == context.stations) // first station + if (targetStation == context.stations) // is home base? { return new End(); } return new Hacking(this->targetStation); } + if (newStation == context.stations) + { + return new WaitingForGameStart(); // todo replace with Restarting + } return new IncorrectStation(targetStation, previousStation); } @@ -110,7 +159,7 @@ String OnTheMove::updateDisplay(const Context& context) { return BICOLA_AFTER_TEXT; } - + return "UNDEFINED"; } @@ -223,25 +272,26 @@ String Hacking::updateDisplay(const Context& context) void Hacking::activated(const Context context) { + // todo change times auto currentStationIndex = context.getStationIndex(this->currentStation); if (currentStationIndex == 1) { - timer = Timer(25000, false); + timer = Timer(5000, false); context.dfPlayer->play(HACKING_STATION_MUHVELLA); } if (currentStationIndex == 2) { - timer = Timer(29000, false); + timer = Timer(5000, false); context.dfPlayer->play(HACKING_STATION_MAGIE); } if (currentStationIndex == 3) { - timer = Timer(29000, false); + timer = Timer(5000, false); context.dfPlayer->play(HACKING_STATION_BICOLA); } if (currentStationIndex == 4) { - timer = Timer(40000, false); + timer = Timer(5000, false); context.dfPlayer->play(HACKING_STATION_TOBIONE); } timer.start(); @@ -260,8 +310,16 @@ State* Complain::putDown(const Context context, Station* newStation) { if (this->currentStation == newStation) // was put back on correct station { + if (currentStation == context.stations) // if wants to be put back on main station + { + return new End(); + } return new Hacking(this->currentStation); } + if (newStation == context.stations) // if was incorrectly put back on main station + { + return new WaitingForGameStart(); // todo return Restarting + } return this; // was not put back on correct station (just keeps complaining) } diff --git a/src/states.h b/src/states.h index 33b09a4..2dc6913 100644 --- a/src/states.h +++ b/src/states.h @@ -27,6 +27,20 @@ public: void activated(Context context) override; }; +class StartInstructions final : public State +{ +private: + Station* targetStation; + Timer timer; + +public: + explicit StartInstructions(Station* targetStation); + State* putDown(Context context, Station* newStation) override; + State* update(Context context) override; + String updateDisplay(const Context& context) override; + void activated(Context context) override; +}; + class OnTheMove final : public State { private: diff --git a/src/text.h b/src/text.h index 47a8ea4..a6e059c 100644 --- a/src/text.h +++ b/src/text.h @@ -1,7 +1,8 @@ #pragma once #define WAITING_FOR_START_TEXT "Lupf mich uf" -#define MAIN_AFTER_PICKUP_TEXT "Danke :D <3 Lueg chli ume" +#define INTRO_TEXT "Danke :D <3" +#define MAIN_AFTER_PICKUP_TEXT "Lueg chli ume" #define MUHVELLA_HACKING_TEXT "Eifach ligge lahBitte warte" #define MUHVELLA_PICKUP_TEXT "Los! Witer =O"