Fix text in blending example

This commit is contained in:
Crayon2000 2022-05-29 00:30:29 -04:00
parent 6f49839b74
commit e46d21721e

View file

@ -21,9 +21,6 @@
// Declare Static Functions // Declare Static Functions
static void ExitGame(); static void ExitGame();
// General Variables
ir_t P1Mote;
// Prepare Graphics // Prepare Graphics
GRRLIB_texImg *GFX_Background; GRRLIB_texImg *GFX_Background;
GRRLIB_texImg *GFX_Blob[3]; GRRLIB_texImg *GFX_Blob[3];
@ -32,10 +29,10 @@ GRRLIB_texImg *GFX_Font;
int main() { int main() {
// Init Variables // Init Variables
u32 WPADKeyDown; ir_t P1Mote;
u8 Stage = 0; u8 Stage = 0;
u8 Blending = 0; GRRLIB_blendMode Blending = GRRLIB_BLEND_ADD;
u8 BlobType = 0; u8 BlobType = 0;
u8 Color; u8 Color;
u16 Step = 0; u16 Step = 0;
@ -43,8 +40,8 @@ int main() {
// Init GRRLIB & WiiUse // Init GRRLIB & WiiUse
GRRLIB_Init(); GRRLIB_Init();
u16 WinW = rmode->fbWidth; const u16 WinW = rmode->fbWidth;
u16 WinH = rmode->efbHeight; const u16 WinH = rmode->efbHeight;
WPAD_Init(); WPAD_Init();
WPAD_SetIdleTimeout( 60 * 10 ); WPAD_SetIdleTimeout( 60 * 10 );
WPAD_SetDataFormat( WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR ); WPAD_SetDataFormat( WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR );
@ -65,7 +62,7 @@ int main() {
while (true) { while (true) {
WPAD_ScanPads(); WPAD_ScanPads();
WPADKeyDown = WPAD_ButtonsDown(WPAD_CHAN_0); const u32 WPADKeyDown = WPAD_ButtonsDown(WPAD_CHAN_0);
WPAD_SetVRes(WPAD_CHAN_0, WinW, WinH); WPAD_SetVRes(WPAD_CHAN_0, WinW, WinH);
WPAD_IR(WPAD_CHAN_0, &P1Mote); WPAD_IR(WPAD_CHAN_0, &P1Mote);
@ -74,7 +71,7 @@ int main() {
int P1MY = P1Mote.sy - 150; int P1MY = P1Mote.sy - 150;
// Update Stage // Update Stage
Step = Step + 1; Step++;
if (Step == 720) { if (Step == 720) {
Step = 0; Step = 0;
} }
@ -83,12 +80,20 @@ int main() {
// Draw Stage // Draw Stage
GRRLIB_DrawImg( 0, 0, GFX_Background, 0, 1, 1, RGBA(255, 255, 255, 255) ); GRRLIB_DrawImg( 0, 0, GFX_Background, 0, 1, 1, RGBA(255, 255, 255, 255) );
GRRLIB_SetBlend( (Blending + 1) ); GRRLIB_SetBlend( Blending );
switch (Stage) { switch (Stage) {
case 2: Color = 160; break; case 2:
case 3: Color = 128; break; Color = 160;
case 4: Color = 64; break; break;
default: Color = 255; 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) ); GRRLIB_DrawImg( SX, SY, GFX_Blob[BlobType], 0, 1, 1, RGBA(Color, Color, Color, 255) );
@ -99,28 +104,46 @@ int main() {
// Draw Text // Draw Text
GRRLIB_SetBlend ( GRRLIB_BLEND_ALPHA ); GRRLIB_SetBlend ( GRRLIB_BLEND_ALPHA );
GRRLIB_Rectangle( 28, 28, 480 + 16, 76, RGBA(0, 0, 0, 160), 1 ); GRRLIB_Rectangle( 28, 28, 480 + 16, 76, RGBA(0, 0, 0, 160), true );
GRRLIB_Printf ( 32, 32, GFX_Font, 0xFFFFFFFF, 1, "Point your WiiMote on the screen." ); GRRLIB_Printf ( 32, 32, GFX_Font, 0xFFFFFFFF, 1, "Point your WiiMote on the screen." );
GRRLIB_Printf ( 32, 48, GFX_Font, 0xFFFFFFFF, 1, "Press LEFT and RIGHT to switch through the different stages." ); GRRLIB_Printf ( 32, 48, GFX_Font, 0xFFFFFFFF, 1, "Press LEFT and RIGHT to switch through the different stages." );
GRRLIB_Printf ( 32, 64, GFX_Font, 0xFFFFFFFF, 1, "Press A to change the blob sprite." ); GRRLIB_Printf ( 32, 64, GFX_Font, 0xFFFFFFFF, 1, "Press A to change the blob sprite." );
switch (Stage) { switch (Stage) {
case 0: GRRLIB_Printf( 32, 88, GFX_Font, 0xFFFFFFFF, 1, "Stage 1: Additive Blending" ); Blending = 0; break; case 0:
case 1: GRRLIB_Printf( 32, 88, GFX_Font, 0xFFFFFFFF, 1, "Stage 2: Alpha Light Blending" ); Blending = 1; break; GRRLIB_Printf( 32, 88, GFX_Font, 0xFFFFFFFF, 1, "Stage 1: Additive Blending" );
case 2: GRRLIB_Printf( 32, 88, GFX_Font, 0xFFFFFFFF, 1, "Stage 3: Multiply Blending (75%)" ); Blending = 2; break; Blending = GRRLIB_BLEND_ADD;
case 3: GRRLIB_Printf( 32, 88, GFX_Font, 0xFFFFFFFF, 1, "Stage 4: Multiply Blending (50%)" ); Blending = 2; break; break;
case 4: GRRLIB_Printf( 32, 88, GFX_Font, 0xFFFFFFFF, 1, "Stage 5: Multiply Blending (25%)" ); Blending = 2; break; case 1:
case 5: GRRLIB_Printf( 32, 88, GFX_Font, 0xFFFFFFFF, 1, "Stage 6: Invert Color Blending" ); Blending = 3; break; GRRLIB_Printf( 32, 88, GFX_Font, 0xFFFFFFFF, 1, "Stage 2: Alpha Light Blending" );
Blending = GRRLIB_BLEND_SCREEN;
break;
case 2:
GRRLIB_Printf( 32, 88, GFX_Font, 0xFFFFFFFF, 1, "Stage 3: Multiply Blending (75%%)" );
Blending = GRRLIB_BLEND_MULTI;
break;
case 3:
GRRLIB_Printf( 32, 88, GFX_Font, 0xFFFFFFFF, 1, "Stage 4: Multiply Blending (50%%)" );
Blending = GRRLIB_BLEND_MULTI;
break;
case 4:
GRRLIB_Printf( 32, 88, GFX_Font, 0xFFFFFFFF, 1, "Stage 5: Multiply Blending (25%%)" );
Blending = GRRLIB_BLEND_MULTI;
break;
case 5:
GRRLIB_Printf( 32, 88, GFX_Font, 0xFFFFFFFF, 1, "Stage 6: Invert Color Blending" );
Blending = GRRLIB_BLEND_INV;
break;
} }
GRRLIB_Render(); GRRLIB_Render();
if (WPADKeyDown & WPAD_BUTTON_RIGHT) { if (WPADKeyDown & WPAD_BUTTON_RIGHT) {
if (Stage < 5) { if (Stage < 5) {
Stage += 1; Stage++;
} }
} }
if (WPADKeyDown & WPAD_BUTTON_LEFT) { if (WPADKeyDown & WPAD_BUTTON_LEFT) {
if (Stage > 0) { if (Stage > 0) {
Stage -= 1; Stage--;
} }
} }
if (WPADKeyDown & WPAD_BUTTON_A) { if (WPADKeyDown & WPAD_BUTTON_A) {