From 3ee20bffc24c3e3d95f690d83369b2bf406eb35d Mon Sep 17 00:00:00 2001 From: Crayon2000 Date: Sun, 11 Sep 2022 23:19:19 -0400 Subject: [PATCH] Use an enum in particle example instead of a macro --- examples/3D_CubedTileDemo/source/main.c | 2 +- examples/TileDemo/source/main.c | 2 +- examples/gamecube/3D_CubedTileDemo/source/main.c | 2 +- examples/gamecube/TileDemo/source/main.c | 2 +- examples/particle/source/main.cpp | 14 ++++++++------ 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/examples/3D_CubedTileDemo/source/main.c b/examples/3D_CubedTileDemo/source/main.c index 34c6b6f..665907b 100644 --- a/examples/3D_CubedTileDemo/source/main.c +++ b/examples/3D_CubedTileDemo/source/main.c @@ -240,7 +240,7 @@ int main() { bgy++; else if(diry<0) bgy--; - if((bgy>-1) ||(bgy<-63)) + if((bgy>-1) || (bgy<-63)) bgy=-32; if(cpty==32) { diff --git a/examples/TileDemo/source/main.c b/examples/TileDemo/source/main.c index 2a5427f..067faa3 100644 --- a/examples/TileDemo/source/main.c +++ b/examples/TileDemo/source/main.c @@ -208,7 +208,7 @@ int main() { bgx++; else if(dirx<0) bgx--; - if((bgx>-1) ||(bgx<-63)) + if((bgx>-1) || (bgx<-63)) bgx=-32; if(cptx==32) { diff --git a/examples/gamecube/3D_CubedTileDemo/source/main.c b/examples/gamecube/3D_CubedTileDemo/source/main.c index df38e01..d13520a 100644 --- a/examples/gamecube/3D_CubedTileDemo/source/main.c +++ b/examples/gamecube/3D_CubedTileDemo/source/main.c @@ -240,7 +240,7 @@ int main() { bgy++; else if(diry<0) bgy--; - if((bgy>-1) ||(bgy<-63)) + if((bgy>-1) || (bgy<-63)) bgy=-32; if(cpty==32) { diff --git a/examples/gamecube/TileDemo/source/main.c b/examples/gamecube/TileDemo/source/main.c index 6673b24..b61c835 100644 --- a/examples/gamecube/TileDemo/source/main.c +++ b/examples/gamecube/TileDemo/source/main.c @@ -208,7 +208,7 @@ int main() { bgx++; else if(dirx<0) bgx--; - if((bgx>-1) ||(bgx<-63)) + if((bgx>-1) || (bgx<-63)) bgx=-32; if(cptx==32) { diff --git a/examples/particle/source/main.cpp b/examples/particle/source/main.cpp index 6395e10..a8bbebf 100644 --- a/examples/particle/source/main.cpp +++ b/examples/particle/source/main.cpp @@ -20,8 +20,10 @@ #include "RGFX_Font_png.h" -// Define Effects -#define EFFECT_SMOKEBOMB 1 +// Effects +enum class Effect : u8 { + SMOKEBOMB +}; // Random Number (0 - 1) in float #define RANDOM ((((float)(rand() % 12))/12)-0.5) @@ -47,7 +49,7 @@ static std::vector ParticleListTmp; // Declare static functions static void ExitGame(); -static void createEffect( u8 id, int _x, int _y ); +static void createEffect( Effect id, int _x, int _y ); static void createParticle( u8 _id, int _x, int _y, float _scale, float _alpha, u8 _red, u8 _green, u8 _blue ); static bool updateParticle( Particle *part ); static u8 CalculateFrameRate(); @@ -137,7 +139,7 @@ int main() { FPS = CalculateFrameRate(); if (WPADKeyDown & WPAD_BUTTON_B) { - createEffect( EFFECT_SMOKEBOMB, P1MX, P1MY ); + createEffect( Effect::SMOKEBOMB, P1MX, P1MY ); } if (WPADKeyDown & WPAD_BUTTON_HOME) { break; @@ -147,9 +149,9 @@ int main() { return 0; } -static void createEffect( u8 id, int _x, int _y ) { +static void createEffect( Effect id, int _x, int _y ) { switch (id) { - case EFFECT_SMOKEBOMB: + case Effect::SMOKEBOMB: for (u8 i = 0; i < 5; i++) { createParticle( 1, (_x + (RANDOM * 10)), (_y + (RANDOM * 10)), (1.4f+(RANDOM*0.20)), 1.0f, 64, 64, 64 ); }