generated from sigonasr2/CPlusPlusProjectTemplate
Move update rate of score items into update loop
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
ace73b6bad
commit
a59acd4634
BIN
MeercaChase
BIN
MeercaChase
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));
|
DrawRotatedDecal({neggPos[0],neggPos[1]},negg,0,{16,16},{1.5,1.5},olc::Pixel(0,251,255));
|
||||||
}break;
|
}break;
|
||||||
case 7:{
|
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;
|
}break;
|
||||||
case 8:{
|
case 8:{
|
||||||
DrawRotatedDecal({neggPos[0],neggPos[1]},negg,0,{16,16},{1.5,1.5},olc::Pixel(255,128,0));
|
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});
|
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);
|
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++) {
|
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) {
|
if (i!=tailSize-1&&abs(meercaPos[0]-meercaPreviousPos[(i*8+6)])<8&&abs(meercaPos[1]-meercaPreviousPos[(i*8+7)])<8) {
|
||||||
init();
|
init();
|
||||||
@ -205,8 +208,6 @@ public:
|
|||||||
DrawCircle({(int)meercaPreviousPos[(i*8+6)],(int)meercaPreviousPos[(i*8+7)]},8);
|
DrawCircle({(int)meercaPreviousPos[(i*8+6)],(int)meercaPreviousPos[(i*8+7)]},8);
|
||||||
}
|
}
|
||||||
if (scoreTransparency>0) {
|
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);
|
DrawString({(int)scorePos[0],(int)scorePos[1]},"+"+to_string(scoreValue),olc::Pixel(0,0,255,scoreTransparency),2);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -254,6 +255,8 @@ public:
|
|||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
scorePos[1]-=0.2;
|
||||||
|
scoreTransparency-=4;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
BIN
MeercaChase.data
BIN
MeercaChase.data
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
BIN
MeercaChase.wasm
BIN
MeercaChase.wasm
Binary file not shown.
@ -965,6 +965,8 @@ namespace olc
|
|||||||
int32_t GetDrawTargetHeight() const;
|
int32_t GetDrawTargetHeight() const;
|
||||||
// Returns the currently active draw target
|
// Returns the currently active draw target
|
||||||
olc::Sprite* GetDrawTarget() const;
|
olc::Sprite* GetDrawTarget() const;
|
||||||
|
//Returns whether or not this is running on mobile.
|
||||||
|
bool IsMobile();
|
||||||
// Resize the primary screen sprite
|
// Resize the primary screen sprite
|
||||||
void SetScreenSize(int w, int h);
|
void SetScreenSize(int w, int h);
|
||||||
// Specify which Sprite should be the target of drawing functions, use nullptr
|
// Specify which Sprite should be the target of drawing functions, use nullptr
|
||||||
@ -1240,11 +1242,15 @@ namespace olc
|
|||||||
void olc_Terminate();
|
void olc_Terminate();
|
||||||
void olc_Reanimate();
|
void olc_Reanimate();
|
||||||
bool olc_IsRunning();
|
bool olc_IsRunning();
|
||||||
|
bool olc_IsMobile();
|
||||||
|
|
||||||
// At the very end of this file, chooses which
|
// At the very end of this file, chooses which
|
||||||
// components to compile
|
// components to compile
|
||||||
virtual void olc_ConfigureSystem();
|
virtual void olc_ConfigureSystem();
|
||||||
|
|
||||||
|
|
||||||
|
static bool mobile;
|
||||||
|
|
||||||
// NOTE: Items Here are to be deprecated, I have left them in for now
|
// 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.
|
// in case you are using them, but they will be removed.
|
||||||
// olc::vf2d vSubPixelOffset = { 0.0f, 0.0f };
|
// olc::vf2d vSubPixelOffset = { 0.0f, 0.0f };
|
||||||
@ -1884,6 +1890,10 @@ namespace olc
|
|||||||
Sprite* PixelGameEngine::GetDrawTarget() const
|
Sprite* PixelGameEngine::GetDrawTarget() const
|
||||||
{ return pDrawTarget; }
|
{ return pDrawTarget; }
|
||||||
|
|
||||||
|
bool PixelGameEngine::IsMobile() {
|
||||||
|
return mobile;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t PixelGameEngine::GetDrawTargetWidth() const
|
int32_t PixelGameEngine::GetDrawTargetWidth() const
|
||||||
{
|
{
|
||||||
if (pDrawTarget)
|
if (pDrawTarget)
|
||||||
@ -3364,6 +3374,8 @@ namespace olc
|
|||||||
|
|
||||||
bool PixelGameEngine::olc_IsRunning()
|
bool PixelGameEngine::olc_IsRunning()
|
||||||
{ return bAtomActive; }
|
{ return bAtomActive; }
|
||||||
|
bool PixelGameEngine::olc_IsMobile()
|
||||||
|
{ return mobile; }
|
||||||
|
|
||||||
void PixelGameEngine::olc_Terminate()
|
void PixelGameEngine::olc_Terminate()
|
||||||
{ bAtomActive = false; }
|
{ bAtomActive = false; }
|
||||||
@ -3637,6 +3649,7 @@ namespace olc
|
|||||||
// Need a couple of statics as these are singleton instances
|
// Need a couple of statics as these are singleton instances
|
||||||
// read from multiple locations
|
// read from multiple locations
|
||||||
std::atomic<bool> PixelGameEngine::bAtomActive{ false };
|
std::atomic<bool> PixelGameEngine::bAtomActive{ false };
|
||||||
|
bool PixelGameEngine::mobile{ false };
|
||||||
olc::PixelGameEngine* olc::PGEX::pge = nullptr;
|
olc::PixelGameEngine* olc::PGEX::pge = nullptr;
|
||||||
olc::PixelGameEngine* olc::Platform::ptrPGE = nullptr;
|
olc::PixelGameEngine* olc::Platform::ptrPGE = nullptr;
|
||||||
olc::PixelGameEngine* olc::Renderer::ptrPGE = nullptr;
|
olc::PixelGameEngine* olc::Renderer::ptrPGE = nullptr;
|
||||||
@ -5952,12 +5965,14 @@ namespace olc
|
|||||||
// Move
|
// Move
|
||||||
if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE)
|
if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE)
|
||||||
{
|
{
|
||||||
|
ptrPGE->mobile=true;
|
||||||
ptrPGE->olc_UpdateMouse(e->touches->targetX, e->touches->targetY);
|
ptrPGE->olc_UpdateMouse(e->touches->targetX, e->touches->targetY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start
|
// Start
|
||||||
if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART)
|
if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART)
|
||||||
{
|
{
|
||||||
|
ptrPGE->mobile=true;
|
||||||
ptrPGE->olc_UpdateMouse(e->touches->targetX, e->touches->targetY);
|
ptrPGE->olc_UpdateMouse(e->touches->targetX, e->touches->targetY);
|
||||||
ptrPGE->olc_UpdateMouseState(0, true);
|
ptrPGE->olc_UpdateMouseState(0, true);
|
||||||
}
|
}
|
||||||
@ -5965,6 +5980,7 @@ namespace olc
|
|||||||
// End
|
// End
|
||||||
if (eventType == EMSCRIPTEN_EVENT_TOUCHEND)
|
if (eventType == EMSCRIPTEN_EVENT_TOUCHEND)
|
||||||
{
|
{
|
||||||
|
ptrPGE->mobile=true;
|
||||||
ptrPGE->olc_UpdateMouseState(0, false);
|
ptrPGE->olc_UpdateMouseState(0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5975,8 +5991,10 @@ namespace olc
|
|||||||
static EM_BOOL mouse_callback(int eventType, const EmscriptenMouseEvent* e, void* userData)
|
static EM_BOOL mouse_callback(int eventType, const EmscriptenMouseEvent* e, void* userData)
|
||||||
{
|
{
|
||||||
//Mouse Movement
|
//Mouse Movement
|
||||||
if (eventType == EMSCRIPTEN_EVENT_MOUSEMOVE)
|
if (eventType == EMSCRIPTEN_EVENT_MOUSEMOVE) {
|
||||||
|
ptrPGE->mobile=false;
|
||||||
ptrPGE->olc_UpdateMouse(e->targetX, e->targetY);
|
ptrPGE->olc_UpdateMouse(e->targetX, e->targetY);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//Mouse button press
|
//Mouse button press
|
||||||
|
Loading…
x
Reference in New Issue
Block a user