Move update rate of score items into update loop

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent ace73b6bad
commit a59acd4634
  1. BIN
      MeercaChase
  2. 9
      MeercaChase.cpp
  3. BIN
      MeercaChase.data
  4. 2
      MeercaChase.js
  5. BIN
      MeercaChase.wasm
  6. 20
      pixelGameEngine.h

Binary file not shown.

@ -182,7 +182,7 @@ public:
DrawRotatedDecal({neggPos[0],neggPos[1]},negg,0,{16,16},{1.5,1.5},olc::Pixel(0,251,255));
}break;
case 7:{
DrawRotatedDecal({neggPos[0],neggPos[1]},negg,0,{16,16},{1.5,1.5},olc::RED);
DrawRotatedDecal({neggPos[0],neggPos[1]},negg,0,{16,16},{1.5,1.5},olc::MAGENTA);
}break;
case 8:{
DrawRotatedDecal({neggPos[0],neggPos[1]},negg,0,{16,16},{1.5,1.5},olc::Pixel(255,128,0));
@ -198,6 +198,9 @@ public:
DrawRotatedDecal({badNeggs[i*2],badNeggs[i*2+1]},badnegg,0,{16,16},{1,1});
}
DrawString({16,16},"Score: "+to_string(score),olc::VERY_DARK_BLUE);
if (IsMobile()) {
DrawString({16,32},"<Using Mobile Controls>",olc::WHITE,2);
}
for (int i=0;i<tailSize;i++) {
if (i!=tailSize-1&&abs(meercaPos[0]-meercaPreviousPos[(i*8+6)])<8&&abs(meercaPos[1]-meercaPreviousPos[(i*8+7)])<8) {
init();
@ -205,8 +208,6 @@ public:
DrawCircle({(int)meercaPreviousPos[(i*8+6)],(int)meercaPreviousPos[(i*8+7)]},8);
}
if (scoreTransparency>0) {
scorePos[1]-=0.06;
scoreTransparency--;
DrawString({(int)scorePos[0],(int)scorePos[1]},"+"+to_string(scoreValue),olc::Pixel(0,0,255,scoreTransparency),2);
}
return true;
@ -254,6 +255,8 @@ public:
init();
}
}
scorePos[1]-=0.2;
scoreTransparency-=4;
}
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 393 B

After

Width:  |  Height:  |  Size: 19 KiB

File diff suppressed because one or more lines are too long

Binary file not shown.

@ -965,6 +965,8 @@ namespace olc
int32_t GetDrawTargetHeight() const;
// Returns the currently active draw target
olc::Sprite* GetDrawTarget() const;
//Returns whether or not this is running on mobile.
bool IsMobile();
// Resize the primary screen sprite
void SetScreenSize(int w, int h);
// Specify which Sprite should be the target of drawing functions, use nullptr
@ -1240,11 +1242,15 @@ namespace olc
void olc_Terminate();
void olc_Reanimate();
bool olc_IsRunning();
bool olc_IsMobile();
// At the very end of this file, chooses which
// components to compile
virtual void olc_ConfigureSystem();
static bool mobile;
// NOTE: Items Here are to be deprecated, I have left them in for now
// in case you are using them, but they will be removed.
// olc::vf2d vSubPixelOffset = { 0.0f, 0.0f };
@ -1884,6 +1890,10 @@ namespace olc
Sprite* PixelGameEngine::GetDrawTarget() const
{ return pDrawTarget; }
bool PixelGameEngine::IsMobile() {
return mobile;
}
int32_t PixelGameEngine::GetDrawTargetWidth() const
{
if (pDrawTarget)
@ -3364,6 +3374,8 @@ namespace olc
bool PixelGameEngine::olc_IsRunning()
{ return bAtomActive; }
bool PixelGameEngine::olc_IsMobile()
{ return mobile; }
void PixelGameEngine::olc_Terminate()
{ bAtomActive = false; }
@ -3637,6 +3649,7 @@ namespace olc
// Need a couple of statics as these are singleton instances
// read from multiple locations
std::atomic<bool> PixelGameEngine::bAtomActive{ false };
bool PixelGameEngine::mobile{ false };
olc::PixelGameEngine* olc::PGEX::pge = nullptr;
olc::PixelGameEngine* olc::Platform::ptrPGE = nullptr;
olc::PixelGameEngine* olc::Renderer::ptrPGE = nullptr;
@ -5952,12 +5965,14 @@ namespace olc
// Move
if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE)
{
ptrPGE->mobile=true;
ptrPGE->olc_UpdateMouse(e->touches->targetX, e->touches->targetY);
}
// Start
if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART)
{
ptrPGE->mobile=true;
ptrPGE->olc_UpdateMouse(e->touches->targetX, e->touches->targetY);
ptrPGE->olc_UpdateMouseState(0, true);
}
@ -5965,6 +5980,7 @@ namespace olc
// End
if (eventType == EMSCRIPTEN_EVENT_TOUCHEND)
{
ptrPGE->mobile=true;
ptrPGE->olc_UpdateMouseState(0, false);
}
@ -5975,8 +5991,10 @@ namespace olc
static EM_BOOL mouse_callback(int eventType, const EmscriptenMouseEvent* e, void* userData)
{
//Mouse Movement
if (eventType == EMSCRIPTEN_EVENT_MOUSEMOVE)
if (eventType == EMSCRIPTEN_EVENT_MOUSEMOVE) {
ptrPGE->mobile=false;
ptrPGE->olc_UpdateMouse(e->targetX, e->targetY);
}
//Mouse button press

Loading…
Cancel
Save