fixes audiofiles and adds screentext
This commit is contained in:
parent
47195d9445
commit
c8346ded11
12 changed files with 184 additions and 83 deletions
BIN
assets/0007PickupStationMagie.mp3
(Stored with Git LFS)
BIN
assets/0007PickupStationMagie.mp3
(Stored with Git LFS)
Binary file not shown.
BIN
assets/0008AfterSationMagie.mp3
(Stored with Git LFS)
BIN
assets/0008AfterSationMagie.mp3
(Stored with Git LFS)
Binary file not shown.
BIN
assets/0008ObjektvonderNebenstationentfernt.mp3
(Stored with Git LFS)
Normal file
BIN
assets/0008ObjektvonderNebenstationentfernt.mp3
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/0017AfterStationMagie.mp3
(Stored with Git LFS)
Normal file
BIN
assets/0017AfterStationMagie.mp3
(Stored with Git LFS)
Normal file
Binary file not shown.
|
@ -143,7 +143,7 @@ void loop(void)
|
|||
}
|
||||
|
||||
stateMachine.update(Context(stations, sizeof(stations) / sizeof(stations[0]), deltaTime, &dfPlayer));
|
||||
String newContent = stateMachine.updateDisplay();
|
||||
String newContent = stateMachine.updateDisplay(Context(stations, sizeof(stations) / sizeof(stations[0]), deltaTime, &dfPlayer));
|
||||
if (previousDisplayContent != newContent)
|
||||
{
|
||||
lcd.clear();
|
||||
|
@ -182,5 +182,5 @@ void setup(void)
|
|||
}
|
||||
}
|
||||
|
||||
dfPlayer.volume(18);
|
||||
dfPlayer.volume(15);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#define HACKING_STATION_MAGIE 6
|
||||
#define PICKUP_STATION_MAGIE 7
|
||||
#define AFTER_MAGIE 8
|
||||
#define AFTER_MAGIE 17 // weird hack because file 8 does not seem to work...
|
||||
|
||||
#define HACKING_STATION_BICOLA 9
|
||||
#define PICKUP_STATION_BICOLA 10
|
||||
|
|
|
@ -21,6 +21,6 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
virtual String updateDisplay() { return ""; }
|
||||
virtual String updateDisplay(const Context& context) { return ""; }
|
||||
|
||||
};
|
||||
|
|
|
@ -3,36 +3,44 @@
|
|||
#include "context.h"
|
||||
|
||||
StateMachine::StateMachine(State* initialState)
|
||||
: currentState(initialState) {}
|
||||
|
||||
StateMachine::~StateMachine() {
|
||||
delete currentState;
|
||||
}
|
||||
|
||||
void StateMachine::updateState(State* newState, const Context& context) {
|
||||
if (newState != currentState) {
|
||||
delete currentState;
|
||||
currentState = newState;
|
||||
currentState->activated(context);
|
||||
}
|
||||
}
|
||||
|
||||
void StateMachine::pickedUp(const Context& context) {
|
||||
State* newState = currentState->pickedUp(context);
|
||||
updateState(newState, context);
|
||||
}
|
||||
|
||||
void StateMachine::putDown(const Context& context, Station* newStation) {
|
||||
State* newState = currentState->putDown(context, newStation);
|
||||
updateState(newState, context);
|
||||
}
|
||||
|
||||
void StateMachine::update(const Context& context) {
|
||||
State* newState = currentState->update(context);
|
||||
updateState(newState, context);
|
||||
}
|
||||
|
||||
String StateMachine::updateDisplay() const
|
||||
: currentState(initialState)
|
||||
{
|
||||
return currentState->updateDisplay();
|
||||
}
|
||||
|
||||
StateMachine::~StateMachine()
|
||||
{
|
||||
delete currentState;
|
||||
}
|
||||
|
||||
void StateMachine::updateState(State* newState, const Context& context)
|
||||
{
|
||||
if (newState != currentState)
|
||||
{
|
||||
delete currentState;
|
||||
currentState = newState;
|
||||
currentState->activated(context);
|
||||
}
|
||||
}
|
||||
|
||||
void StateMachine::pickedUp(const Context& context)
|
||||
{
|
||||
State* newState = currentState->pickedUp(context);
|
||||
updateState(newState, context);
|
||||
}
|
||||
|
||||
void StateMachine::putDown(const Context& context, Station* newStation)
|
||||
{
|
||||
State* newState = currentState->putDown(context, newStation);
|
||||
updateState(newState, context);
|
||||
}
|
||||
|
||||
void StateMachine::update(const Context& context)
|
||||
{
|
||||
State* newState = currentState->update(context);
|
||||
updateState(newState, context);
|
||||
}
|
||||
|
||||
String StateMachine::updateDisplay(const Context& context) const
|
||||
{
|
||||
return currentState->updateDisplay(context);
|
||||
}
|
||||
|
|
|
@ -17,5 +17,5 @@ public:
|
|||
void putDown(const Context& context, Station* newStation);
|
||||
void update(const Context& context);
|
||||
|
||||
String updateDisplay() const;
|
||||
String updateDisplay(const Context& context) const;
|
||||
};
|
||||
|
|
123
src/states.cpp
123
src/states.cpp
|
@ -1,10 +1,9 @@
|
|||
#include "states.h"
|
||||
|
||||
#include <sequences.h>
|
||||
|
||||
#include "state.h"
|
||||
#include "station.h"
|
||||
#include "sounds.h"
|
||||
#include "text.h"
|
||||
|
||||
Startup::Startup() = default;
|
||||
|
||||
|
@ -24,10 +23,9 @@ State* Startup::update(const Context context)
|
|||
return this;
|
||||
}
|
||||
|
||||
String Startup::updateDisplay()
|
||||
String Startup::updateDisplay(const Context& context)
|
||||
{
|
||||
return "Initializing:Put"
|
||||
"on first station";
|
||||
return "Legg mi uf die ersti Station!";
|
||||
}
|
||||
|
||||
void Startup::activated(Context context)
|
||||
|
@ -42,7 +40,7 @@ WaitingForGameStart::WaitingForGameStart() = default;
|
|||
|
||||
State* WaitingForGameStart::pickedUp(const Context context)
|
||||
{
|
||||
return new OnTheMove(context.stations + 1); // first element of the array
|
||||
return new OnTheMove(context.stations + 1, context.stations); // first element of the array
|
||||
}
|
||||
|
||||
State* WaitingForGameStart::update(const Context context)
|
||||
|
@ -50,10 +48,9 @@ State* WaitingForGameStart::update(const Context context)
|
|||
return this;
|
||||
}
|
||||
|
||||
String WaitingForGameStart::updateDisplay()
|
||||
String WaitingForGameStart::updateDisplay(const Context& context)
|
||||
{
|
||||
return "Waiting for Game"
|
||||
"Start...";
|
||||
return WAITING_FOR_START_TEXT;
|
||||
}
|
||||
|
||||
void WaitingForGameStart::activated(const Context context)
|
||||
|
@ -65,9 +62,10 @@ void WaitingForGameStart::activated(const Context context)
|
|||
//------------------------------------
|
||||
|
||||
|
||||
OnTheMove::OnTheMove(Station* targetStation)
|
||||
OnTheMove::OnTheMove(Station* targetStation, Station* previousStation)
|
||||
{
|
||||
this->targetStation = targetStation;
|
||||
this->previousStation = previousStation;
|
||||
}
|
||||
|
||||
State* OnTheMove::putDown(const Context context, Station* newStation)
|
||||
|
@ -81,7 +79,7 @@ State* OnTheMove::putDown(const Context context, Station* newStation)
|
|||
return new Hacking(this->targetStation);
|
||||
}
|
||||
|
||||
return new IncorrectStation(targetStation);
|
||||
return new IncorrectStation(targetStation, previousStation);
|
||||
}
|
||||
|
||||
State* OnTheMove::update(const Context context)
|
||||
|
@ -89,15 +87,41 @@ State* OnTheMove::update(const Context context)
|
|||
return this;
|
||||
}
|
||||
|
||||
String OnTheMove::updateDisplay()
|
||||
String OnTheMove::updateDisplay(const Context& context)
|
||||
{
|
||||
return "On the Move... ";
|
||||
const int index = context.getStationIndex(this->targetStation);
|
||||
if (index == 0)
|
||||
{
|
||||
return TOBIONE_AFTER_TEXT;
|
||||
}
|
||||
else if (index == 1)
|
||||
{
|
||||
return MAIN_AFTER_PICKUP_TEXT;
|
||||
}
|
||||
else if (index == 2)
|
||||
{
|
||||
return MUHVELLA_AFTER_TEXT;
|
||||
}
|
||||
else if (index == 3)
|
||||
{
|
||||
return MAGIE_AFTER_TEXT;
|
||||
}
|
||||
else if (index == 4)
|
||||
{
|
||||
return BICOLA_AFTER_TEXT;
|
||||
}
|
||||
|
||||
return "UNDEFINED";
|
||||
}
|
||||
|
||||
void OnTheMove::activated(const Context context)
|
||||
{
|
||||
const int index = context.getStationIndex(this->targetStation);
|
||||
if (index == 1)
|
||||
if (index == 0)
|
||||
{
|
||||
context.dfPlayer->play(AFTER_TOBIONE);
|
||||
}
|
||||
else if (index == 1)
|
||||
{
|
||||
context.dfPlayer->play(AFTER_MAIN_STATION);
|
||||
}
|
||||
|
@ -119,14 +143,15 @@ void OnTheMove::activated(const Context context)
|
|||
//------------------------------------
|
||||
|
||||
|
||||
IncorrectStation::IncorrectStation(Station* targetStation)
|
||||
IncorrectStation::IncorrectStation(Station* targetStation, Station* previousStation)
|
||||
{
|
||||
this->targetStation = targetStation;
|
||||
this->previousStation = previousStation;
|
||||
}
|
||||
|
||||
State* IncorrectStation::pickedUp(const Context context)
|
||||
{
|
||||
return new OnTheMove(this->targetStation); // todo fix nullptr
|
||||
return new OnTheMove(this->targetStation, previousStation);
|
||||
}
|
||||
|
||||
State* IncorrectStation::update(const Context context)
|
||||
|
@ -134,9 +159,9 @@ State* IncorrectStation::update(const Context context)
|
|||
return this;
|
||||
}
|
||||
|
||||
String IncorrectStation::updateDisplay()
|
||||
String IncorrectStation::updateDisplay(const Context& context)
|
||||
{
|
||||
return "Wrong Station! ";
|
||||
return WRONG_STATION_TEXT;
|
||||
}
|
||||
|
||||
void IncorrectStation::activated(const Context context)
|
||||
|
@ -174,9 +199,26 @@ State* Hacking::update(const Context context)
|
|||
return this;
|
||||
}
|
||||
|
||||
String Hacking::updateDisplay()
|
||||
String Hacking::updateDisplay(const Context& context)
|
||||
{
|
||||
return "Hacking B)";
|
||||
auto currentStationIndex = context.getStationIndex(this->currentStation);
|
||||
if (currentStationIndex == 1)
|
||||
{
|
||||
return MUHVELLA_HACKING_TEXT;
|
||||
}
|
||||
if (currentStationIndex == 2)
|
||||
{
|
||||
return MAGIE_HACKING_TEXT;
|
||||
}
|
||||
if (currentStationIndex == 3)
|
||||
{
|
||||
return BICOLA_HACKING_TEXT;
|
||||
}
|
||||
if (currentStationIndex == 4)
|
||||
{
|
||||
return TOBIONE_HACKING_TEXT;
|
||||
}
|
||||
return "UNDEFINED";
|
||||
}
|
||||
|
||||
void Hacking::activated(const Context context)
|
||||
|
@ -199,7 +241,7 @@ void Hacking::activated(const Context context)
|
|||
}
|
||||
if (currentStationIndex == 4)
|
||||
{
|
||||
timer = Timer(39000, false);
|
||||
timer = Timer(40000, false);
|
||||
context.dfPlayer->play(HACKING_STATION_TOBIONE);
|
||||
}
|
||||
timer.start();
|
||||
|
@ -228,9 +270,9 @@ State* Complain::update(Context context)
|
|||
return this;
|
||||
}
|
||||
|
||||
String Complain::updateDisplay()
|
||||
String Complain::updateDisplay(const Context& context)
|
||||
{
|
||||
return "Put me back!!";
|
||||
return COMPLAIN_TEXT;
|
||||
}
|
||||
|
||||
void Complain::activated(Context context)
|
||||
|
@ -249,7 +291,7 @@ WaitingForPickup::WaitingForPickup(Station* currentStation, Station* targetStati
|
|||
|
||||
State* WaitingForPickup::pickedUp(Context context)
|
||||
{
|
||||
return new OnTheMove(targetStation);
|
||||
return new OnTheMove(targetStation, currentStation);
|
||||
}
|
||||
|
||||
State* WaitingForPickup::update(Context context)
|
||||
|
@ -257,9 +299,25 @@ State* WaitingForPickup::update(Context context)
|
|||
return this;
|
||||
}
|
||||
|
||||
String WaitingForPickup::updateDisplay()
|
||||
String WaitingForPickup::updateDisplay(const Context& context)
|
||||
{
|
||||
return "Pick me up ";
|
||||
auto currentStationIndex = context.getStationIndex(this->currentStation);
|
||||
if (currentStationIndex == 1)
|
||||
{
|
||||
return MUHVELLA_PICKUP_TEXT;
|
||||
}
|
||||
if (currentStationIndex == 2)
|
||||
{
|
||||
return MAGIE_PICKUP_TEXT;
|
||||
}
|
||||
if (currentStationIndex == 3)
|
||||
{
|
||||
return BICOLA_PICKUP_TEXT;
|
||||
}
|
||||
if (currentStationIndex == 4)
|
||||
{
|
||||
return TOBIONE_PICKUP_TEXT;
|
||||
}
|
||||
}
|
||||
|
||||
void WaitingForPickup::activated(Context context)
|
||||
|
@ -293,13 +351,13 @@ End::End(): timer(Timer(0, false))
|
|||
|
||||
State* End::pickedUp(const Context context)
|
||||
{
|
||||
// todo to be discussed if this is the expected outcome...
|
||||
return new OnTheMove(context.stations + 1); // starting game early
|
||||
// todo complain
|
||||
return new Complain(context.stations);
|
||||
}
|
||||
|
||||
State* End::update(const Context context)
|
||||
{
|
||||
bool done = timer.update(context.delta);
|
||||
const bool done = timer.update(context.delta);
|
||||
if (done)
|
||||
{
|
||||
return new WaitingForGameStart();
|
||||
|
@ -307,13 +365,14 @@ State* End::update(const Context context)
|
|||
return this;
|
||||
}
|
||||
|
||||
String End::updateDisplay()
|
||||
String End::updateDisplay(const Context& context)
|
||||
{
|
||||
return "END...";
|
||||
return END_TEXT;
|
||||
}
|
||||
|
||||
void End::activated(const Context context)
|
||||
{
|
||||
context.dfPlayer->play(END);
|
||||
timer = Timer(27000, false);
|
||||
timer = Timer(38000, false);
|
||||
timer.start();
|
||||
}
|
||||
|
|
24
src/states.h
24
src/states.h
|
@ -12,7 +12,7 @@ public:
|
|||
Startup();
|
||||
State* putDown(Context context, Station* newStation) override;
|
||||
State* update(Context context) override;
|
||||
String updateDisplay() override;
|
||||
String updateDisplay(const Context& context) override;
|
||||
void activated(Context context) override;
|
||||
};
|
||||
|
||||
|
@ -23,7 +23,7 @@ public:
|
|||
WaitingForGameStart();
|
||||
State* pickedUp(Context context) override;
|
||||
State* update(Context context) override;
|
||||
String updateDisplay() override;
|
||||
String updateDisplay(const Context& context) override;
|
||||
void activated(Context context) override;
|
||||
};
|
||||
|
||||
|
@ -31,12 +31,13 @@ class OnTheMove final : public State
|
|||
{
|
||||
private:
|
||||
Station* targetStation;
|
||||
|
||||
Station* previousStation;
|
||||
|
||||
public:
|
||||
explicit OnTheMove(Station* targetStation);
|
||||
explicit OnTheMove(Station* targetStation, Station* previousStation);
|
||||
State* putDown(Context context, Station* newStation) override;
|
||||
State* update(Context context) override;
|
||||
String updateDisplay() override;
|
||||
String updateDisplay(const Context& context) override;
|
||||
void activated(Context context) override;
|
||||
};
|
||||
|
||||
|
@ -44,12 +45,13 @@ class IncorrectStation final : public State
|
|||
{
|
||||
private:
|
||||
Station* targetStation;
|
||||
Station* previousStation;
|
||||
|
||||
public:
|
||||
explicit IncorrectStation(Station* targetStation);
|
||||
explicit IncorrectStation(Station* targetStation, Station* previousStation);
|
||||
State* pickedUp(Context context) override;
|
||||
State* update(Context context) override;
|
||||
String updateDisplay() override;
|
||||
String updateDisplay(const Context& context) override;
|
||||
void activated(Context context) override;
|
||||
};
|
||||
|
||||
|
@ -64,7 +66,7 @@ public:
|
|||
explicit Hacking(Station* currentStation);
|
||||
State* pickedUp(Context context) override;
|
||||
State* update(Context context) override;
|
||||
String updateDisplay() override;
|
||||
String updateDisplay(const Context& context) override;
|
||||
void activated(Context context) override;
|
||||
};
|
||||
|
||||
|
@ -77,7 +79,7 @@ public:
|
|||
explicit Complain(Station* currentStation);
|
||||
State* putDown(Context context, Station* newStation) override;
|
||||
State* update(Context context) override;
|
||||
String updateDisplay() override;
|
||||
String updateDisplay(const Context& context) override;
|
||||
void activated(Context context) override;
|
||||
};
|
||||
|
||||
|
@ -91,7 +93,7 @@ public:
|
|||
WaitingForPickup(Station* currentStation, Station* targetStation);
|
||||
State* pickedUp(Context context) override;
|
||||
State* update(Context context) override;
|
||||
String updateDisplay() override;
|
||||
String updateDisplay(const Context& context) override;
|
||||
void activated(Context context) override;
|
||||
};
|
||||
|
||||
|
@ -103,6 +105,6 @@ public:
|
|||
End();
|
||||
State* pickedUp(Context context) override;
|
||||
State* update(Context context) override;
|
||||
String updateDisplay() override;
|
||||
String updateDisplay(const Context& context) override;
|
||||
void activated(Context context) override;
|
||||
};
|
||||
|
|
29
src/text.h
Normal file
29
src/text.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
#pragma once
|
||||
|
||||
#define WAITING_FOR_START_TEXT "Lupf mich uf"
|
||||
#define MAIN_AFTER_PICKUP_TEXT "Danke :D <3 Lueg chli ume"
|
||||
|
||||
#define MUHVELLA_HACKING_TEXT "Eifach ligge lahBitte warte"
|
||||
#define MUHVELLA_PICKUP_TEXT "Los! Witer =O"
|
||||
#define MUHVELLA_AFTER_TEXT "Ufd Suechi! Gids Suppe? :P"
|
||||
|
||||
#define MAGIE_HACKING_TEXT "Wart rasch ^^ "
|
||||
#define MAGIE_PICKUP_TEXT "Und witer gahts "
|
||||
#define MAGIE_AFTER_TEXT "Yoga und Chrueter? :/"
|
||||
|
||||
#define BICOLA_HACKING_TEXT "Mues chli sueche"
|
||||
#define BICOLA_PICKUP_TEXT "Und witer!"
|
||||
#define BICOLA_AFTER_TEXT "Fast gschafft :,)"
|
||||
|
||||
#define TOBIONE_HACKING_TEXT "So nah und doch so fern -.-"
|
||||
#define TOBIONE_PICKUP_TEXT "Endspurt!"
|
||||
#define TOBIONE_AFTER_TEXT "goi mer wieder hei"
|
||||
|
||||
#define WRONG_STATION_TEXT "falschi Station"
|
||||
#define COMPLAIN_TEXT "Wieder zrug stelle"
|
||||
|
||||
#define END_TEXT "DU HESCH ES GSCHAFFT!!!"
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in a new issue