generated from sigonasr2/CPlusPlusProjectTemplate
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>master
parent
b7296f50a1
commit
92ab6d3a9c
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,45 +1,88 @@ |
||||
#define OLC_PGE_APPLICATION |
||||
#include "pixelGameEngine.h" |
||||
#define OLC_SOUNDWAVE |
||||
#include "soundExtension.h" |
||||
|
||||
using namespace std; |
||||
|
||||
class Example : public olc::PixelGameEngine |
||||
class EarthboundBattleSim : public olc::PixelGameEngine |
||||
{ |
||||
public: |
||||
Example() |
||||
EarthboundBattleSim() |
||||
{ |
||||
sAppName = "Example"; |
||||
sAppName = "EarthboundBattleSim"; |
||||
} |
||||
|
||||
public: |
||||
|
||||
float accumulatedTime=0; |
||||
const float UPDATE_RATE=1/60.0F; |
||||
char partyMemberCount=1; |
||||
olc::sound::WaveEngine engine; |
||||
olc::sound::Wave se1; |
||||
|
||||
|
||||
bool OnUserCreate() override |
||||
{ |
||||
SetPixelMode(olc::Pixel::ALPHA); |
||||
ConsoleCaptureStdOut(true); |
||||
//ConsoleCaptureStdOut(true);
|
||||
// Called once at the start, so create things here
|
||||
for (int x = 0; x < ScreenWidth(); x++) |
||||
for (int y = 0; y < ScreenHeight(); y++) |
||||
Draw(x, y, olc::Pixel(rand() % 255, rand() % 255, rand()% 255));
|
||||
for (int x=0;x<50;x++) { |
||||
for (int y=0;y<50;y++) { |
||||
Draw(x, y, olc::Pixel(255, 0, 0, 128));
|
||||
} |
||||
} |
||||
engine.InitialiseAudio(); |
||||
engine.SetOutputVolume(0.1f); |
||||
se1.LoadAudioWaveform("./assets/sample-9s.wav"); |
||||
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); |
||||
} |
||||
if (GetMouse(0).bPressed) { |
||||
engine.PlayWaveform(&se1); |
||||
} |
||||
|
||||
drawGame(); |
||||
// called once per frame
|
||||
return true; |
||||
} |
||||
|
||||
void updateGame(){ |
||||
} |
||||
|
||||
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) { |
||||
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}); |
||||
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 drawGame(){ |
||||
drawBox({0,0},{128,32}); |
||||
for (int i=0;i<partyMemberCount;i++) { |
||||
drawBox({(128-32*partyMemberCount)+i*64,160},{64,64}); |
||||
} |
||||
} |
||||
}; |
||||
|
||||
|
||||
int main() |
||||
{ |
||||
Example demo; |
||||
if (demo.Construct(256, 240, 4, 4)) |
||||
EarthboundBattleSim demo; |
||||
if (demo.Construct(256, 224, 4, 4)) |
||||
demo.Start(); |
||||
|
||||
return 0; |
||||
|
@ -1,9 +1,9 @@ |
||||
export AUTO_UPDATE=true |
||||
export AUTO_UPDATE=false |
||||
|
||||
source utils/define.sh |
||||
|
||||
define PROJECT_NAME "C++ProjectTemplate" |
||||
define CUSTOM_PARAMS "-lpng -lGL -lX11" |
||||
define CUSTOM_PARAMS "-lX11 -lGL -lpthread -lpng -lstdc++fs -lasound" |
||||
define LANGUAGE "C++" |
||||
|
||||
source utils/main.sh |
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue