Exemplo n.º 1
0
// Function: main()
int main(int argc, char ** argv)
{
    PA_Init();    // Initializes PA_Lib
    PA_InitVBL(); // Initializes a standard VBL

    PA_InitText(1, 0);

    PA_EasyBgLoad(0, 1, pasplash); // Load your backgrounds...

    PA_InitBgTrans(0); // Init BgTransition system, uses background 0 but little memory...
    // If you want it to hide your sprites, set your sprites' priorities to 1 or more...

    u8 transtype = 0;

    s8 i;
    u8 vflip;

    // Infinite loop to keep the program running
    while (1)
    {
        vflip = PA_Rand()&1; // random
        transtype = PA_Rand()%5; // random

        PA_OutputText(1, 8, 8, "Transition : %d ", transtype);
        PA_OutputText(1, 10, 9, "Vflip : %d ", vflip);

        // Transition out...
        for (i = 0; i <= TRANS_LENGTH; i++) { // Fade length...
            PA_BgTransUpDown(0, // screen
                             transtype, // fade type, from 0 to 4, test them out !
                             vflip, // vertical flip
                             i); // Time, 0 being the screen completely visible, 32 completely out
            PA_WaitForVBL(); // To slow down the fades, we wait a frame...
        }

        vflip = PA_Rand()&1; // random
        transtype = PA_Rand()%5; // random

        PA_OutputText(1, 8, 8, "Transition : %d ", transtype);
        PA_OutputText(1, 10, 9, "Vflip : %d ", vflip);

        // Transition back in...
        for (i = TRANS_LENGTH; i >= 0; i--) { // Fade length...
            PA_BgTransUpDown(0, // screen
                             transtype, // fade type, from 0 to 4, test them out !
                             vflip, // vertical flip
                             i); // Time, 0 being the screen completely visible, 32 completely out
            PA_WaitForVBL(); // To slow down the fades, we wait a frame...
        }


        PA_WaitForVBL();
    }

    return 0;
} // End of main()
Exemplo n.º 2
0
// Function: main()
int main(int argc, char ** argv)
{
	u8 i;
	
	PA_Init();    // Initializes PA_Lib
	PA_InitVBL(); // Initializes a standard VBL
	
	
	// Load 8bit palettes for sprites...
	PA_LoadSpritePal(0,0,(void*)ds_Pal);
	PA_LoadSpritePal(0,1,(void*)giz_Pal);
	PA_LoadSpritePal(0,2,(void*)gp_Pal);
	PA_LoadSpritePal(0,3,(void*)psp_Pal);
	
	// Create sprites
	PA_CreateSprite(0,0,(void*)ds_Sprite,OBJ_SIZE_64X64,1,0,PA_Rand()%192,PA_Rand()%128);
	PA_CreateSprite(0,1,(void*)giz_Sprite,OBJ_SIZE_64X64,1,1,PA_Rand()%192,PA_Rand()%128);
	PA_CreateSprite(0,2,(void*)gp_Sprite,OBJ_SIZE_64X64,1,2,PA_Rand()%192,PA_Rand()%128);
	PA_CreateSprite(0,3,(void*)psp_Sprite,OBJ_SIZE_64X64,1,3,PA_Rand()%192,PA_Rand()%128);
	
	//Set the main palette
	BG_PALETTE[0] = PA_RGB(27,27,27); 
	// Infinite loop to keep the program running
	while (1)
	{
		PA_WaitForVBL();

		for(i=0;i<4;i++) PA_MoveSprite(i);
		
	}
	
	return 0;
} // End of main()
Exemplo n.º 3
0
// Function: main()
int main(int argc, char ** argv)
{
    PA_Init();    // Initializes PA_Lib
    PA_InitVBL(); // Initializes a standard VBL

    PA_InitText(1, 0);

    PA_EasyBgLoad(0, 1, pasplash); // Load your backgrounds...

    u8 fadetype0 = 0;

    s8 i;

    // Infinite loop to keep the program running
    while (1)
    {


        // First we fade out... to fade out, move the time from 0 to 32, 32 included !
        for (i = 0; i <= 32; i++) {
            PA_WindowFade(0, // screen
                          fadetype0, // fade type, from 0 to 7, test them out !
                          i); // Time, 0 being the screen completely visible, 32 completely out
            PA_WaitForVBL(); // To slow down the fades, we wait a frame...
        }


        fadetype0 = PA_Rand()&7; // Random fade type for screen 0... from 0 to 7
        PA_OutputText(1, 8, 9, "Window Fade : %d  ", fadetype0);


        // To fade in, same thing, but from 32 to 0 included...
        for (i = 32; i >= 0; i--) {
            PA_WindowFade(0, fadetype0, i);
            PA_WaitForVBL(); // To slow down the fades, we wait a frame...
        }

        fadetype0 = PA_Rand()&7; // Random fade type for screen 0...
        PA_OutputText(1, 8, 9, "Window Fade : %d  ", fadetype0);



        PA_WaitForVBL();
    }

    return 0;
} // End of main()
Exemplo n.º 4
0
void monster::move(int move_cnt)
{
	if(y < 390)
		y = y + move_cnt;
	else{
		x = PA_Rand()%250;
		y = 10;
	}
}
Exemplo n.º 5
0
// 싱글 플레이 스타트
void singleplay_start() {
	// 각각의 객체 생성
	hero player;
	princess prin;
	monster mons1;
	water drop_water1;
	water drop_water2;
	water drop_water3;
	water drop_water4;
	crystal_Ball ball;

	// 랜덤으로 x좌표지정
	drop_water1.x = PA_Rand()%250;
	drop_water2.x = PA_Rand()%250;
	drop_water3.x = PA_Rand()%250;
	drop_water4.x = PA_Rand()%250;
	mons1.x = PA_Rand()%250;

	// 각각의 객체 이미지 출력
	// 물방울 그림 출력의 경우 (첫번째 인자 - spriteNUM, 두번째인자 - objNUM)
	drop_water1.water_setting(SPRITE2_PAL, OBJ2_NUM);
	drop_water2.water_setting(SPRITE3_PAL, OBJ3_NUM);
	drop_water3.water_setting(SPRITE4_PAL, OBJ4_NUM);
	drop_water4.water_setting(SPRITE5_PAL, OBJ5_NUM);
	ball.ball_setting(SPRITE6_PAL, OBJ6_NUM);
	mons1.monster_setting(SPRITE7_PAL, OBJ7_NUM, mons1.x);

	while(1) // 여기에서 게임이 동작!!
	{
		/* 텍스트 출력부분- 게임정보 (계속적으로 출력)*/
		PA_OutputText(DOWN_SCREEN, 1, 21, "Stage%d", gp.stage_num);
		PA_OutputText(DOWN_SCREEN, 9, 21, "Score:%d", gp.score);
		PA_OutputText(DOWN_SCREEN, 18, 21, "Odd Monster:%d",gp.oddmonster);
		PA_OutputText(DOWN_SCREEN, 18, 22, "My Crystals:%d",gp.crystals);

		// 객체 이동
		player.move();
		prin.move(1);
		mons1.move(1);
		drop_water1.move(3);
		drop_water2.move(2);
		drop_water3.move(3);
		drop_water4.move(2);

		// 몬스터와 크리스탈이 충돌했을 때,
		if (PA_Distance(mons1.x, mons1.y, ball.x, ball.y) < 32*32) {
			gp.score = gp.score+50;
			mons1.y = mons1.y-100; // 몬스터가 뒤로 밀리는 현상
			mons1.hp = mons1.hp-15; // 몬스터의 피가 15씩 감소
			ball.x = -100;
			ball.y = -100;
			if(mons1.hp<0)
			{
				gp.oddmonster--;
				gp.score = gp.score+100;
				mons1.~monster();
			}
		}
		// 물방울을 주인공이 먹었을 때
		if (PA_Distance(drop_water1.x, drop_water1.y-240, player.x, player.y) < 16*8) {
			drop_water1.x = PA_Rand()%250;
			drop_water1.y = 0;
			gp.crystals++;
		}
		if(PA_Distance(drop_water2.x, drop_water2.y-240, player.x, player.y) < 16*8) {
			drop_water2.x = PA_Rand()%250;
			drop_water2.y = 0;
			gp.crystals++;
		}
		if(PA_Distance(drop_water3.x, drop_water3.y-240, player.x, player.y) < 16*8) {
			drop_water3.x = PA_Rand()%250;
			drop_water3.y = 0;
			gp.crystals++;
		}
		if(PA_Distance(drop_water4.x, drop_water4.y-240, player.x, player.y) < 16*8) {
			drop_water4.x = PA_Rand()%250;
			drop_water4.y = 0;
			gp.crystals++;
		}

		// 크리스탈 카운트 ( 떨어지는 물방울을 먹은 개수 만큼 볼 생성 )
		if(gp.crystals > 0 )
			gp.crystals = ball.move(player.x, gp.crystals); // 볼 생성

		/******************************** Motion Area ****************************************/

		move_sprite(SPRITE1, player.x, player.y); // hero 좌표 변경 후 출력
		move_sprite(SPRITE9, prin.x, prin.y); // princess 좌표 변경 후 출력

		dual_move(SPRITE2, drop_water1.x, drop_water1.y); // 물방울 좌표 변경 후 출력
		dual_move(SPRITE3, drop_water2.x, drop_water2.y); // 물방울 좌표 변경 후 출력
		dual_move(SPRITE4, drop_water3.x, drop_water3.y); // 물방울 좌표 변경 후 출력
		dual_move(SPRITE5, drop_water4.x, drop_water4.y); // 물방울 좌표 변경 후 출력

		if(mons1.y > 375)
			break;
		else
			dual_move(SPRITE7, mons1.x, mons1.y); // 몬스터 좌표 변경 후 출력

		// 크리스탈 좌표 변경 후 출력
		if(gp.crystals > 0)
			dual_move(SPRITE6, ball.x, ball.y);

		PA_WaitForVBL();
	}

	UnLoad_Screen();
	PA_LoadBackground(UP_SCREEN, BG2, &gameover);
	PA_LoadBackground(DOWN_SCREEN, BG2, &gameover);
	wait(100);
}
Exemplo n.º 6
0
int main(void)
{

// Initialise the lib...
PA_Init();
PA_InitVBL(); 

PA_InitText(1, 0);

// Load the palettes for the sprites on both screens
PA_DualLoadSpritePal(0, (void*)sprite0_Pal);

s32 i; // will be used in for loops to cycle through the frisbees...

PA_InitRand(); // Init the random stuff...

for (i = 0; i < 10; i++){
	// Sprite initial position...
	frisbee[i].x = (PA_Rand()%256)-16; // random position on the screen
	frisbee[i].y = 192+SCREENHOLE + (PA_Rand()%192)-16; // random position on the bottom screen; 
	
	// Speed of frisbee in both ways
	frisbee[i].vx = 0;
	frisbee[i].vy = 0;
	
	frisbee[i].angle = 0;	
	
	// Create the sprite on both screens...
	PA_DualCreateSprite(FRISBEE+i, (void*)frisbee_Sprite, OBJ_SIZE_32X32, 1, 0, frisbee[i].x-16, frisbee[i].y-16); 
	PA_DualSetSpriteRotEnable(FRISBEE+i, i); // Enable rotation/zoom, rotset 0
}

	while(1)
	{
		for (i = 0; i < 10; i++){
			// Move with the stylus, or move on...
			if (PA_MoveSprite(FRISBEE+i)){
				frisbee[i].x = PA_MovedSprite.X;
				frisbee[i].y = PA_MovedSprite.Y + 192 + SCREENHOLE;
				frisbee[i].vx = PA_MovedSprite.Vx;		frisbee[i].vy = PA_MovedSprite.Vy; 
			}
			else{
				// Now, the frisbee's fixed point position will be updated according to the speed...
				frisbee[i].x += frisbee[i].vx;
				frisbee[i].y += frisbee[i].vy;
			
				// If the sprite touches the left or right border, flip the horizontal speed
				if ((frisbee[i].x - 16 <= 0) && (frisbee[i].vx < 0)) frisbee[i].vx = -frisbee[i].vx; 
				else if ((frisbee[i].x + 16 >= 256)&&(frisbee[i].vx > 0)) frisbee[i].vx = - frisbee[i].vx;
		
				// Same thing, for top and bottom limits...
				if ((frisbee[i].y - 16 <= 0) && (frisbee[i].vy < 0)) frisbee[i].vy = -frisbee[i].vy;
				else if ((frisbee[i].y + 16 >= 192 + 192 + SCREENHOLE)&& (frisbee[i].vy > 0)) frisbee[i].vy = - frisbee[i].vy;		
				// The bottom limit is at the bottom of the bottom screen, so that would be 2 screen heights, plus the space in between...
				PA_DualSetSpriteXY(FRISBEE+i, frisbee[i].x-16, frisbee[i].y-16);
		
			}
			frisbee[i].angle+=4; // Make the frisbee turn...
			PA_DualSetRotsetNoZoom(i, frisbee[i].angle);
		}
		
	
	PA_WaitForVBL();  // Synch to the framerate...
	}

return 0;
}