예제 #1
0
void main(void)
{
	ppu_on_all();//enable rendering

	//set initial coords
	
	cat_x[0]=52;
	cat_y[0]=100;
	cat_x[1]=180;
	cat_y[1]=100;

	//init other vars
	
	touch=0;//collision flag
	frame=0;//frame counter

	//now the main loop

	while(1)
	{
		ppu_waitnmi();//wait for next TV frame

		//flashing color for touch
		
		i=frame&1?0x30:0x2a;

		pal_col(17,touch?i:0x21);//set first sprite color
		pal_col(21,touch?i:0x26);//set second sprite color

		//process players
		
		spr=0;

		for(i=0;i<2;++i)
		{
			//display metasprite
			
			spr=oam_meta_spr(cat_x[i],cat_y[i],spr,!i?metaCat1:metaCat2);

			//poll pad and change coordinates
			
			pad=pad_poll(i);

			if(pad&PAD_LEFT &&cat_x[i]>  0) cat_x[i]-=2;
			if(pad&PAD_RIGHT&&cat_x[i]<232) cat_x[i]+=2;
			if(pad&PAD_UP   &&cat_y[i]>  0) cat_y[i]-=2;
			if(pad&PAD_DOWN &&cat_y[i]<212) cat_y[i]+=2;
		}

		//check for collision for a smaller bounding box
		//metasprite is 24x24, collision box is 20x20
		
		if(!(cat_x[0]+22< cat_x[1]+2 ||
		     cat_x[0]+ 2>=cat_x[1]+22||
	         cat_y[0]+22< cat_y[1]+2 ||
		     cat_y[0]+ 2>=cat_y[1]+22)) touch=1; else touch=0;

		frame++;
	}
}
예제 #2
0
파일: onepad.cpp 프로젝트: KitoHo/pcsx2
PADpoll(u8 value)
{
    return pad_poll(value);
}