From 0f8a1d0e1f2690dd2d6d53f8a4f4d08b5baf12c2 Mon Sep 17 00:00:00 2001 From: Crayon2000 Date: Sun, 12 Jan 2020 01:49:01 -0500 Subject: [PATCH] Clean some examples code --- examples/3D_sample3/source/main.c | 1 - examples/blending/source/main.c | 40 +++++++++++++++++++++--------- examples/compositing/source/main.c | 1 - examples/particle/source/main.cpp | 8 +++--- examples/unlimited2d/source/main.c | 1 - examples/unlimited3d/source/main.c | 3 --- 6 files changed, 32 insertions(+), 22 deletions(-) diff --git a/examples/3D_sample3/source/main.c b/examples/3D_sample3/source/main.c index f8aa057..ea5b523 100644 --- a/examples/3D_sample3/source/main.c +++ b/examples/3D_sample3/source/main.c @@ -14,7 +14,6 @@ #include "gfx/font.h" #include "gfx/girl.h" -extern GXRModeObj *rmode; int main() { float a=0; diff --git a/examples/blending/source/main.c b/examples/blending/source/main.c index 2ed96c4..1962523 100644 --- a/examples/blending/source/main.c +++ b/examples/blending/source/main.c @@ -22,7 +22,6 @@ static void ExitGame(); // General Variables -extern GXRModeObj *rmode; ir_t P1Mote; // Prepare Graphics @@ -34,21 +33,20 @@ GRRLIB_texImg *GFX_Font; int main() { // Init Variables u32 WPADKeyDown; - short WinW, WinH; u8 Stage = 0; u8 Blending = 0; u8 BlobType = 0; - u8 Color = 255; + u8 Color; u16 Step = 0; // Init GRRLIB & WiiUse GRRLIB_Init(); - WinW = rmode->fbWidth; - WinH = rmode->efbHeight; + u16 WinW = rmode->fbWidth; + u16 WinH = rmode->efbHeight; WPAD_Init(); - WPAD_SetIdleTimeout( 60*10 ); + WPAD_SetIdleTimeout( 60 * 10 ); WPAD_SetDataFormat( WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR ); // Load Textures @@ -77,17 +75,20 @@ int main() { // Update Stage Step = Step + 1; - if (Step == 720) { Step = 0; } + if (Step == 720) { + Step = 0; + } float SX = 320 + (sin(DegToRad(Step )) * 250); float SY = 240 + (cos(DegToRad(Step*3)) * 100); // Draw Stage GRRLIB_DrawImg( 0, 0, GFX_Background, 0, 1, 1, RGBA(255, 255, 255, 255) ); - GRRLIB_SetBlend( (Blending+1) ); Color = 255; + GRRLIB_SetBlend( (Blending + 1) ); switch (Stage) { case 2: Color = 160; break; case 3: Color = 128; break; case 4: Color = 64; break; + default: Color = 255; break; } GRRLIB_DrawImg( SX, SY, GFX_Blob[BlobType], 0, 1, 1, RGBA(Color, Color, Color, 255) ); @@ -112,10 +113,25 @@ int main() { } GRRLIB_Render(); - if (WPADKeyDown & WPAD_BUTTON_RIGHT) { if (Stage < 5) { Stage += 1; } } - if (WPADKeyDown & WPAD_BUTTON_LEFT ) { if (Stage > 0) { Stage -= 1; } } - if (WPADKeyDown & WPAD_BUTTON_A ) { BlobType += 1; if (BlobType > 2) { BlobType = 0; } } - if (WPADKeyDown & WPAD_BUTTON_HOME ) { ExitGame(); } + if (WPADKeyDown & WPAD_BUTTON_RIGHT) { + if (Stage < 5) { + Stage += 1; + } + } + if (WPADKeyDown & WPAD_BUTTON_LEFT) { + if (Stage > 0) { + Stage -= 1; + } + } + if (WPADKeyDown & WPAD_BUTTON_A) { + BlobType += 1; + if (BlobType > 2) { + BlobType = 0; + } + } + if (WPADKeyDown & WPAD_BUTTON_HOME) { + break; + } } ExitGame(); return 0; diff --git a/examples/compositing/source/main.c b/examples/compositing/source/main.c index 6665e3f..d81710b 100644 --- a/examples/compositing/source/main.c +++ b/examples/compositing/source/main.c @@ -7,7 +7,6 @@ #include #include "gfx/font3d.h" -extern GXRModeObj *rmode; int main() { diff --git a/examples/particle/source/main.cpp b/examples/particle/source/main.cpp index 4ea6c03..86cfd09 100644 --- a/examples/particle/source/main.cpp +++ b/examples/particle/source/main.cpp @@ -67,10 +67,10 @@ int main() { // Init GRRLIB & WiiUse GRRLIB_Init(); - short WinW = rmode->fbWidth; - short WinH = rmode->efbHeight; + u16 WinW = rmode->fbWidth; + u16 WinH = rmode->efbHeight; WPAD_Init(); - WPAD_SetIdleTimeout( 60*10 ); + WPAD_SetIdleTimeout( 60 * 10 ); WPAD_SetDataFormat( WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR ); // Load textures @@ -160,7 +160,7 @@ static void createEffect( u8 id, int _x, int _y ) { createParticle( 3, (_x + (RANDOM * 50)), (_y + (RANDOM * 50)), 1.25f, 1.5f, 92, 92, 92 ); } for (u8 i = 0; i < 5; i++) { - _ColorAdd = (RANDOM*75); + _ColorAdd = (RANDOM * 75); createParticle( 2, (_x + (RANDOM * 40)), (_y + (RANDOM * 40)), (1.0f+(RANDOM*0.20)), 1.0f, 128+_ColorAdd, 128+_ColorAdd, 128+_ColorAdd ); } break; diff --git a/examples/unlimited2d/source/main.c b/examples/unlimited2d/source/main.c index 961f541..38234da 100644 --- a/examples/unlimited2d/source/main.c +++ b/examples/unlimited2d/source/main.c @@ -14,7 +14,6 @@ #include "gfx/font.h" #include "gfx/ball.h" -extern GXRModeObj *rmode; int main() { int i; diff --git a/examples/unlimited3d/source/main.c b/examples/unlimited3d/source/main.c index 06d51ad..f5ed80d 100644 --- a/examples/unlimited3d/source/main.c +++ b/examples/unlimited3d/source/main.c @@ -14,9 +14,6 @@ #include "gfx/logo.h" #include "gfx/font.h" -extern GXRModeObj *rmode; - - int main() { int i;