#define OLC_PGE_APPLICATION #include "pixelGameEngine.h" #define OLC_SOUNDWAVE #include "soundExtension.h" using namespace std; class EarthboundBattleSim : public olc::PixelGameEngine { public: EarthboundBattleSim() { sAppName = "EarthboundBattleSim"; } public: int frameCount=0; float accumulatedTime=0; const float UPDATE_RATE=1/60.0F; char partyMemberCount=1; olc::sound::WaveEngine engine; olc::sound::Wave se1; olc::Decal*rollingCounter; char*player_name[4] = {"NESS","PAULA","JEFF","POO"}; int player_hp[4] = {120,74,105,96}; int player_pp[4] = {46,87,0,50}; int player_rollhp[4] = {player_hp[0],player_hp[1],player_hp[2],player_hp[3]}; int player_rollpp[4] = {player_pp[0],player_pp[1],player_pp[2],player_pp[3]}; int player_rollhp_display[4][3] = {{player_hp[0]%10,player_hp[0]/10%10,player_hp[0]/100%10},{player_hp[1]%10,player_hp[1]/10%10,player_hp[1]/100%10},{player_hp[2]%10,player_hp[2]/10%10,player_hp[2]/100%10},{player_hp[3]%10,player_hp[3]/10%10,player_hp[3]/100%10}}; int player_rollpp_display[4][3] = {{player_pp[0]%10,player_pp[0]/10%10,player_pp[0]/100%10},{player_pp[1]%10,player_pp[1]/10%10,player_pp[1]/100%10},{player_pp[2]%10,player_pp[2]/10%10,player_pp[2]/100%10},{player_pp[3]%10,player_pp[3]/10%10,player_pp[3]/100%10}}; int player_rollhp_counter[4][3] = {{0,0,0},{0,0,0},{0,0,0},{0,0,0}}; int player_rollpp_counter[4][3] = {{0,0,0},{0,0,0},{0,0,0},{0,0,0}}; bool OnUserCreate() override { SetPixelMode(olc::Pixel::ALPHA); rollingCounter = new olc::Decal(new olc::Sprite("assets/rollingcounter.png")); //ConsoleCaptureStdOut(true); // Called once at the start, so create things here engine.InitialiseAudio(); engine.SetOutputVolume(0.1f); se1.LoadAudioWaveform("./assets/sample-9s.wav"); player_hp[0]=30; //WriteEmscriptenFile("test","Test?\nThis has more\nthan two lines!"); return true; } bool OnUserUpdate(float fElapsedTime) override { Clear(olc::BLACK); accumulatedTime+=fElapsedTime; while (accumulatedTime>=UPDATE_RATE) { accumulatedTime-=UPDATE_RATE; updateGame(); //DO NOT ADD THINGS HERE. USE updateGame()! } if (GetKey(olc::RIGHT).bPressed) { partyMemberCount=min(partyMemberCount+1,4); } if (GetKey(olc::LEFT).bPressed) { partyMemberCount=max(partyMemberCount-1,1); } drawGame(); // called once per frame return true; } void updateGame(){ frameCount++; if (frameCount==180) { std::vector data = ReadEmscriptenFile("test"); for (int i=0;iplayer_hp[i]) { if (player_rollhp_counter[i][0]<=0) { player_rollhp_display[i][0]--; player_rollhp_counter[i][0]=13; player_rollhp[i]--; if (player_rollhp_display[i][0]<0) { player_rollhp_display[i][0]=9; player_rollhp_counter[i][0]=13; player_rollhp_display[i][1]--; player_rollhp_counter[i][1]=13; if (player_rollhp_display[i][1]<0) { player_rollhp_display[i][1]=9; player_rollhp_counter[i][1]=13; player_rollhp_display[i][2]--; player_rollhp_counter[i][2]=13; } } } } else if (player_rollhp[i]0) { player_rollhp_counter[i][0]-=3; } if (player_rollhp_counter[i][1]>0) { player_rollhp_counter[i][1]--; } if (player_rollhp_counter[i][2]>0) { player_rollhp_counter[i][2]--; } } } void drawBox(const olc::vi2d &pos, const olc::vi2d &size, olc::Pixel p = olc::WHITE, olc::Pixel p2 = olc::DARK_GREY, olc::Pixel p3 = olc::VERY_DARK_GREY) { FillRectDecal({(float)(pos.x+3),(float)(pos.y+3)},{(float)(size.x-5),(float)(size.y-5)},p); DrawRect({pos.x,pos.y},size,p2); DrawRect({pos.x+2,pos.y+2},{size.x-4,size.y-4},p3); DrawRect({pos.x+1,pos.y+1},{size.x-2,size.y-2},p); Draw({pos.x,pos.y},olc::BLACK); Draw({pos.x+size.x,pos.y+size.y},olc::BLACK); Draw({pos.x+size.x,pos.y},olc::BLACK); Draw({pos.x,pos.y+size.y},olc::BLACK); } void drawCheckerboardBox(const olc::vi2d &pos, const olc::vi2d &size, olc::Pixel p = olc::WHITE, olc::Pixel alternatingCol = olc::WHITE, const olc::vi2d &checkerboardSize = {3,3}, olc::Pixel p2 = olc::DARK_GREY, olc::Pixel p3 = olc::VERY_DARK_GREY) { drawBox(pos,size,p,p2,p3); for (int x=3;x