mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-22 15:02:20 +00:00
[CHG] Tabs converted to spaces
This commit is contained in:
parent
1d1b996a06
commit
3a71ef517b
7 changed files with 314 additions and 314 deletions
|
@ -44,107 +44,107 @@ float sinx=0,oldsinx=0;
|
||||||
GRRLIB_camera3dSettings(0.0f,0.0f,13.0f, 0,1,0, 0,0,0);
|
GRRLIB_camera3dSettings(0.0f,0.0f,13.0f, 0,1,0, 0,0,0);
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
GRRLIB_2dMode();
|
GRRLIB_2dMode();
|
||||||
WPAD_ScanPads();
|
WPAD_ScanPads();
|
||||||
if(WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) exit(0);
|
if(WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) exit(0);
|
||||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_A) cubeZ++;
|
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_A) cubeZ++;
|
||||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_B) cubeZ--;
|
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_B) cubeZ--;
|
||||||
|
|
||||||
GRRLIB_3dMode(0.1,1000,45,1);
|
GRRLIB_3dMode(0.1,1000,45,1);
|
||||||
GRRLIB_setTexture(tex_girl,0);
|
GRRLIB_setTexture(tex_girl,0);
|
||||||
GRRLIB_objectView(0,0,cubeZ, a,a*2,a*3);
|
GRRLIB_objectView(0,0,cubeZ, a,a*2,a*3);
|
||||||
GX_Begin(GX_QUADS, GX_VTXFMT0, 24);
|
GX_Begin(GX_QUADS, GX_VTXFMT0, 24);
|
||||||
GX_Position3f32(-1.0f,1.0f,1.0f);
|
GX_Position3f32(-1.0f,1.0f,1.0f);
|
||||||
GX_Color1u32(col[0]);
|
GX_Color1u32(col[0]);
|
||||||
GX_TexCoord2f32(0.0f,0.0f);
|
GX_TexCoord2f32(0.0f,0.0f);
|
||||||
GX_Position3f32(1.0f,1.0f,1.0f);
|
GX_Position3f32(1.0f,1.0f,1.0f);
|
||||||
GX_Color1u32(col[0]);
|
GX_Color1u32(col[0]);
|
||||||
GX_TexCoord2f32(1.0f,0.0f);
|
GX_TexCoord2f32(1.0f,0.0f);
|
||||||
GX_Position3f32(1.0f,-1.0f,1.0f);
|
GX_Position3f32(1.0f,-1.0f,1.0f);
|
||||||
GX_Color1u32(col[0]);
|
GX_Color1u32(col[0]);
|
||||||
GX_TexCoord2f32(1.0f,1.0f);
|
GX_TexCoord2f32(1.0f,1.0f);
|
||||||
GX_Position3f32(-1.0f,-1.0f,1.0f);
|
GX_Position3f32(-1.0f,-1.0f,1.0f);
|
||||||
GX_Color1u32(col[0]);
|
GX_Color1u32(col[0]);
|
||||||
GX_TexCoord2f32(0.0f,1.0f);
|
GX_TexCoord2f32(0.0f,1.0f);
|
||||||
|
|
||||||
GX_Position3f32(1.0f,1.0f,-1.0f);
|
GX_Position3f32(1.0f,1.0f,-1.0f);
|
||||||
GX_Color1u32(col[0]);
|
GX_Color1u32(col[0]);
|
||||||
GX_TexCoord2f32(0.0f,0.0f);
|
GX_TexCoord2f32(0.0f,0.0f);
|
||||||
GX_Position3f32(-1.0f,1.0f,-1.0f);
|
GX_Position3f32(-1.0f,1.0f,-1.0f);
|
||||||
GX_Color1u32(col[0]);
|
GX_Color1u32(col[0]);
|
||||||
GX_TexCoord2f32(1.0f,0.0f);
|
GX_TexCoord2f32(1.0f,0.0f);
|
||||||
GX_Position3f32(-1.0f,-1.0f,-1.0f);
|
GX_Position3f32(-1.0f,-1.0f,-1.0f);
|
||||||
GX_Color1u32(col[0]);
|
GX_Color1u32(col[0]);
|
||||||
GX_TexCoord2f32(1.0f,1.0f);
|
GX_TexCoord2f32(1.0f,1.0f);
|
||||||
GX_Position3f32(1.0f,-1.0f,-1.0f);
|
GX_Position3f32(1.0f,-1.0f,-1.0f);
|
||||||
GX_Color1u32(col[0]);
|
GX_Color1u32(col[0]);
|
||||||
GX_TexCoord2f32(0.0f,1.0f);
|
GX_TexCoord2f32(0.0f,1.0f);
|
||||||
|
|
||||||
GX_Position3f32(1.0f,1.0f,1.0f);
|
GX_Position3f32(1.0f,1.0f,1.0f);
|
||||||
GX_Color1u32(col[1]);
|
GX_Color1u32(col[1]);
|
||||||
GX_TexCoord2f32(0.0f,0.0f);
|
GX_TexCoord2f32(0.0f,0.0f);
|
||||||
GX_Position3f32(1.0f,1.0f,-1.0f);
|
GX_Position3f32(1.0f,1.0f,-1.0f);
|
||||||
GX_Color1u32(col[1]);
|
GX_Color1u32(col[1]);
|
||||||
GX_TexCoord2f32(1.0f,0.0f);
|
GX_TexCoord2f32(1.0f,0.0f);
|
||||||
GX_Position3f32(1.0f,-1.0f,-1.0f);
|
GX_Position3f32(1.0f,-1.0f,-1.0f);
|
||||||
GX_Color1u32(col[1]);
|
GX_Color1u32(col[1]);
|
||||||
GX_TexCoord2f32(1.0f,1.0f);
|
GX_TexCoord2f32(1.0f,1.0f);
|
||||||
GX_Position3f32(1.0f,-1.0f,1.0f);
|
GX_Position3f32(1.0f,-1.0f,1.0f);
|
||||||
GX_Color1u32(col[1]);
|
GX_Color1u32(col[1]);
|
||||||
GX_TexCoord2f32(0.0f,1.0f);
|
GX_TexCoord2f32(0.0f,1.0f);
|
||||||
|
|
||||||
GX_Position3f32(-1.0f,1.0f,-1.0f);
|
GX_Position3f32(-1.0f,1.0f,-1.0f);
|
||||||
GX_Color1u32(col[1]);
|
GX_Color1u32(col[1]);
|
||||||
GX_TexCoord2f32(0.0f,0.0f);
|
GX_TexCoord2f32(0.0f,0.0f);
|
||||||
GX_Position3f32(-1.0f,1.0f,1.0f);
|
GX_Position3f32(-1.0f,1.0f,1.0f);
|
||||||
GX_Color1u32(col[1]);
|
GX_Color1u32(col[1]);
|
||||||
GX_TexCoord2f32(1.0f,0.0f);
|
GX_TexCoord2f32(1.0f,0.0f);
|
||||||
GX_Position3f32(-1.0f,-1.0f,1.0f);
|
GX_Position3f32(-1.0f,-1.0f,1.0f);
|
||||||
GX_Color1u32(col[1]);
|
GX_Color1u32(col[1]);
|
||||||
GX_TexCoord2f32(1.0f,1.0f);
|
GX_TexCoord2f32(1.0f,1.0f);
|
||||||
GX_Position3f32(-1.0f,-1.0f,-1.0f);
|
GX_Position3f32(-1.0f,-1.0f,-1.0f);
|
||||||
GX_Color1u32(col[1]);
|
GX_Color1u32(col[1]);
|
||||||
GX_TexCoord2f32(0.0f,1.0f);
|
GX_TexCoord2f32(0.0f,1.0f);
|
||||||
|
|
||||||
GX_Position3f32(-1.0f,1.0f,-1.0f);
|
GX_Position3f32(-1.0f,1.0f,-1.0f);
|
||||||
GX_Color1u32(col[2]);
|
GX_Color1u32(col[2]);
|
||||||
GX_TexCoord2f32(0.0f,0.0f);
|
GX_TexCoord2f32(0.0f,0.0f);
|
||||||
GX_Position3f32(1.0f,1.0f,-1.0f);
|
GX_Position3f32(1.0f,1.0f,-1.0f);
|
||||||
GX_Color1u32(col[2]);
|
GX_Color1u32(col[2]);
|
||||||
GX_TexCoord2f32(1.0f,0.0f);
|
GX_TexCoord2f32(1.0f,0.0f);
|
||||||
GX_Position3f32(1.0f,1.0f,1.0f);
|
GX_Position3f32(1.0f,1.0f,1.0f);
|
||||||
GX_Color1u32(col[2]);
|
GX_Color1u32(col[2]);
|
||||||
GX_TexCoord2f32(1.0f,1.0f);
|
GX_TexCoord2f32(1.0f,1.0f);
|
||||||
GX_Position3f32(-1.0f,1.0f,1.0f);
|
GX_Position3f32(-1.0f,1.0f,1.0f);
|
||||||
GX_Color1u32(col[2]);
|
GX_Color1u32(col[2]);
|
||||||
GX_TexCoord2f32(0.0f,1.0f);
|
GX_TexCoord2f32(0.0f,1.0f);
|
||||||
|
|
||||||
GX_Position3f32(1.0f,-1.0f,-1.0f);
|
GX_Position3f32(1.0f,-1.0f,-1.0f);
|
||||||
GX_Color1u32(col[2]);
|
GX_Color1u32(col[2]);
|
||||||
GX_TexCoord2f32(0.0f,0.0f);
|
GX_TexCoord2f32(0.0f,0.0f);
|
||||||
GX_Position3f32(-1.0f,-1.0f,-1.0f);
|
GX_Position3f32(-1.0f,-1.0f,-1.0f);
|
||||||
GX_Color1u32(col[2]);
|
GX_Color1u32(col[2]);
|
||||||
GX_TexCoord2f32(1.0f,0.0f);
|
GX_TexCoord2f32(1.0f,0.0f);
|
||||||
GX_Position3f32(-1.0f,-1.0f,1.0f);
|
GX_Position3f32(-1.0f,-1.0f,1.0f);
|
||||||
GX_Color1u32(col[2]);
|
GX_Color1u32(col[2]);
|
||||||
GX_TexCoord2f32(1.0f,1.0f);
|
GX_TexCoord2f32(1.0f,1.0f);
|
||||||
GX_Position3f32(1.0f,-1.0f,1.0f);
|
GX_Position3f32(1.0f,-1.0f,1.0f);
|
||||||
GX_Color1u32(col[2]);
|
GX_Color1u32(col[2]);
|
||||||
GX_TexCoord2f32(0.0f,1.0f);
|
GX_TexCoord2f32(0.0f,1.0f);
|
||||||
GX_End();
|
GX_End();
|
||||||
GRRLIB_Screen2Texture(0,0,tex_screen,1);
|
GRRLIB_Screen2Texture(0,0,tex_screen,1);
|
||||||
a+=0.5f;
|
a+=0.5f;
|
||||||
|
|
||||||
// Switch To 2D Mode to display text
|
// Switch To 2D Mode to display text
|
||||||
GRRLIB_2dMode();
|
GRRLIB_2dMode();
|
||||||
oldsinx=sinx;
|
oldsinx=sinx;
|
||||||
for(i=0;i<rmode->efbHeight;i++){
|
for(i=0;i<rmode->efbHeight;i++){
|
||||||
GRRLIB_DrawTile(0+sin(sinx)*60,i,tex_screen,0,1,1,0xFFFFFFFF,i);
|
GRRLIB_DrawTile(0+sin(sinx)*60,i,tex_screen,0,1,1,0xFFFFFFFF,i);
|
||||||
sinx+=0.02f;
|
sinx+=0.02f;
|
||||||
}
|
}
|
||||||
sinx=oldsinx+0.02f;
|
sinx=oldsinx+0.02f;
|
||||||
|
|
||||||
GRRLIB_Printf((640-(16*29))/2, 20, tex_font, 0xFFFFFFFF, 1, "PRESS A OR B TO ZOOM THE CUBE");
|
GRRLIB_Printf((640-(16*29))/2, 20, tex_font, 0xFFFFFFFF, 1, "PRESS A OR B TO ZOOM THE CUBE");
|
||||||
|
|
||||||
GRRLIB_Render();
|
GRRLIB_Render();
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ int main() {
|
||||||
// Load the original texture and create empty texture of the same size as the original one
|
// Load the original texture and create empty texture of the same size as the original one
|
||||||
GRRLIB_texImg *tex_pirate = GRRLIB_LoadTexture(pirate);
|
GRRLIB_texImg *tex_pirate = GRRLIB_LoadTexture(pirate);
|
||||||
GRRLIB_texImg *tex_gray = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
|
GRRLIB_texImg *tex_gray = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
|
||||||
GRRLIB_texImg *tex_sepia = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
|
GRRLIB_texImg *tex_sepia = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
|
||||||
GRRLIB_texImg *tex_invert = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
|
GRRLIB_texImg *tex_invert = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
|
||||||
GRRLIB_texImg *tex_blur1 = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
|
GRRLIB_texImg *tex_blur1 = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
|
||||||
GRRLIB_texImg *tex_blur2 = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
|
GRRLIB_texImg *tex_blur2 = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
============================================*/
|
============================================*/
|
||||||
#include <grrlib.h>
|
#include <grrlib.h>
|
||||||
|
|
||||||
#include <ogc/lwp_watchdog.h> // Needed for gettime and ticks_to_millisecs
|
#include <ogc/lwp_watchdog.h> // Needed for gettime and ticks_to_millisecs
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <wiiuse/wpad.h>
|
#include <wiiuse/wpad.h>
|
||||||
#include <fat.h>
|
#include <fat.h>
|
||||||
|
|
|
@ -32,39 +32,39 @@ GRRLIB_texImg *GFX_Font;
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
// Init Variables
|
// Init Variables
|
||||||
u32 WPADKeyDown;
|
u32 WPADKeyDown;
|
||||||
u32 WPADKeyHeld;
|
u32 WPADKeyHeld;
|
||||||
short WinW, WinH;
|
short WinW, WinH;
|
||||||
int P1MX, P1MY;
|
int P1MX, P1MY;
|
||||||
|
|
||||||
u8 Stage = 0, Blending = 0;
|
u8 Stage = 0, Blending = 0;
|
||||||
u8 BlobType = 0;
|
u8 BlobType = 0;
|
||||||
u8 Color = 255;
|
u8 Color = 255;
|
||||||
u16 Step = 0;
|
u16 Step = 0;
|
||||||
float SX, SY;
|
float SX, SY;
|
||||||
|
|
||||||
|
|
||||||
// Init GRRLIB & WiiUse
|
// Init GRRLIB & WiiUse
|
||||||
GRRLIB_Init();
|
GRRLIB_Init();
|
||||||
WinW = rmode->fbWidth;
|
WinW = rmode->fbWidth;
|
||||||
WinH = rmode->efbHeight;
|
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 );
|
||||||
|
|
||||||
// Load Textures
|
// Load Textures
|
||||||
GFX_Background = GRRLIB_LoadTextureJPG(RGFX_Background);
|
GFX_Background = GRRLIB_LoadTextureJPG(RGFX_Background);
|
||||||
GFX_Blob[0] = GRRLIB_LoadTexturePNG(RGFX_Blob01);
|
GFX_Blob[0] = GRRLIB_LoadTexturePNG(RGFX_Blob01);
|
||||||
GFX_Blob[1] = GRRLIB_LoadTexturePNG(RGFX_Blob02);
|
GFX_Blob[1] = GRRLIB_LoadTexturePNG(RGFX_Blob02);
|
||||||
GFX_Blob[2] = GRRLIB_LoadTexturePNG(RGFX_Blob03);
|
GFX_Blob[2] = GRRLIB_LoadTexturePNG(RGFX_Blob03);
|
||||||
GFX_Font = GRRLIB_LoadTexturePNG(RGFX_Font);
|
GFX_Font = GRRLIB_LoadTexturePNG(RGFX_Font);
|
||||||
GRRLIB_InitTileSet(GFX_Font, 8, 16, 32);
|
GRRLIB_InitTileSet(GFX_Font, 8, 16, 32);
|
||||||
|
|
||||||
// Set Handles
|
// Set Handles
|
||||||
GRRLIB_SetMidHandle( GFX_Blob[0], true );
|
GRRLIB_SetMidHandle( GFX_Blob[0], true );
|
||||||
GRRLIB_SetMidHandle( GFX_Blob[1], true );
|
GRRLIB_SetMidHandle( GFX_Blob[1], true );
|
||||||
GRRLIB_SetMidHandle( GFX_Blob[2], true );
|
GRRLIB_SetMidHandle( GFX_Blob[2], true );
|
||||||
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -72,47 +72,47 @@ int main() {
|
||||||
WPADKeyDown = WPAD_ButtonsDown(WPAD_CHAN_0);
|
WPADKeyDown = WPAD_ButtonsDown(WPAD_CHAN_0);
|
||||||
WPADKeyHeld = WPAD_ButtonsHeld(WPAD_CHAN_0);
|
WPADKeyHeld = WPAD_ButtonsHeld(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);
|
||||||
|
|
||||||
// WiiMote IR Viewport Correction
|
// WiiMote IR Viewport Correction
|
||||||
P1MX = P1Mote.sx - 150;
|
P1MX = P1Mote.sx - 150;
|
||||||
P1MY = P1Mote.sy - 150;
|
P1MY = P1Mote.sy - 150;
|
||||||
|
|
||||||
// Update Stage
|
// Update Stage
|
||||||
Step = Step + 1;
|
Step = Step + 1;
|
||||||
if (Step == 720) { Step = 0; }
|
if (Step == 720) { Step = 0; }
|
||||||
SX = 320 + (sin(DegToRad(Step )) * 250);
|
SX = 320 + (sin(DegToRad(Step )) * 250);
|
||||||
SY = 240 + (cos(DegToRad(Step*3)) * 100);
|
SY = 240 + (cos(DegToRad(Step*3)) * 100);
|
||||||
|
|
||||||
// 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) ); Color = 255;
|
GRRLIB_SetBlend( (Blending+1) ); Color = 255;
|
||||||
switch (Stage) {
|
switch (Stage) {
|
||||||
case 2: Color = 160; break;
|
case 2: Color = 160; break;
|
||||||
case 3: Color = 128; break;
|
case 3: Color = 128; break;
|
||||||
case 4: Color = 64; break;
|
case 4: Color = 64; 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) );
|
||||||
|
|
||||||
// IR Pointer
|
// IR Pointer
|
||||||
if (P1Mote.state == 1) {
|
if (P1Mote.state == 1) {
|
||||||
GRRLIB_DrawImg( P1MX, P1MY, GFX_Blob[BlobType], 0, 1, 1, RGBA(Color, Color, Color, 255) );
|
GRRLIB_DrawImg( P1MX, P1MY, GFX_Blob[BlobType], 0, 1, 1, RGBA(Color, Color, Color, 255) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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), 1 );
|
||||||
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: GRRLIB_Printf( 32, 88, GFX_Font, 0xFFFFFFFF, 1, "Stage 1: Additive Blending" ); Blending = 0; break;
|
||||||
case 1: GRRLIB_Printf( 32, 88, GFX_Font, 0xFFFFFFFF, 1, "Stage 2: Alpha Light Blending" ); Blending = 1; break;
|
case 1: GRRLIB_Printf( 32, 88, GFX_Font, 0xFFFFFFFF, 1, "Stage 2: Alpha Light Blending" ); Blending = 1; break;
|
||||||
case 2: GRRLIB_Printf( 32, 88, GFX_Font, 0xFFFFFFFF, 1, "Stage 3: Multiply Blending (75%)" ); Blending = 2; break;
|
case 2: GRRLIB_Printf( 32, 88, GFX_Font, 0xFFFFFFFF, 1, "Stage 3: Multiply Blending (75%)" ); Blending = 2; break;
|
||||||
case 3: GRRLIB_Printf( 32, 88, GFX_Font, 0xFFFFFFFF, 1, "Stage 4: Multiply Blending (50%)" ); Blending = 2; break;
|
case 3: GRRLIB_Printf( 32, 88, GFX_Font, 0xFFFFFFFF, 1, "Stage 4: Multiply Blending (50%)" ); Blending = 2; break;
|
||||||
case 4: GRRLIB_Printf( 32, 88, GFX_Font, 0xFFFFFFFF, 1, "Stage 5: Multiply Blending (25%)" ); Blending = 2; break;
|
case 4: GRRLIB_Printf( 32, 88, GFX_Font, 0xFFFFFFFF, 1, "Stage 5: Multiply Blending (25%)" ); Blending = 2; break;
|
||||||
case 5: GRRLIB_Printf( 32, 88, GFX_Font, 0xFFFFFFFF, 1, "Stage 6: Invert Color Blending" ); Blending = 3; break;
|
case 5: GRRLIB_Printf( 32, 88, GFX_Font, 0xFFFFFFFF, 1, "Stage 6: Invert Color Blending" ); Blending = 3; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
GRRLIB_Render();
|
GRRLIB_Render();
|
||||||
if (WPADKeyDown & WPAD_BUTTON_RIGHT) { if (Stage < 5) { Stage += 1; } }
|
if (WPADKeyDown & WPAD_BUTTON_RIGHT) { if (Stage < 5) { Stage += 1; } }
|
||||||
|
@ -125,16 +125,16 @@ int main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ExitGame() {
|
static void ExitGame() {
|
||||||
// Deinitialize GRRLIB & Video
|
// Deinitialize GRRLIB & Video
|
||||||
GRRLIB_Exit();
|
GRRLIB_Exit();
|
||||||
|
|
||||||
// Free all memory used by textures.
|
// Free all memory used by textures.
|
||||||
GRRLIB_FreeTexture(GFX_Background);
|
GRRLIB_FreeTexture(GFX_Background);
|
||||||
GRRLIB_FreeTexture(GFX_Blob[0]);
|
GRRLIB_FreeTexture(GFX_Blob[0]);
|
||||||
GRRLIB_FreeTexture(GFX_Blob[1]);
|
GRRLIB_FreeTexture(GFX_Blob[1]);
|
||||||
GRRLIB_FreeTexture(GFX_Blob[2]);
|
GRRLIB_FreeTexture(GFX_Blob[2]);
|
||||||
GRRLIB_FreeTexture(GFX_Font);
|
GRRLIB_FreeTexture(GFX_Font);
|
||||||
|
|
||||||
// Exit application
|
// Exit application
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,16 +31,16 @@ Mtx GXmodelView2D;
|
||||||
|
|
||||||
// Basic structure to hold particle data
|
// Basic structure to hold particle data
|
||||||
typedef struct Particle {
|
typedef struct Particle {
|
||||||
u8 id;
|
u8 id;
|
||||||
float x, y;
|
float x, y;
|
||||||
float sx, sy;
|
float sx, sy;
|
||||||
u16 rot;
|
u16 rot;
|
||||||
u8 frame, framecnt, framedelay;
|
u8 frame, framecnt, framedelay;
|
||||||
u8 red, green, blue;
|
u8 red, green, blue;
|
||||||
float scale, alpha;
|
float scale, alpha;
|
||||||
float sscale, salpha;
|
float sscale, salpha;
|
||||||
float scolor;
|
float scolor;
|
||||||
GRRLIB_texImg *tex;
|
GRRLIB_texImg *tex;
|
||||||
} Particle;
|
} Particle;
|
||||||
|
|
||||||
// Vector used as a container to iterate through all members of GRRLIB_texImg
|
// Vector used as a container to iterate through all members of GRRLIB_texImg
|
||||||
|
@ -77,88 +77,88 @@ int main() {
|
||||||
u8 FPS = 0;
|
u8 FPS = 0;
|
||||||
u32 ParticleCnt = 0;
|
u32 ParticleCnt = 0;
|
||||||
|
|
||||||
// Init GRRLIB & WiiUse
|
// Init GRRLIB & WiiUse
|
||||||
GRRLIB_Init();
|
GRRLIB_Init();
|
||||||
WinW = rmode->fbWidth;
|
WinW = rmode->fbWidth;
|
||||||
WinH = rmode->efbHeight;
|
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 );
|
||||||
|
|
||||||
// Load textures
|
// Load textures
|
||||||
GFX_Background = GRRLIB_LoadTextureJPG(RGFX_Background);
|
GFX_Background = GRRLIB_LoadTextureJPG(RGFX_Background);
|
||||||
GFX_Crosshair = GRRLIB_LoadTexturePNG(RGFX_Crosshair);
|
GFX_Crosshair = GRRLIB_LoadTexturePNG(RGFX_Crosshair);
|
||||||
GFX_Smoke = GRRLIB_LoadTexturePNG(RGFX_Smoke);
|
GFX_Smoke = GRRLIB_LoadTexturePNG(RGFX_Smoke);
|
||||||
GFX_Font = GRRLIB_LoadTexturePNG(RGFX_Font);
|
GFX_Font = GRRLIB_LoadTexturePNG(RGFX_Font);
|
||||||
GRRLIB_InitTileSet( GFX_Font, 8, 16, 32 );
|
GRRLIB_InitTileSet( GFX_Font, 8, 16, 32 );
|
||||||
|
|
||||||
// Set handles
|
// Set handles
|
||||||
GRRLIB_SetMidHandle( GFX_Crosshair, true );
|
GRRLIB_SetMidHandle( GFX_Crosshair, true );
|
||||||
GRRLIB_SetMidHandle( GFX_Smoke, true );
|
GRRLIB_SetMidHandle( GFX_Smoke, true );
|
||||||
|
|
||||||
// Feed the vector with the textures
|
// Feed the vector with the textures
|
||||||
TextureList.push_back( GFX_Background );
|
TextureList.push_back( GFX_Background );
|
||||||
TextureList.push_back( GFX_Crosshair );
|
TextureList.push_back( GFX_Crosshair );
|
||||||
TextureList.push_back( GFX_Smoke );
|
TextureList.push_back( GFX_Smoke );
|
||||||
TextureList.push_back( GFX_Font );
|
TextureList.push_back( GFX_Font );
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
WPAD_ScanPads();
|
WPAD_ScanPads();
|
||||||
WPADKeyDown = WPAD_ButtonsDown(WPAD_CHAN_0);
|
WPADKeyDown = WPAD_ButtonsDown(WPAD_CHAN_0);
|
||||||
WPADKeyHeld = WPAD_ButtonsHeld(WPAD_CHAN_0);
|
WPADKeyHeld = WPAD_ButtonsHeld(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);
|
||||||
|
|
||||||
// Resetting Vars
|
// Resetting Vars
|
||||||
GRRLIB_SetBlend( GRRLIB_BLEND_ALPHA );
|
GRRLIB_SetBlend( GRRLIB_BLEND_ALPHA );
|
||||||
ParticleCnt = 0;
|
ParticleCnt = 0;
|
||||||
|
|
||||||
// WiiMote IR Viewport correction
|
// WiiMote IR Viewport correction
|
||||||
P1MX = P1Mote.sx - 150;
|
P1MX = P1Mote.sx - 150;
|
||||||
P1MY = P1Mote.sy - 150;
|
P1MY = P1Mote.sy - 150;
|
||||||
|
|
||||||
// Drawing Background
|
// Drawing Background
|
||||||
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) );
|
||||||
|
|
||||||
// Add any pending objects into the main container
|
// Add any pending objects into the main container
|
||||||
if (ParticleListTmp.size()) {
|
if (ParticleListTmp.size()) {
|
||||||
for(u32 i = 0; i<ParticleListTmp.size();i++) {
|
for(u32 i = 0; i<ParticleListTmp.size();i++) {
|
||||||
ParticleList.push_back(ParticleListTmp[i]);
|
ParticleList.push_back(ParticleListTmp[i]);
|
||||||
}
|
}
|
||||||
ParticleListTmp.clear();
|
ParticleListTmp.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update and draw all particles
|
// Update and draw all particles
|
||||||
for (vector<Particle *>::iterator PartIter = ParticleList.begin(); PartIter != ParticleList.end();) {
|
for (vector<Particle *>::iterator PartIter = ParticleList.begin(); PartIter != ParticleList.end();) {
|
||||||
if (updateParticle((*PartIter)) == true) {
|
if (updateParticle((*PartIter)) == true) {
|
||||||
GRRLIB_DrawImg( (*PartIter)->x, (*PartIter)->y, (*PartIter)->tex, (*PartIter)->rot, (*PartIter)->scale, (*PartIter)->scale, RGBA( (*PartIter)->red, (*PartIter)->green, (*PartIter)->blue, GRRLIB_ClampVar8((*PartIter)->alpha*255) ) );
|
GRRLIB_DrawImg( (*PartIter)->x, (*PartIter)->y, (*PartIter)->tex, (*PartIter)->rot, (*PartIter)->scale, (*PartIter)->scale, RGBA( (*PartIter)->red, (*PartIter)->green, (*PartIter)->blue, GRRLIB_ClampVar8((*PartIter)->alpha*255) ) );
|
||||||
} else {
|
} else {
|
||||||
free( (*PartIter) );
|
free( (*PartIter) );
|
||||||
ParticleList.erase(PartIter);
|
ParticleList.erase(PartIter);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ParticleCnt += 1;
|
ParticleCnt += 1;
|
||||||
PartIter++;
|
PartIter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw Crosshair
|
// Draw Crosshair
|
||||||
GRRLIB_DrawImg( P1MX, P1MY, GFX_Crosshair, 0, 1, 1, RGBA(255, 255, 255, 255) );
|
GRRLIB_DrawImg( P1MX, P1MY, GFX_Crosshair, 0, 1, 1, RGBA(255, 255, 255, 255) );
|
||||||
|
|
||||||
// Draw Text
|
// Draw Text
|
||||||
GRRLIB_Rectangle( 28, 28, 280, 20, RGBA(0, 0, 0, 160), 1 );
|
GRRLIB_Rectangle( 28, 28, 280, 20, RGBA(0, 0, 0, 160), 1 );
|
||||||
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_Rectangle( 28, 48, 200, 16, RGBA(0, 0, 0, 160), 1 );
|
GRRLIB_Rectangle( 28, 48, 200, 16, RGBA(0, 0, 0, 160), 1 );
|
||||||
GRRLIB_Printf ( 32, 48, GFX_Font, 0xFFFFFFFF, 1, "Number of Particle: %d", ParticleCnt );
|
GRRLIB_Printf ( 32, 48, GFX_Font, 0xFFFFFFFF, 1, "Number of Particle: %d", ParticleCnt );
|
||||||
GRRLIB_Rectangle( 28, 64, 64, 16, RGBA(0, 0, 0, 160), 1 );
|
GRRLIB_Rectangle( 28, 64, 64, 16, RGBA(0, 0, 0, 160), 1 );
|
||||||
GRRLIB_Printf ( 32, 64, GFX_Font, 0xFFFFFFFF, 1, "FPS: %d", FPS );
|
GRRLIB_Printf ( 32, 64, GFX_Font, 0xFFFFFFFF, 1, "FPS: %d", FPS );
|
||||||
|
|
||||||
// Renders the Scene
|
// Renders the Scene
|
||||||
GRRLIB_Render();
|
GRRLIB_Render();
|
||||||
FPS = CalculateFrameRate();
|
FPS = CalculateFrameRate();
|
||||||
|
|
||||||
if (WPADKeyDown & WPAD_BUTTON_B) {
|
if (WPADKeyDown & WPAD_BUTTON_B) {
|
||||||
createEffect( EFFECT_SMOKEBOMB, P1MX, P1MY );
|
createEffect( EFFECT_SMOKEBOMB, P1MX, P1MY );
|
||||||
}
|
}
|
||||||
if (WPADKeyDown & WPAD_BUTTON_HOME) {
|
if (WPADKeyDown & WPAD_BUTTON_HOME) {
|
||||||
ExitGame();
|
ExitGame();
|
||||||
}
|
}
|
||||||
|
@ -168,107 +168,107 @@ int main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void createEffect( u8 id, int _x, int _y ) {
|
static void createEffect( u8 id, int _x, int _y ) {
|
||||||
u8 _ColorAdd = 0;
|
u8 _ColorAdd = 0;
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case EFFECT_SMOKEBOMB:
|
case EFFECT_SMOKEBOMB:
|
||||||
for (u8 i = 0; i < 5; i++) {
|
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 );
|
createParticle( 1, (_x + (RANDOM * 10)), (_y + (RANDOM * 10)), (1.4f+(RANDOM*0.20)), 1.0f, 64, 64, 64 );
|
||||||
}
|
}
|
||||||
for (u8 i = 0; i < 20; i++) {
|
for (u8 i = 0; i < 20; i++) {
|
||||||
createParticle( 3, (_x + (RANDOM * 50)), (_y + (RANDOM * 50)), 1.25f, 1.5f, 92, 92, 92 );
|
createParticle( 3, (_x + (RANDOM * 50)), (_y + (RANDOM * 50)), 1.25f, 1.5f, 92, 92, 92 );
|
||||||
}
|
}
|
||||||
for (u8 i = 0; i < 5; i++) {
|
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 );
|
createParticle( 2, (_x + (RANDOM * 40)), (_y + (RANDOM * 40)), (1.0f+(RANDOM*0.20)), 1.0f, 128+_ColorAdd, 128+_ColorAdd, 128+_ColorAdd );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void createParticle( u8 _id, int _x, int _y, float _scale, float _alpha, u8 _red, u8 _green, u8 _blue ) {
|
static void createParticle( u8 _id, int _x, int _y, float _scale, float _alpha, u8 _red, u8 _green, u8 _blue ) {
|
||||||
Particle *part = (struct Particle *)calloc(1, sizeof(Particle));
|
Particle *part = (struct Particle *)calloc(1, sizeof(Particle));
|
||||||
part->id = _id;
|
part->id = _id;
|
||||||
part->x = _x;
|
part->x = _x;
|
||||||
part->y = _y;
|
part->y = _y;
|
||||||
part->rot = rand() % 360;
|
part->rot = rand() % 360;
|
||||||
part->red = _red;
|
part->red = _red;
|
||||||
part->green = _green;
|
part->green = _green;
|
||||||
part->blue = _blue;
|
part->blue = _blue;
|
||||||
part->scale = _scale;
|
part->scale = _scale;
|
||||||
part->alpha = _alpha;
|
part->alpha = _alpha;
|
||||||
|
|
||||||
part->tex = GFX_Smoke;
|
part->tex = GFX_Smoke;
|
||||||
part->sy = RANDOM;
|
part->sy = RANDOM;
|
||||||
part->sx = RANDOM;
|
part->sx = RANDOM;
|
||||||
part->sscale = 0.9985;
|
part->sscale = 0.9985;
|
||||||
part->salpha = 0.985;
|
part->salpha = 0.985;
|
||||||
switch (part->id) {
|
switch (part->id) {
|
||||||
case 1:
|
case 1:
|
||||||
part->sy = RANDOM * 0.5;
|
part->sy = RANDOM * 0.5;
|
||||||
part->sx = RANDOM * 0.5;
|
part->sx = RANDOM * 0.5;
|
||||||
part->sscale = 0.999;
|
part->sscale = 0.999;
|
||||||
part->salpha = 0.992;
|
part->salpha = 0.992;
|
||||||
part->framedelay = 10;
|
part->framedelay = 10;
|
||||||
part->framecnt = 2;
|
part->framecnt = 2;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
part->scolor = 0.98;
|
part->scolor = 0.98;
|
||||||
part->salpha = 0.95;
|
part->salpha = 0.95;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
part->sy = (RANDOM * 8);
|
part->sy = (RANDOM * 8);
|
||||||
part->sx = (RANDOM * 8);
|
part->sx = (RANDOM * 8);
|
||||||
part->salpha = 0.85;
|
part->salpha = 0.85;
|
||||||
part->scolor = 0.95;
|
part->scolor = 0.95;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ParticleListTmp.push_back( part );
|
ParticleListTmp.push_back( part );
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool updateParticle( Particle *part ) {
|
static bool updateParticle( Particle *part ) {
|
||||||
if (part->alpha < 0.05) { part->alpha -= 0.001; }
|
if (part->alpha < 0.05) { part->alpha -= 0.001; }
|
||||||
if (part->alpha < 0.1) { part->alpha -= 0.001; }
|
if (part->alpha < 0.1) { part->alpha -= 0.001; }
|
||||||
|
|
||||||
part->x += part->sx;
|
part->x += part->sx;
|
||||||
part->y += part->sy;
|
part->y += part->sy;
|
||||||
part->scale *= part->sscale;
|
part->scale *= part->sscale;
|
||||||
part->alpha *= part->salpha;
|
part->alpha *= part->salpha;
|
||||||
switch (part->id) {
|
switch (part->id) {
|
||||||
case 1:
|
case 1:
|
||||||
if (part->alpha < 0.25) { part->alpha -= 0.001; }
|
if (part->alpha < 0.25) { part->alpha -= 0.001; }
|
||||||
if (part->framecnt == 0) {
|
if (part->framecnt == 0) {
|
||||||
part->framecnt = 20;
|
part->framecnt = 20;
|
||||||
part->red -= 1;
|
part->red -= 1;
|
||||||
part->green -= 1;
|
part->green -= 1;
|
||||||
part->blue -= 1;
|
part->blue -= 1;
|
||||||
}
|
}
|
||||||
part->framecnt -= 1;
|
part->framecnt -= 1;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
part->red *= part->scolor;
|
part->red *= part->scolor;
|
||||||
part->green *= part->scolor;
|
part->green *= part->scolor;
|
||||||
part->blue *= part->scolor;
|
part->blue *= part->scolor;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ((part->scale < 0) || (part->alpha < 0)) { return false; }
|
if ((part->scale < 0) || (part->alpha < 0)) { return false; }
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ExitGame() {
|
static void ExitGame() {
|
||||||
// Deinitialize GRRLIB & Video
|
// Deinitialize GRRLIB & Video
|
||||||
GRRLIB_Exit();
|
GRRLIB_Exit();
|
||||||
|
|
||||||
// Free all memory used by textures.
|
// Free all memory used by textures.
|
||||||
for (vector<GRRLIB_texImg *>::iterator TexIter = TextureList.begin(); TexIter != TextureList.end(); TexIter++) {
|
for (vector<GRRLIB_texImg *>::iterator TexIter = TextureList.begin(); TexIter != TextureList.end(); TexIter++) {
|
||||||
free((*TexIter)->data);
|
free((*TexIter)->data);
|
||||||
free((*TexIter));
|
free((*TexIter));
|
||||||
}
|
}
|
||||||
TextureList.clear();
|
TextureList.clear();
|
||||||
|
|
||||||
// Exit application
|
// Exit application
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static u8 CalculateFrameRate() {
|
static u8 CalculateFrameRate() {
|
||||||
|
|
Loading…
Reference in a new issue