//Character selection menu //@Fix glitchy BG screen and display of Arrow void ChrselMenu() { Sprite sprites[1]; //Sprite struct DrawBG(0); //Cls DrawBG(8); //Draw "How many players" BG InitMenu(1,0,0,3,_FALSE); //Init a 2 item Menu //Setup the arrow sprite SYS_disableInts(); SPR_init(16); //Sprite tile cache of 16 tiles SYS_enableInts(); // !@ Screws up SPR_initSprite(&sprites[0], &SPR_Arrow, 271, 266, TILE_ATTR(MISCPAL,TRUE,FALSE,FALSE)); //Init the Arrow Sprite VDP_setPalette(MISCPAL, SPR_Arrow.palette->data); //Init pal OBJPAL to Arrow pal echo_play_sfx(SFX_13); //"How many players are going to play today?" JOY_setEventHandler( &BtnHMenu ); //Setup joy handler to HMenu type //While no items are selected while (SItem==0) { //If 1 player hilighted if ((HItem==1) && (Trig==_FALSE)) { SPR_setPosition(&sprites[0],271,266); //Set new arrow position SPR_update(sprites, 1); //Update it } else { SPR_setPosition(&sprites[0],311, 266); SPR_update(sprites, 1); } VDP_waitVSync(); } VDP_resetSprites(); //@Toggle amt of players as appropriately if (SItem==1) { Opts[0]=_FALSE; } else { Opts[0]=PTRUE; } SPR_setPosition(&sprites[0],-128, -128); //@Kill sprite SPR_update(sprites, 1); //Update it SPR_end; //Kill sprite engine echo_wait_sfx(SFX_10); //"Let us play some hockey!" VDP_fadeOutAll(100,_FALSE); }
static void beastScrollingFX(){ u32 hscrollInc = 0; u16 vblCount = 0; u16 vramIndex = TILE_USERINDEX; short i; Sprite sprites[BALL_COUNT]; SYS_disableInts(); VDP_clearPlan(APLAN, 0); VDP_clearPlan(BPLAN, 0); /* Set a larger tileplan to be able to scroll */ VDP_setPlanSize(64, 32); /* Draw the foreground */ VDP_setPalette(PAL1, ground.palette->data); VDP_drawImageEx(BPLAN, &ground, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, vramIndex), 0, 4, FALSE, FALSE); VDP_drawImageEx(BPLAN, &ground, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, vramIndex), 24, 4, FALSE, FALSE); vramIndex += ground.tileset->numTile; VDP_setPalette(PAL0, rse_logo.palette->data); VDP_drawImageEx(APLAN, &rse_logo, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, vramIndex), 0, 6, FALSE, FALSE); vramIndex += rse_logo.tileset->numTile; for(i = 0; i < BALL_COUNT; i++) SPR_initSprite(&sprites[i], &ball_metal, 0, 0, TILE_ATTR_FULL(PAL2, TRUE, FALSE, FALSE, 0)); VDP_setPalette(PAL2, ball_metal.palette->data); SPR_init(BALL_COUNT); SYS_enableInts(); SND_startPlay_XGM(midnight); while (1){ hscrollInc = 0; VDP_waitVSync(); VDP_setHorizontalScroll(PLAN_B, -vblCount); VDP_setHorizontalScroll(PLAN_A, sinFix16(vblCount << 2)); for(i = 0; i < BALL_COUNT; i++) { // SPR_setPosition(&sprites[i], 160 + sinFix16((vblCount << 2) + (i << 5)), 100 + cosFix16((vblCount << 3) + (i << 3))); sprites[i].x = (160 + 0x80) + sinFix16((vblCount << 2) + (i << 5)); sprites[i].y = (100 + 0x80) + cosFix16((vblCount << 3) + (i << 3)); } SPR_update(sprites, BALL_COUNT); vblCount += 1; } }
int main() { VDP_setScreenWidth320(); Vector2D speed = { FIX32(0.2), FIX32(0.2) }; Vector2D position = { FIX32( 1), FIX32( 1) }; // Init joy handler JOY_init(); JOY_setEventHandler( &joyAtkHandler ); // Under construction // SPR_init( (4 * 8) + (3 * 3 * 9) ); // Knighty is 2x2 tiles and 8 frames, Wizard is 3x3 and 9 frames SPR_init( (4 * 8) + (3 * 3 * 9) ); draw_arena(); init_player_wizard(140, 128); init_player_knighty(128, 128); spr_players[1] = WIZARD_SPR; spr_players[0] = KNIGHTY_SPR; // game loop while (1) { // directionalInput( &p1, &p2 ); wizard_control(&p1, JOY_1); knighty_control(&p2, JOY_2); bounceCharacter( &speed, &position ); debugPlayers(p1, p2, p1_dir, p2_dir); // control_wizard(&p1); SPR_update(spr_players, 2); // wait for the screen to refresh VDP_waitVSync(); } SPR_end(); return 0; }
static _voidCallback *VIntCallback() { if ( VINT_SCROLL_FLAG ) { VDP_setHorizontalScroll ( PLAN_B, h_scroll-- ); // Updating Horizontal Scroll (CLOUDS) } if ( VINT_JOY_UPDATE ) { _JOYupdate ( ); SPR_setPosition ( pointer, _JOYgetPosX(), _JOYgetPosY() ); } if ( IS_PALSYSTEM || ( !IS_PALSYSTEM && ( vtimer % 6 ) ) ) { sfxpsg_frame(); } SPR_update ( sprlist, sd_cnt() ); return 0; }
static void fastStarFieldFX() { u16 vramIndex = TILE_USERINDEX; s16 i, ns, s; Sprite sprites[256]; SYS_disableInts(); VDP_clearPlan(APLAN, 0); VDP_clearPlan(BPLAN, 0); VDP_setPlanSize(32, 32); /* Draw the foreground */ VDP_drawImageEx(BPLAN, &starfield, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, vramIndex), 0, 0, TRUE, FALSE); vramIndex += starfield.tileset->numTile; /* Set the proper scrolling mode (line by line) */ VDP_setScrollingMode(HSCROLL_LINE, VSCROLL_PLANE); /* Create the scrolling offset table */ s = 1; for(i = 0; i < TABLE_LEN; i++) { scroll_PLAN_B[i] = 0; do { ns = -((random() % 3) + 1); } while (ns == s); scroll_speed[i] = ns; s = ns; } /* Setup the sprites */ SPR_init(256); for(i = 0; i < MAX_DONUT; i++) SPR_initSprite(&sprites[i], &donut, 0, 0, TILE_ATTR_FULL(PAL2, TRUE, FALSE, FALSE, 0)); SPR_update(sprites, MAX_DONUT); VDP_setPalette(PAL2, donut.palette->data); SYS_enableInts(); /* Start !!!! */ s = 0; while (TRUE) { VDP_waitVSync(); BMP_showFPS(1); /* Scroll the starfield */ VDP_setHorizontalScrollLine(PLAN_B, 2, scroll_PLAN_B, TABLE_LEN, TRUE); for(i = 0; i < TABLE_LEN; i++) scroll_PLAN_B[i] = (scroll_PLAN_B[i] + scroll_speed[i]) & 0xFF; /* Animate the donuts */ for(i = 0; i < MAX_DONUT; i++) { // SPR_setPosition(&sprites[i], (cosFix16(s + (i << 5)) << 1) + 160 - 16, sinFix16(s + (i << 5)) + 112 - 16); sprites[i].x = (cosFix16(s + (i << 5)) << 1) + 160 - 16 + 0x80; sprites[i].y = sinFix16(s + (i << 5)) + 112 - 16 + 0x80; SPR_setFrame(&sprites[i], ((s >> 4) + i) & 0x7); } s += 4; SPR_update(sprites, MAX_DONUT); } }