diff --git a/C++/scripts/md5 b/C++/scripts/md5 index 36cf76a..3e77b3f 100644 --- a/C++/scripts/md5 +++ b/C++/scripts/md5 @@ -1,3 +1,3 @@ build.sh:530634457ea9041267c05d4ced95eee1 - commit.sh:d03a46e721060c22ccb146e19d27e70a - -web.sh:3229cb0053cd0ca4ea08cc90e0d50ad0 - +web.sh:241ce74055952325f82f009b494df250 - diff --git a/C++/scripts/web.sh b/C++/scripts/web.sh index 0ff35a6..eef8c5b 100755 --- a/C++/scripts/web.sh +++ b/C++/scripts/web.sh @@ -6,6 +6,9 @@ else em++ -std=c++17 -O2 -s ALLOW_MEMORY_GROWTH=1 -s MAX_WEBGL_VERSION=2 -s MIN_WEBGL_VERSION=2 -s USE_LIBPNG=1 $(find . -type f -name "*.cpp") -o ${PROJECT_NAME}.html -I pixelGameEngine.h fi +cp buildtemplate.html ${PROJECT_NAME}.html +sed -i "s/_REPLACEME_/$PROJECT_NAME.js/" ${PROJECT_NAME}.html + if [ "$1" == "headless" ]; then echo "Running as headless web server" emrun --no_browser ${PROJECT_NAME}.html diff --git a/MeercaChase b/MeercaChase index 7d11389..78e9362 100755 Binary files a/MeercaChase and b/MeercaChase differ diff --git a/MeercaChase.cpp b/MeercaChase.cpp index 60effeb..f0b3fb6 100644 --- a/MeercaChase.cpp +++ b/MeercaChase.cpp @@ -10,14 +10,23 @@ public: olc::Decal*meerca; olc::Decal*negg; const float UPDATE_RATE = 0.016666667f; + const int NEGG_BOUNDARY=16; float accumulatedTime = 0.0f; int frameCount=0; int moveSpd=4; float meercaSpd[2] = {0,0}; - float meercaPos[2] = {240,240}; + float meercaPos[2] = {0,0}; + float neggPos[2] = {}; + + void assignNeggRandomPos() { + neggPos[0]=(float)rand()/RAND_MAX*(480-NEGG_BOUNDARY*2)+NEGG_BOUNDARY; + neggPos[1]=(float)rand()/RAND_MAX*(480-NEGG_BOUNDARY*2)+NEGG_BOUNDARY; + } MeercaChase() { sAppName = "Meerca Chase"; + srand(432189); + assignNeggRandomPos(); } bool OnUserCreate() override { @@ -36,9 +45,7 @@ public: accumulatedTime+=fElapsedTime; while (accumulatedTime>=UPDATE_RATE) { accumulatedTime-=UPDATE_RATE; - meercaPos[0]+=meercaSpd[0]; - meercaPos[1]+=meercaSpd[1]; - updateGame(); + updateGame(); //DO NOT ADD THINGS HERE. USE updateGame()! } if (GetKey(olc::F1).bPressed) { ConsoleShow(olc::F1,false); @@ -61,22 +68,27 @@ public: } // called once per frame if (meercaSpd[0]==moveSpd) { - DrawRotatedDecal({meercaPos[0]-16,meercaPos[1]-16},meerca,M_PI_2,{16,16}); + DrawRotatedDecal({meercaPos[0],meercaPos[1]},meerca,M_PI_2,{16,16}); } else if (meercaSpd[0]==-moveSpd) { - DrawRotatedDecal({meercaPos[0]-16,meercaPos[1]-16},meerca,M_PI_2*3,{16,16}); + DrawRotatedDecal({meercaPos[0],meercaPos[1]},meerca,M_PI_2*3,{16,16}); } else if (meercaSpd[1]==moveSpd) { - DrawRotatedDecal({meercaPos[0]-16,meercaPos[1]-16},meerca,M_PI,{16,16}); + DrawRotatedDecal({meercaPos[0],meercaPos[1]},meerca,M_PI,{16,16}); } else { - DrawRotatedDecal({meercaPos[0]-16,meercaPos[1]-16},meerca,0,{16,16}); + DrawRotatedDecal({meercaPos[0],meercaPos[1]},meerca,0,{16,16}); } - DrawDecal({32,64},negg,{1,1},olc::YELLOW); + DrawRotatedDecal({neggPos[0],neggPos[1]},negg,0,{16,16},{1.5,1.5},olc::YELLOW); return true; } void updateGame() { - + meercaPos[0]+=meercaSpd[0]; + meercaPos[1]+=meercaSpd[1]; + + if (abs(meercaPos[0]-neggPos[0])<8&&abs(meercaPos[1]-neggPos[1])<8) { + assignNeggRandomPos(); + } } }; diff --git a/MeercaChase.html b/MeercaChase.html index ab43ae8..0c4b5c9 100644 --- a/MeercaChase.html +++ b/MeercaChase.html @@ -1 +1,75 @@ -Emscripten-Generated Codeimage/svg+xml
Downloading...
Resize canvasLock/hide mouse pointer    
\ No newline at end of file + + + + + + + + Emscripten-Generated Code + + + + + + + + + + diff --git a/MeercaChase.wasm b/MeercaChase.wasm index 0863800..e89ab7c 100755 Binary files a/MeercaChase.wasm and b/MeercaChase.wasm differ diff --git a/buildtemplate.html b/buildtemplate.html new file mode 100644 index 0000000..7e6698d --- /dev/null +++ b/buildtemplate.html @@ -0,0 +1,75 @@ + + + + + + + + Emscripten-Generated Code + + + + + + + + + +