Esempio n. 1
0
int main(void) {

    PA_Init();
    PA_InitVBL();

    PA_InitText(1,0); // On the top screen

    PA_DualLoadSpritePal(0, (void*)sprite0_Pal);

    // This'll be the movable sprite...
    PA_CreateSprite(0, 0,(void*)circle_Sprite, OBJ_SIZE_32X32,1, 0, 16, 16);
    s32 x = 16;
    s32 y = 16; // Sprite's center position

    // This will be the hit circle
    PA_DualCreateSprite(1,(void*)circle_Sprite, OBJ_SIZE_32X32,1, 0, 128-16, 96-16);
    puck.x = 128;
    puck.y = 96+192+SCREENHOLE; // central position on bottom screen
    puck.vx = 0;
    puck.vy = 0; // No speed


    while(1)
    {
        if (PA_MoveSprite(0)) {
            x = PA_MovedSprite.X;
            y = PA_MovedSprite.Y;
        }

        // Collision ?
        if (PA_Distance(x, y, puck.x, puck.y-192-SCREENHOLE) < 32*32) {
            // Collision, so we'l change the pucks speed to move it out of our 'raquette'
            u16 angle = PA_GetAngle(x, y, puck.x, puck.y-192-SCREENHOLE); // New direction angle
            u16 speed = (32*32-PA_Distance(x, y, puck.x, puck.y-192-SCREENHOLE))/32; // The closer they are, the harder the hit was...
            puck.vx = (PA_Cos(angle)*speed)>>8;
            puck.vy = -(PA_Sin(angle)*speed)>>8;
        }

        puck.x += puck.vx;
        puck.y += puck.vy;

        // If the sprite touches the left or right border, flip the horizontal speed
        if ((puck.x -16 <= 0) && (puck.vx < 0)) puck.vx = -puck.vx;
        else if ((puck.x + 16 >= 256)&&(puck.vx > 0)) puck.vx = - puck.vx;

        // Same thing, for top and bottom limits...
        if ((puck.y -16 <= 0) && (puck.vy < 0)) puck.vy = -puck.vy;
        else if ((puck.y + 16 >= 192 + 192 + SCREENHOLE)&& (puck.vy > 0)) puck.vy = - puck.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(1, puck.x-16, puck.y-16);



        PA_WaitForVBL();
    }
Esempio n. 2
0
int main(void){

	PA_Init();
	PA_InitVBL();
	
	PA_InitText(1,0); // On the top screen

	PA_LoadSpritePal(0, 0, (void*)sprite0_Pal);
	
	// This'll be the movable sprite...
	PA_CreateSprite(0, 0,(void*)circle_Sprite, OBJ_SIZE_32X32,1, 0, 16, 16); 	
	s32 x = 16; s32 y = 16; // Sprite's center position
	
	// This will be the fixed circle
	PA_CreateSprite(0, 1,(void*)circle_Sprite, OBJ_SIZE_32X32,1, 0, 128-16, 96-16); 
	
	while(1)
	{
		if (PA_MoveSprite(0)){
			x = PA_MovedSprite.X;
			y = PA_MovedSprite.Y;
		}
		
		// Collision ?
		if (PA_Distance(x, y, 128, 96) < 32*32) PA_OutputText(1, 2, 10, "Collision !!");
		else PA_OutputText(1, 2, 10, "            ");

		PA_WaitForVBL();
	}
	return 0;
}
Esempio n. 3
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);
}