Add sounds and start implementing the triggers for them

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 4e5a0eef43
commit 559d2b1752
  1. 187
      SeasonsOfLoneliness.cpp
  2. BIN
      Seasons_of_Loneliness
  3. BIN
      Seasons_of_Loneliness.wasm
  4. BIN
      assets/IntroFinal.wav
  5. BIN
      assets/SeasonsOfLoneliness.wav
  6. BIN
      assets/battle.wav
  7. BIN
      assets/card_flip.wav
  8. BIN
      assets/dome.wav
  9. BIN
      assets/explode.wav
  10. BIN
      assets/explore.wav
  11. BIN
      assets/finalBattle.wav
  12. BIN
      assets/laserShoot.wav
  13. BIN
      assets/msg.wav
  14. BIN
      assets/roboticNoise.wav
  15. BIN
      assets/saw.wav
  16. BIN
      assets/select.wav
  17. BIN
      assets/sonar.wav
  18. BIN
      assets/warning.wav
  19. BIN
      assets/weatherHeavy.wav
  20. BIN
      assets/weatherLight.wav
  21. 2
      data.h

@ -12,15 +12,15 @@ using namespace olc;
//#define TEST_MAP1 //Toggle to just play around on map 1.
//#define TEST_MAP2 //Toggle on to just play around on map 2.
#define SKIP_INTRO true
#define SKIP_CHAPTER1 true
#define SKIP_BOSS true
#define SKIP_SILICON2 true
#define SKIP_CHAPTER2 true
#define SKIP_STORYBOOK true
#define SKIP_CHAPTER3 true
#define SKIP_LAUNCHPAD true
#define SKIP_A_A true
#define SKIP_INTRO false
#define SKIP_CHAPTER1 false
#define SKIP_BOSS false
#define SKIP_SILICON2 false
#define SKIP_CHAPTER2 false
#define SKIP_STORYBOOK false
#define SKIP_CHAPTER3 false
#define SKIP_LAUNCHPAD false
#define SKIP_A_A false
#define STARTING_MAP MAP_1
#define STARTING_STATE CUTSCENE_3
@ -387,6 +387,7 @@ class Entity{
bool ally=false;
int hp;
int startingHP;
Decal*startingspr;
int maxhp;
Decal*spr;
float x;
@ -405,7 +406,7 @@ class Entity{
bool hidden=false; //If hidden, this enemy will take 0 damage.
int shield=0; //If shield is greater than 0, the shield must be depleted first before health can be dealt.
Entity(Decal*spr,std::string name,float x,float y,int hp,int maxhp,std::vector<WEATHER_POWER*>moveset,vf2d sprScale={1,1},bool fixedMoveset=false) {
this->spr=spr;
this->spr=this->startingspr=spr;
this->name=name;
this->x=x;
this->y=y;
@ -672,6 +673,7 @@ public:
Pixel SHIP_COLOR=WHITE;
vf2d BOSS_SIZE={1,1};
vf2d CREDITS_SCROLLING_OFFSET={0,12};
bool HIDE_CARDS=false;
Map*MAP_1=new Map("map1");
Map*MAP_2=new Map("map2");
@ -722,11 +724,13 @@ public:
PlayerState*PREV_PLAYERSTATE=new PlayerState();
int WALK_STEPS=0;
int PETRIFY_TURNS=0;
int LAST_FRAME_SOUND_PLAYED=0;
Map*CURRENT_MAP=MAP_1;
sound::Wave SONG_MAIN;
sound::Wave SONG_MAIN,SONG_BATTLE,SONG_FINALBATTLE,SONG_EXPLORE,SONG_DOME;
sound::Wave SOUND_MSG,SOUND_CHANGE_OPTION,SOUND_ROBOTICNOISE,SOUND_SELECT,SOUND_SAW,SOUND_SONAR,SOUND_WARNING,SOUND_EXPLODE,SOUND_LASERSHOOT,SOUND_WEATHERHEAVY,SOUND_WEATHERLIGHT;
std::queue<int> turnOrder;
@ -734,6 +738,8 @@ public:
effect::Pixel*pixels[MAX_PIXELS];
effect::Pixel*starpixels[150];
sound::PlayingWave CURRENT_BGM;
bool OnUserCreate() override
{
SetPixelMode(Pixel::ALPHA);
@ -798,6 +804,21 @@ public:
}
SONG_MAIN = sound::Wave("./assets/SeasonsOfLoneliness.wav");
SONG_BATTLE = sound::Wave("./assets/battle.wav");
SONG_FINALBATTLE = sound::Wave("./assets/finalBattle.wav");
SONG_EXPLORE = sound::Wave("./assets/explore.wav");
SONG_DOME = sound::Wave("./assets/dome.wav");
SOUND_MSG = sound::Wave("./assets/msg.wav");
SOUND_CHANGE_OPTION = sound::Wave("./assets/card_flip.wav");
SOUND_ROBOTICNOISE = sound::Wave("./assets/roboticNoise.wav");
SOUND_SELECT = sound::Wave("./assets/select.wav");
SOUND_SAW = sound::Wave("./assets/saw.wav");
SOUND_SONAR = sound::Wave("./assets/sonar.wav");
SOUND_WARNING = sound::Wave("./assets/warning.wav");
SOUND_EXPLODE = sound::Wave("./assets/explode.wav");
SOUND_LASERSHOOT = sound::Wave("./assets/laserShoot.wav");
SOUND_WEATHERHEAVY = sound::Wave("./assets/weatherHeavy.wav");
SOUND_WEATHERLIGHT = sound::Wave("./assets/weatherLight.wav");
//ConsoleShow(F1,false);
// Called once at the start, so create things here
@ -1201,6 +1222,9 @@ public:
ZONES.push_back(SILICON_DEPOSIT_ZONE);
ResetTerminal(STORY_TEXT2);
for (int i=0;i<MAX_PIXELS;i++) {
pixels[i]=new effect::Pixel();
}
@ -1274,6 +1298,7 @@ public:
if (getPlantStatus((int)PLAYER_COORDS[0],(int)PLAYER_COORDS[1])==2) {
setPlantStatus((int)PLAYER_COORDS[0],(int)PLAYER_COORDS[1],0);
foodCount++;
PlaySound(&SOUND_SELECT,false,0.6);
}
}
}break;
@ -1283,6 +1308,7 @@ public:
switch (MAIN_MENU_SELECTION) {
case 0:
case 1:{
PlaySound(&SOUND_SELECT);
fadeOut();
audioFadeOut();
}break;
@ -1335,13 +1361,16 @@ public:
if (TERMINAL_INPUT.length()==MAX_TERMINAL_NAME_LENGTH) {
TERMINAL_SELECTED_CHAR=27;
}
PlaySound(&SOUND_CHANGE_OPTION);
} else
if (TERMINAL_SELECTED_CHAR==26&&TERMINAL_INPUT.length()>0) {
TERMINAL_INPUT.erase(TERMINAL_INPUT.length()-1);
PlaySound(&SOUND_SELECT,false,0.3);
} else
if (TERMINAL_SELECTED_CHAR==27&&TERMINAL_INPUT.length()>0) {
PLAYER_NAME=TERMINAL_INPUT;
PlayCutscene(cutscene::GO_OUTSIDE);
PlaySound(&SOUND_SELECT);
}
}break;
case cutscene::READY_TO_BOARD:{
@ -1445,9 +1474,11 @@ public:
if (MAIN_MENU_SELECTION<0) {
MAIN_MENU_SELECTION=3;
}
PlaySound(&SOUND_CHANGE_OPTION);
}
if (GetKey(D).bPressed||GetKey(RIGHT).bPressed||GetKey(NP6).bPressed||GetKey(S).bPressed||GetKey(DOWN).bPressed||GetKey(NP5).bPressed||GetKey(NP2).bPressed) {
MAIN_MENU_SELECTION=(MAIN_MENU_SELECTION+1)%4;
PlaySound(&SOUND_CHANGE_OPTION);
}
}
switch (CURRENT_CUTSCENE) {
@ -1457,6 +1488,7 @@ public:
if (TERMINAL_SELECTED_CHAR<0) {
TERMINAL_SELECTED_CHAR+=28;
}
PlaySound(&SOUND_MSG);
}
if (GetKey(D).bPressed||GetKey(RIGHT).bPressed||GetKey(NP6).bPressed) {
if ((TERMINAL_SELECTED_CHAR+1)%7==0) {
@ -1464,6 +1496,7 @@ public:
} else {
TERMINAL_SELECTED_CHAR++;
}
PlaySound(&SOUND_MSG);
}
if (GetKey(A).bPressed||GetKey(LEFT).bPressed||GetKey(NP4).bPressed) {
if ((TERMINAL_SELECTED_CHAR-1)%7==6||TERMINAL_SELECTED_CHAR-1<0) {
@ -1471,6 +1504,7 @@ public:
} else {
TERMINAL_SELECTED_CHAR--;
}
PlaySound(&SOUND_MSG);
}
if (GetKey(S).bPressed||GetKey(DOWN).bPressed||GetKey(NP5).bPressed||GetKey(NP2).bPressed) {
if (TERMINAL_SELECTED_CHAR+7>=28) {
@ -1478,6 +1512,7 @@ public:
} else {
TERMINAL_SELECTED_CHAR+=7;
}
PlaySound(&SOUND_MSG);
}
}break;
case cutscene::READY_TO_BOARD:{
@ -1512,6 +1547,7 @@ public:
case CUTSCENE_3:{
GAME_STATE=CUTSCENE_1;
fadeIn();
stopMusic();
ResetTerminal(STORY_TEXT1);
}break;
case CUTSCENE_4:{
@ -1605,6 +1641,7 @@ public:
GAME_FLAGS[gameflag::VISIT_BROKEN_ROVER]=true;
PlayCutscene(cutscene::WALK_TO_ROVER);
}
playMusic(&SONG_EXPLORE);
}break;
case cutscene::TRANSITION_CUTSCENE_2:{
if (GAME_FLAGS[gameflag::ROCKET_LAUNCH_READY]&&!GAME_FLAGS[gameflag::COLLECTED_ITEMS_IN_DOME]) {
@ -1650,6 +1687,7 @@ public:
GAME_FLAGS[gameflag::CHECK_ROVER]=true;
DisplayMessageBox(26);
}
playMusic(&SONG_DOME);
}break;
case cutscene::DISPLAY_VOLCANIC_AREA:{
TeleportToMapFileCoords(13,122);
@ -1703,6 +1741,7 @@ public:
}break;
case cutscene::READY_TO_BOARD:{
GAME_STATE=IN_SPACE;
TIMER=0;
fadeIn();
EndCutscene();
}break;
@ -1774,6 +1813,7 @@ public:
}break;
case cutscene::CUTSCENE_4:{
LoadMap(MAP_2);
playMusic(&SONG_DOME);
PLAYER_COORDS[0]=16;
PLAYER_COORDS[1]=6;
updatePlayerState();
@ -1818,7 +1858,7 @@ public:
audioLevel-=0.01;
engine.SetOutputVolume(audioLevel);
} else
if (!audioFade&&audioLevel<0.6) {
if (!audioFade&&audioLevel<0.6&&!SOUND_IS_MUTED) {
audioLevel+=0.01;
engine.SetOutputVolume(audioLevel);
}
@ -1873,7 +1913,7 @@ public:
bool animationchanged=false;
bool positionModified=false;
if (GetKey(D).bHeld||GetKey(RIGHT).bHeld||GetKey(NP6).bHeld) {
if (MAP[(int)PLAYER_COORDS[1]][(int)std::clamp(PLAYER_COORDS[0]+MOVE_SPD,0.1,(double)MAP_WIDTH)]!=4) {
if (GAME_STATE!=IN_SPACE&&MAP[(int)PLAYER_COORDS[1]][(int)std::clamp(PLAYER_COORDS[0]+MOVE_SPD,0.1,(double)MAP_WIDTH)]!=4) {
PLAYER_COORDS[0]=std::clamp(PLAYER_COORDS[0]+MOVE_SPD,0.1,(double)MAP_WIDTH);
positionModified=true;
}
@ -1885,7 +1925,7 @@ public:
}
}
if (GetKey(A).bHeld||GetKey(LEFT).bHeld||GetKey(NP4).bHeld) {
if (MAP[(int)PLAYER_COORDS[1]][(int)std::clamp(PLAYER_COORDS[0]-MOVE_SPD,0.1,(double)MAP_WIDTH)]!=4) {
if (GAME_STATE!=IN_SPACE&&MAP[(int)PLAYER_COORDS[1]][(int)std::clamp(PLAYER_COORDS[0]-MOVE_SPD,0.1,(double)MAP_WIDTH)]!=4) {
PLAYER_COORDS[0]=std::clamp(PLAYER_COORDS[0]-MOVE_SPD,0.1,(double)MAP_WIDTH);
positionModified=true;
}
@ -1897,7 +1937,7 @@ public:
}
}
if (GetKey(W).bHeld||GetKey(UP).bHeld||GetKey(NP8).bHeld) {
if (MAP[(int)std::clamp(PLAYER_COORDS[1]-MOVE_SPD,0.1,(double)MAP_HEIGHT)][(int)PLAYER_COORDS[0]]!=4) {
if (GAME_STATE!=IN_SPACE&&MAP[(int)std::clamp(PLAYER_COORDS[1]-MOVE_SPD,0.1,(double)MAP_HEIGHT)][(int)PLAYER_COORDS[0]]!=4) {
PLAYER_COORDS[1]=std::clamp(PLAYER_COORDS[1]-MOVE_SPD,0.1,(double)MAP_HEIGHT);
positionModified=true;
}
@ -1907,9 +1947,14 @@ public:
changeAnimation(playerAnimWalkUp);
animationchanged=true;
}
if (!messageBoxVisible&&BATTLE_STATE==battle::PLAYER_SELECTION) {
HIDE_CARDS=true;
}
} else {
HIDE_CARDS=false;
}
if (GetKey(S).bHeld||GetKey(DOWN).bHeld||GetKey(NP5).bHeld||GetKey(NP2).bHeld) {
if (MAP[(int)std::clamp(PLAYER_COORDS[1]+MOVE_SPD,0.1,(double)MAP_HEIGHT)][(int)PLAYER_COORDS[0]]!=4) {
if (GAME_STATE!=IN_SPACE&&MAP[(int)std::clamp(PLAYER_COORDS[1]+MOVE_SPD,0.1,(double)MAP_HEIGHT)][(int)PLAYER_COORDS[0]]!=4) {
PLAYER_COORDS[1]=std::clamp(PLAYER_COORDS[1]+MOVE_SPD,0.1,(double)MAP_HEIGHT);
positionModified=true;
}
@ -2302,21 +2347,6 @@ public:
CURRENT_ENCOUNTER.entities[BATTLE_CURRENT_TURN_ENTITY]->hidden=true;
}
}
if (ref->appliesPetrification) {
if (BATTLE_CURRENT_TURN_ENTITY==-1) {
//Not implemented for the player.
} else {
PETRIFY_TURNS=3;
}
}
if (ref->appliesRadioactive) {
if (BATTLE_CURRENT_TURN_ENTITY==-1) {
//Not implemented for the player.
} else {
SEEDS.clear();
TREES.clear();
}
}
if (EFFECT_TIMER>ref->effectTime) {
EFFECT_TIMER=0;
clearPixelEffect();
@ -2332,6 +2362,14 @@ public:
BATTLE_REASON_CODE=reasoncode::DROUGHT;
BATTLE_STATE=battle::WAIT_TURN_ANIMATION2;
BATTLE_DROUGHT_ACTIVE=true;
} else
if (ref->appliesRadioactive&&(SEEDS.size()>0||TREES.size()>0)) {
BATTLE_REASON_CODE=reasoncode::RADIOACTIVE;
BATTLE_STATE=battle::WAIT_TURN_ANIMATION2;
} else
if (ref->appliesPetrification) {
BATTLE_REASON_CODE=reasoncode::PETRIFIED;
BATTLE_STATE=battle::WAIT_TURN_ANIMATION2;
} else {
BATTLE_REASON_CODE=-1;
BATTLE_STATE=battle::DAMAGE_RESOLUTION;
@ -2375,6 +2413,21 @@ public:
}
clearTrees();
}break;
case reasoncode::RADIOACTIVE:{
if (BATTLE_CURRENT_TURN_ENTITY==-1) {
//Not implemented for the player.
} else {
SEEDS.clear();
TREES.clear();
}
}break;
case reasoncode::PETRIFIED:{
if (BATTLE_CURRENT_TURN_ENTITY==-1) {
//Not implemented for the player.
} else {
PETRIFY_TURNS=3;
}
}break;
}
}
if (EFFECT_TIMER==WAIT_THRESHOLD*2) {
@ -2390,6 +2443,11 @@ public:
if (BATTLE_CURRENT_TURN_ENTITY==-1) {
BATTLE_DROUGHT_ACTIVE=false;
std::cout<<"Drought turned off.\n";
for (int i=0;i<WEATHER_POWER_COUNT;i++) {
if (WEATHER_POWERS[i]->name.compare("Snack")==0||WEATHER_POWERS[i]->name.compare("Meal")==0) {
WEATHER_POWERS[i]->playerOwnCount=foodCount;
}
}
} else {
if (CURRENT_ENCOUNTER.entities[BATTLE_CURRENT_TURN_ENTITY]->lastSlowVal==CURRENT_ENCOUNTER.entities[BATTLE_CURRENT_TURN_ENTITY]->speed&&
CURRENT_ENCOUNTER.entities[BATTLE_CURRENT_TURN_ENTITY]->speed!=0&&rand()%3==0) {
@ -2507,11 +2565,6 @@ public:
BATTLE_STATE=battle::WAIT_TURN_ANIMATION;
PIXEL_EFFECT_TRANSPARENCY=0;
EFFECT_TIMER=0;
for (int i=0;i<WEATHER_POWER_COUNT;i++) {
if (WEATHER_POWERS[i]->name.compare("Snack")==0||WEATHER_POWERS[i]->name.compare("Meal")==0) {
WEATHER_POWERS[i]->playerOwnCount=foodCount;
}
}
}
}
}break;
@ -2546,6 +2599,7 @@ public:
}
if (MoveCameraTowardsPoint(GetMapFileCoords(7,11))) {
PlayCutscene(cutscene::RAINING_IN_DOME);
PlaySound(&SOUND_WEATHERLIGHT);
}
}break;
case cutscene::RAINING_IN_DOME:{
@ -2875,7 +2929,7 @@ public:
DisplayMessageBox(45);
} else {
PLAYER_COORDS[0]=CUTSCENE_OBJS[0]->x;
PLAYER_COORDS[1]=CUTSCENE_OBJS[1]->y;
PLAYER_COORDS[1]=CUTSCENE_OBJS[0]->y;
current_playerAnim=playerAnimLeft;
EndCutscene();
}
@ -3077,8 +3131,7 @@ public:
}
if (GAME_STATE==CUTSCENE_3&&!SOUND_IS_PLAYING) {
engine.SetOutputVolume(0.6);
engine.PlayWaveform(&SONG_MAIN,true);
playMusic(&SONG_MAIN);
SOUND_IS_PLAYING=true;
}
@ -3089,6 +3142,22 @@ public:
case CUTSCENE_5:
case CUTSCENE_6:
case GAME_OVER_TERMINAL:{
int soundFrequency=-1;
if (GAME_STATE==CUTSCENE_1) {
soundFrequency=160;
} else
if (GAME_STATE==CUTSCENE_4) {
soundFrequency=120;
} else
if (GAME_STATE==CUTSCENE_5) {
soundFrequency=80;
} else
if (GAME_STATE==CUTSCENE_6) {
soundFrequency=70;
}
if (soundFrequency!=-1&&frameCount%soundFrequency==0) {
PlaySound(&SOUND_SONAR);
}
if (GAME_STATE==CUTSCENE_3&&frameCount%4!=0) {break;}
if (textInd<CONSOLE_REF_TEXT.length()) {
char c = CONSOLE_REF_TEXT[textInd++];
@ -3239,6 +3308,9 @@ public:
}
void advanceMessageBox() {
if (frameCount%4==0) {
PlaySound(&SOUND_MSG);
}
char c = messageBoxRefText[messageBoxCursor++];
printf("%c",c);
if (c=='\n') {
@ -3400,7 +3472,6 @@ public:
DrawDecal({(float)(WIDTH/2-BOOK2_DECAL->sprite->width*2/2),(float)(HEIGHT/2-BOOK2_DECAL->sprite->height*2/2)},BOOK2_DECAL,{2,2});
}break;
case IN_SPACE:{
SetDrawTarget(2);
Clear(BLACK);
DrawStars();
if (!IN_BATTLE_ENCOUNTER) {
@ -3437,10 +3508,12 @@ public:
}
switch (BATTLE_STATE) {
case battle::PLAYER_SELECTION:{
SetDrawTarget(nullptr);
DrawCard(availablePowers[(BATTLE_CARD_SELECTION_IND+1)%availablePowers.size()],{WIDTH-96,32},{0.7,0.7},0.4);
DrawCard(availablePowers[(BATTLE_CARD_SELECTION_IND-1<0)?availablePowers.size()-1:BATTLE_CARD_SELECTION_IND-1],{-96,32},{0.7,0.7},0.4);
DrawCard(BATTLE_CARD_SELECTION);
if (!HIDE_CARDS) {
SetDrawTarget(nullptr);
DrawCard(availablePowers[(BATTLE_CARD_SELECTION_IND+1)%availablePowers.size()],{WIDTH-96,32},{0.7,0.7},0.4);
DrawCard(availablePowers[(BATTLE_CARD_SELECTION_IND-1<0)?availablePowers.size()-1:BATTLE_CARD_SELECTION_IND-1],{-96,32},{0.7,0.7},0.4);
DrawCard(BATTLE_CARD_SELECTION);
}
}break;
case battle::PLAYER_TARGET_SELECTION:{
if (PLAYER_SELECTED_TARGET>=0) {
@ -3714,6 +3787,27 @@ public:
void audioFadeIn() {
audioFade=false;
}
sound::PlayingWave playMusic(sound::Wave*sound,bool loop=true,float spd=1) {
audioFadeIn();
if (SOUND_IS_PLAYING) {
stopMusic();
}
SOUND_IS_PLAYING=true;
CURRENT_BGM=engine.PlayWaveform(sound,loop,spd);
return CURRENT_BGM;
}
void PlaySound(sound::Wave* sound,bool loop=false,float spd=1) {
audioFadeIn();
if (LAST_FRAME_SOUND_PLAYED!=frameCount) {
engine.PlayWaveform(sound,loop,spd);
LAST_FRAME_SOUND_PLAYED=frameCount;
}
}
void stopMusic() {
engine.StopWaveform(CURRENT_BGM);
SOUND_IS_PLAYING=false;
}
void StopCutscene() {
EndCutscene();
@ -4401,6 +4495,11 @@ public:
ResetTerminal(STORY_TEXT4+PLAYER_NAME+STORY_TEXT5);
for (int i=0;i<CURRENT_ENCOUNTER.entities.size();i++) {
CURRENT_ENCOUNTER.entities[i]->hp=CURRENT_ENCOUNTER.entities[i]->startingHP;
CURRENT_ENCOUNTER.entities[i]->spr=CURRENT_ENCOUNTER.entities[i]->startingspr;
CURRENT_ENCOUNTER.entities[i]->fixedTurnOrderInd=0;
CURRENT_ENCOUNTER.entities[i]->hidden=false;
CURRENT_ENCOUNTER.entities[i]->turnComplete=false;
CURRENT_ENCOUNTER.entities[i]->speed=0;
}
resetBattleState();
fadeOut();

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -88,7 +88,7 @@ std::string CREDITS_TEXT=R"(
std::string THANKS_TEXT=R"(
Thanks
for
playing!)";
Playing!)";
std::string STORY_DIALOG[]={R"(
???

Loading…
Cancel
Save