int main(){ SYS_SetResetCallback(WiiResetPressed); SYS_SetPowerCallback(WiiPowerPressed); WPAD_SetPowerButtonCallback(WiimotePowerPressed); VIDEO_Init(); if(CONF_GetAspectRatio()) { SCREEN_WIDTH = 720; } else { SCREEN_WIDTH = 640; } initializeinput(); initializeworld(); GRRLIB_InitVideo(); GRRLIB_Start(); startscreen(); while(1){ if(!fadeout) { updateinput(); updateworld(); updatetiles(); updateoverlay(); } drawworld(); drawcursor(); drawoverlay(); //When hitting home do a slow fade to black, //if it is totally black do the actual exit if (wpadheld & WPAD_BUTTON_HOME || HWButton) fadeout = true; if(fadeout) { fadeout_opacity += 5; if(fadeout_opacity >= 270) { if(HWButton) SYS_ResetSystem(HWButton, 0, 0); return 0; } GRRLIB_Rectangle(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, fadeout_opacity > 255 ? 255 << 24 : fadeout_opacity << 24, true); } GRRLIB_Render(); } return 0; }
char singleloop(GameStruct* game) { PlayerStruct singlep; MainStruct mains; ItemStruct zombie[MAX_ZOMBIES]; ItemStruct shots[2]; init(&mains, &singlep, 1, game, zombie, shots); for(;; game->frames++) { WaitVsync(1); drawoverlay(game, &singlep); gameflags(game); playerflags(&singlep); singlep.joypad = ReadJoypad(0); if(singlep.life <= 0) { switch(gameovermenu(game, &singlep)) { case 1: return 1; case 2: return 0; default: break; } } else if(singlep.joypad&BTN_SELECT && game->flagcount >= DEBOUNCE_DELAY) { game->flagcount = 0; if(game->flags & GAMEPAUSED) game->flags &= ~GAMEPAUSED; else game->flags |= GAMEPAUSED; } if(game->flags & GAMEPAUSED) continue; rendermap(&mains, 1); screenSections[1].scrollX = mains.x.s; screenSections[1].scrollY = mains.y.s; singlemove(&singlep, &mains, shots); inputanim(&singlep); singlep.gundelay++; for(int i = 0; i < 2; i++) handleshot(&mains, game, &singlep, &shots[i], zombie); necromancer(zombie, &mains, game, &singlep, 1); if(!(singlep.flags & PLAYERHURT) || game->frames&2) { sprites[1].x = sprites[2].x = singlep.x; sprites[1].y = singlep.y; sprites[2].y = singlep.y + TILE_HEIGHT; } else { sprites[1].x = sprites[2].x = DISABLED_SPRITE; sprites[2].y = sprites[1].y = DISABLED_SPRITE; } } }