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

Loading…
Cancel
Save