示例#1
0
int main(int argc, char **argv, char **env)
{
	float speed;

#ifndef WITH_SERIAL_PTY
	set_conio_terminal_mode();
#endif

	Verilated::commandArgs(argc, argv);
	dut = new Vdut;

	Verilated::traceEverOn(true);
	tfp = new VerilatedVcdC;
	dut->trace(tfp, 99);
	tfp->open("dut.vcd");

	struct sim s;
	sim_init(&s);

#ifdef WITH_SERIAL_PTY
	console_init(&s);
	console_open(&s);
#endif

#ifdef WITH_ETH
	eth_init(&s, "/dev/net/tap0", "tap0"); // XXX get this from /tmp/simethernet
	eth_open(&s);
#endif

	s.run = true;
	while(s.run) {
		sim_tick(&s);
		if(SYS_CLK) {
#ifdef WITH_SERIAL
			if(console_service(&s) != 0)
				s.run = false;
#endif
#ifdef WITH_ETH
			ethernet_service(&s);
#endif
		}
	}
	s.end = clock();

	speed = (s.tick/2)/((s.end-s.start)/CLOCKS_PER_SEC);

	printf("average speed: %3.3f MHz\n\r", speed/1000000);

	tfp->close();


#ifdef WITH_SERIAL_PTY
	console_close(&s);
#endif
#ifdef WITH_ETH
	eth_close(&s);
#endif

	exit(0);
}
示例#2
0
文件: temp_1.c 项目: yeaslism/gittest
int main()
{
	set_conio_terminal_mode();
	acc_tick=last_tick=0;

	while(bLoop) {
		//타이밍처리
		clock_gettime(CLOCK_MONOTONIC,&work_timer);
		double cur_tick = work_timer.tv_sec +
			(double)(work_timer.tv_nsec * 1e-9);
		double delta_tick = cur_tick - last_tick;
		last_tick = cur_tick;
		//실시간 입력
		if(kbhit() != 0) {
			char ch = getch();
			if(ch == 'q') {
				bLoop = 0;
				puts("Bye~ \r");
			}
		}
		//타이밍 계산
		acc_tick += delta_tick;
		if(acc_tick > 1.0) {
			puts("tick...\r");
			acc_tick = 0;
		}

	}

	return 0;

}
示例#3
0
文件: ex2.c 项目: yeongeun0325/cygwin
int main()
{
	set_conio_terminal_mode();
	acc_tick=0;
	last_tick=0;

	//putTitle(1,5,0,4,pstr);
	
	int bLoop=1;
	while(bLoop){
		if(kbhit()!=0){
			char ch=getch();
			if(ch=='q'){
				bLoop=0;
			}
		}
		clock_gettime(CLOCK_MONOTONIC,&work_timer);
		double cur_tick=work_timer.tv_sec+(double)(work_timer.tv_nsec*1e-9);
		
		double delta_tick=cur_tick-last_tick;
		last_tick=cur_tick;
		acc_tick+=delta_tick;

		if(acc_tick>1.0){
			acc_tick=0;
			nCount--;
			system("clear");
			putTitle(nCount,nCount+4,0,8,9,pstr);
			//printf("%d\r\n",nCount);

			
		}
	}
}
示例#4
0
int main(void)
{
    set_conio_terminal_mode();
    wuerfel_print(1);
    Top_Cross();
    
    while(1)
    {
        if(kbhit())
        {
            switch(getch())
            {
                case 'q':
                case 'Q':
                    return 0;
  
                case '0':
                    wuerfel_print(0);
                    break;
                case '1':
                    wuerfel_print(1);
                    break;
                case '2':
                    wuerfel_print(2);
                    break;
                case '3':
                    wuerfel_print(3);
                    break;
                    
            }
        }
        
    }
}
示例#5
0
文件: core.cpp 项目: ZhreShold/OpenZL
	/// <summary>
	/// wait for the specficed ms until keypressed
	/// </summary>
	/// <param name="ms">The ms to wait.</param>
	/// <returns>The key pressed(ASC-II not guaranteed).</returns>
	int waitkey(double ms)
	{
		int key = -1;
		double start = get_real_time();
		double end = start + ms / 1000;

#if defined(__unix__) || defined(__unix) || defined(unix) || (defined(__APPLE__) && defined(__MACH__))
		set_conio_terminal_mode();
#endif

		if (ms <= 0)
		{
			// disable timer if ms <= 0
			end = DBL_MAX;
		}

		while (key == -1)
		{
			key = kb_hit();
			//printf("%d", (int)get_elapsed_time_ms(start));
			if (get_real_time() >= end)
			{
				break;
			}
		}
		//std::cin.get();
#if defined(__unix__) || defined(__unix) || defined(unix) || (defined(__APPLE__) && defined(__MACH__))
		reset_terminal_mode();
#endif
		return key;
	}
示例#6
0
文件: ex8.c 项目: dlawltjs/gittest
int main()
{
	system("clear");

	for(int i=0;i<2;i++) {
		map_init(&gScreenBuf[i]);
		map_new(&gScreenBuf[i],35,16);
	
	
	}

	map_init(&gPlayer);
	map_load(&gPlayer,"plane1.dat");
	
	Plane_init(&gPlayerObject,&gPlayer,17,10);
	
	set_conio_terminal_mode();
	acc_tick = last_tick = 0;

	while(bLoop) {

		//타이밍처리
		clock_gettime(CLOCK_MONOTONIC,&work_timer);
		double cur_tick = work_timer.tv_sec + (double)(work_timer.tv_nsec * 1e-9);
		double delta_tick = cur_tick - last_tick;
		last_tick = cur_tick;

		//실시간입력	
		if(kbhit() != 0) {
			char ch = getch();
			if(ch == 'q') {
				bLoop = 0;
				puts("bye~\r");
			}
			//gPlayerObject.fpApply(&gPlayerObject,delta_tick,ch);
			gPlayerObject.fpApply(&gPlayerObject,delta_tick,ch);
		}

		//타이밍계산
		acc_tick += delta_tick;
		if(acc_tick > 0.1) {
			//puts("tick...\r");
			gotoxy(0,0);
			map_drawTile(&gScreenBuf[0],0,0,&gScreenBuf[1]);
			
			gPlayerObject.fpDraw(&gPlayerObject,&gScreenBuf[1]);
			//Plane_Draw(&gPlayerObject,&gScreenBuf[1]);

			map_dump(&gScreenBuf[1],Default_Tilepalete);
			acc_tick = 0;
		}
	}


	return 0;
}
示例#7
0
void motor_usals(int frontend_fd, double site_lat, double site_long, double sat_long)
{
	if (ioctl(frontend_fd, FE_SET_TONE, SEC_TONE_OFF) == -1)
		perror("FE_SET_TONE ERROR!");
	usleep(20000);

	if (ioctl(frontend_fd, FE_SET_VOLTAGE, SEC_VOLTAGE_18) == -1)
		perror("FE_SET_VOLTAGE ERROR!");
	usleep(20000);

	double r_eq = 6378.14;		// Earth radius
	double r_sat = 42164.57;	// Distance from earth centre to satellite

	site_lat  = radian(site_lat);
	site_long = radian(site_long);
	sat_long  = radian(sat_long);

	double declination = degree( atan( r_eq * sin(site_lat) / ( (r_sat - r_eq) + (r_eq * (1 - cos(site_lat))) ) ) );

	// x = [0], y = [1], z = [2]
	double dishVector[3] = { r_eq * cos(site_lat), 0, r_eq * sin(site_lat) };
	double satVector[3] = { r_sat * cos(site_long - sat_long), r_sat * sin(site_long - sat_long), 0 };
	double satPointing[3] = { satVector[0] - dishVector[0], satVector[1] - dishVector[1], satVector[2] - dishVector[2] } ;

	double motor_angle = degree( atan( satPointing[1]/satPointing[0] ) );

	int sixteenths = fabs(motor_angle) * 16.0 + 0.5;
	int angle_1, angle_2;
	angle_1 = motor_angle > 0.0 ? 0xd0 : 0xe0;
	angle_1 |= sixteenths >> 8;
	angle_2  = sixteenths & 0xff;

	printf("Long: %.2f, Lat: %.2f, Orbital Pos: %.2f, RotorCmd: %02x %02x, motor_angle: %.2f declination: %.2f\n", degree(site_long), degree(site_lat), degree(sat_long), angle_1, angle_2, motor_angle, declination);

	struct dvb_diseqc_master_cmd usals_cmd = { { 0xe0, 0x31, 0x6e, angle_1, angle_2, 0x00 }, 5 };

	diseqc_send_msg(frontend_fd, usals_cmd);

	printf("Waiting for motor to move, either wait 45sec or hit 's' to skip\n");

    int c;
    int sec = time(NULL);
    set_conio_terminal_mode();
    do {
		sleep(1);
		if ( kbhit() )
	   		c = kbgetchar(); /* consume the character */
    } while( (char)c != 's' && sec+45 > time(NULL) );
	reset_terminal_mode();
}
示例#8
0
void motor_gotox(int frontend_fd, int pmem)
{
	struct dvb_diseqc_master_cmd gotox_cmd = { { 0xe0, 0x31, 0x6B, pmem, 0x00, 0x00 }, 4 };
	diseqc_send_msg(frontend_fd, gotox_cmd);
	printf("Waiting for motor to move, either wait 45sec or hit 's' to skip\n");
    int c;
    int sec = time(NULL);
    set_conio_terminal_mode();
    do {
		sleep(1);
		if ( kbhit() )
	   		c = kbgetchar(); /* consume the character */
    } while( (char)c != 's' && sec+45 > time(NULL) );
	reset_terminal_mode();
}
示例#9
0
int main(){
    set_conio_terminal_mode();
    int nCount=0;
    int bLoop=1;
    int xpos,ypos;
    xpos=0;ypos=1;
    char cmd;
    while(bLoop){
    // scanf("%c",&cmd);
        if(kbhit() != 0){
            cmd = getch();
            switch(cmd){
                case 'w':
                ypos-=1;
                break;
                case 's':
                ypos+=1;
                break;
                case 'a':
                xpos-=1;
                break;
                case 'd':
                xpos+=1;
                break;
                case 'q':
                bLoop = 0;
                break;
            }
            if(cmd == 'q'){
                bLoop =0;
            }
            printf("%d \r\n",(int)cmd);
        }
        printf("%d \r",nCount);
        nCount++;
        nCount %=10;

        system("clear");
        drawMyBox(xpos,ypos,0,44,1,3);
        drawMyBox(nCount,5,0,42,1,5);
        gotoxy(0,20);
        printf("-----------------------");

    }
    reset_terminal_mode();
    return 0;
}
示例#10
0
void spektrum_satellite_init (void) {
	
	int32_t i;
	for (i=0; i<16; i++) {
		sat.channels[i]=-500;
		channel_center[i]=0;
		joystick_axes[i]=0;
		joystick_buttons[i]=0;
		joy_max[i]=32700;
		joy_min[i]=-32700;
	}
	sat.channels[RC_THROTTLE]=0;
	channel_center[RC_YAW]=0;
	joystick_filedescriptor=open_joystick(JOYSTICK_DEVICE);
	last_update=time_keeper_get_millis();
	
	#ifdef KEYBOARD_ACTIVE
	set_conio_terminal_mode();
	#endif
}
示例#11
0
int main()
{
	//srand((float)time(NULL)); //랜덤 함수
	
	for(int i=0;i<2;i++)
	{
		map_init(&gScreenBuf[i]);
		map_new(&gScreenBuf[i],40,25);
	}

	map_init(&gPlayerModel);
	map_load(&gPlayerModel,"plane3.dat");

	map_init(&gBulletModel);
	map_load(&gBulletModel,"plasma1.dat");

	map_init(&gAlienModel);
	map_load(&gAlienModel,"alien1.dat");

	map_init(&gMissileModel);
	map_load(&gMissileModel,"missile.dat");

	map_init(&gFishModel);
	map_load(&gFishModel,"fish1.dat");

//비행기 init
	Plane_init(&gPlayerObject,&gPlayerModel,20,22);

	gPlayerObject.m_nFSM = 1;
	
//에일리언 총알 init
	for(int i=0;i< sizeof(gBulletObject)/sizeof(_S_BULLET_OBJECT) ;i++)
	{
		bullet_init(&gBulletObject[i],0,0,0,&gBulletModel);
		
	}

//비행기 총알 init
	for(int i=0;i< sizeof(gMissileObject)/sizeof(_S_BULLET_OBJECT) ;i++)
	{
		bullet_init(&gMissileObject[i],0,0,0,&gMissileModel);
		
	}

//에일리언 갯수와 위치
	double TablePosition1[] = {0,6.0,30.0,13.0};

	for(int i=0;i<4;i++)
	{
	
		_S_ALIEN_OBJECT *pObj = &gAlienObjects[i];
		alien_init(pObj,&gAlienModel);
		pObj->m_fXpos = TablePosition1[i];
		pObj->m_fYpos = 2;
		pObj->m_nFSM = 1;
		
		gAlienObjects[i].m_pBullet = &gBulletObject[i];
	}

//물고기 init
	//srand(time(NULL));
	double TablePosition2[] = {6.0,19.0,31.0};
	//double TablePosition3[] = {5.0,15.0};
	
	for(int i=0;i<3;i++) 
	{
		_S_FISH_OBJECT *pObj = &gFishObject[i];
		Fish_init(pObj,&gFishModel);
		pObj->m_fXpos = TablePosition2[i]; //rand() % 20; 랜덤값을 불러온다
		pObj->m_fYpos = 2;
		pObj->m_nFSM = 2;
		
		
	}
	

	set_conio_terminal_mode();
	acc_tick=last_tick=0;

	system("clear");

//플레이상태로 만들기
	gPlayerObject.m_nFSM = 1;

	while(bLoop) {
		//타이밍처리 
		clock_gettime(CLOCK_MONOTONIC,&work_timer);
		double cur_tick = work_timer.tv_sec + 
			(double)(work_timer.tv_nsec * 1e-9);
		double delta_tick = cur_tick - last_tick;
		last_tick = cur_tick;
		//실시간 입력
		if(kbhit() != 0) {
			char ch = getch();
			if(ch == 'q') {
				bLoop = 0;
				puts("bye~ \r");
			} //비행기 총알
			else if(ch=='j') {
				for(int i=0;i<sizeof(gMissileObject)/sizeof(_S_BULLET_OBJECT);i++) {
					_S_BULLET_OBJECT *pObj = &gMissileObject[i];
					
						if(pObj->m_nFSM == 0) { //슬립상태라면....
							gMissileObject[i].pfFire(pObj,gPlayerObject.m_fXpos,gPlayerObject.m_fYpos,
							10,0,-1,5.0);
							break;
					}
				}
			}		
	
	//비행기apply
			gPlayerObject.pfApply(&gPlayerObject,delta_tick,ch);
		}
	
	//비행기총알 apply
		for(int i=0;i< sizeof(gMissileObject)/sizeof(_S_BULLET_OBJECT) ;i++)
		{	
			_S_BULLET_OBJECT *pObj = &gMissileObject[i];
			pObj->pfApply(pObj,delta_tick);
		}	
	//에일리언총알 apply	
		for(int i=0;i< sizeof(gBulletObject)/sizeof(_S_BULLET_OBJECT) ;i++)
		{	
			_S_BULLET_OBJECT *pObj = &gBulletObject[i];
			pObj->pfApply(pObj,delta_tick);
		}	

	//에일리언apply
		for(int i=0;i<4;i++)
	
		{		
			_S_ALIEN_OBJECT *pObj = &gAlienObjects[i];
			pObj->pfApply(pObj,delta_tick);
		}	
	
	//물고기 apply	
	for(int i=0;i<3;i++)
	
		{		
			_S_FISH_OBJECT *pObj = &gFishObject[i];
			pObj->pfApply(pObj,delta_tick);
		}	
	
	//충돌-에일리언총알에 비행기가 맞을때
		for(int i=0;i< sizeof(gBulletObject)/sizeof(_S_BULLET_OBJECT) ;i++)
		{
			_S_BULLET_OBJECT *pObj = &gBulletObject[i];
			
				if(pObj->m_nFSM != 0) {
				
					double dist = getDistance_1(pObj,&gPlayerObject); 

						if(dist < 0.25) {  
							pObj->m_nFSM = 0;
							gPlayerObject.m_nFSM = 0;
							printf("---------------GAME OVER----------------\r\n");
							bLoop = 0;
				}

			}
		}
	
	//충돌-에일리언이 비행기 총알에 맞을때
		for(int i=0;i< sizeof(gMissileObject)/sizeof(_S_BULLET_OBJECT) ;i++)
		{
			_S_BULLET_OBJECT *pObj = &gMissileObject[i];
			
				if(pObj->m_nFSM != 0) {
				
					double dist = getDistance_2(pObj,&gAlienObjects[i]); 
		
						if(dist < 4.0) {  
							gAlienObjects[i].m_nFSM = 0;	
							//printf("---------------GAME WIN----------------\r\n");
				}
			}
		}
	
	//충돌-물고기에 비행기가 맞을때
		for(int i=0;i<2;i++)
		{
			_S_FISH_OBJECT *pObj = &gFishObject[i];
			
				if(pObj->m_nFSM != 0) {
				
					double dist = getDistance_3(pObj,&gPlayerObject); 

						if(dist < 1.0) {  
							//pObj->m_nFSM = 0;
							gPlayerObject.m_nFSM = 0;
							printf("---------------GAME OVER----------------\r\n");
							bLoop = 0;
				}

			}
		}
		
		//타이밍 계산 
		acc_tick += delta_tick;
		if(acc_tick > 0.1) {
			
            gotoxy(0,0);
			map_drawTile(&gScreenBuf[0],0,0,&gScreenBuf[1]);
		
		//비행기draw	
			gPlayerObject.pfDraw(&gPlayerObject,&gScreenBuf[1]); 

		//에일리언 draw	
            for(int i=0;i<4;i++)	
			{
				_S_ALIEN_OBJECT *pObj = &gAlienObjects[i];
				pObj->pfDraw(pObj,&gScreenBuf[1]);

			}
		
		//에일리언 총알 draw
			for(int i=0;i< sizeof(gBulletObject)/sizeof(_S_BULLET_OBJECT) ;i++)
			{	
				_S_BULLET_OBJECT *pObj = &gBulletObject[i];
			 	pObj->pfDraw(pObj,&gScreenBuf[1]);
			}	
		//비행기 총알 draw
			for(int i=0;i<sizeof(gMissileObject)/sizeof(_S_BULLET_OBJECT);i++) 
			{
					_S_BULLET_OBJECT *pObj = &gMissileObject[i];		
					pObj->pfDraw(pObj,&gScreenBuf[1]);
			}
		//물고기 draw
			 for(int i=0;i<3;i++)	
			{
				_S_FISH_OBJECT *pObj = &gFishObject[i];
				pObj->pfDraw(pObj,&gScreenBuf[1]);

			}
	
			map_dump(&gScreenBuf[1],Default_Tilepalete);
			
			puts("move : w,a,s,d \r");
			puts("quit : q \r");
			
			acc_tick = 0;
		}

	}

	return 0;

}
示例#12
0
文件: ex10.c 项目: tamjung00/gittest
int main()
{
    set_conio_terminal_mode();
	acc_tick=last_tick=0;
	
    system("clear");

	for(int i =0;i<2;i++) //총알
	{
		map_init(&gScreenBuffer[i]);
		map_new(&gScreenBuffer[i],35,16);
	}

	
	map_init(&gPlayer);
	map_load(&gPlayer,"plane1.dat");

	Plane_init(&gPlayerObject,&gPlayer,17,10);

	double target_x,target_y;
	double center_x,center_y;
	center_x = 14;
	center_y = 7;
	
	target_x = 14;
	target_y = 3;
	
	double angle = 0;
	
	
	
	while(bLoop) {
		//타이밍처리 
		clock_gettime(CLOCK_MONOTONIC,&work_timer);
		double cur_tick = work_timer.tv_sec + 
			(double)(work_timer.tv_nsec * 1e-9);
		double delta_tick = cur_tick - last_tick;
		last_tick = cur_tick;
		
		//실시간 입력
		if(kbhit() != 0) {
			char ch = getch();
			if(ch == 'q') {
				bLoop = 0;
				puts("bye~ \r");
			}
			//Plane_Apply(&gPlayerObject,delta_tick,ch);
            
            gPlayerObject.fpApply(&gPlayerObject,delta_tick,ch);
        }
         
         //apply 위치

		angle += (delta_tick * 45);
		double tx,ty;
		double rad = angle/180.0 * 3.141592;
		tx = (target_x - center_x) *cos(rad) - (target_y - center_y) * sin(rad);
		ty = (target_x - center_x) *sin(rad) - (target_y - center_y) * cos(rad);
		tx += center_x;
		ty += center_y;
		

        //타이밍 계산 
		acc_tick += delta_tick;
		if(acc_tick > 0.1) {
			//puts("tick...\r");
			gotoxy(0,0);
			//map_drawTile(&gScreenBuf[0],0,0,&gScreenBuf[1]);
			map_drawTile(&gScreenBuffer[0],0,0,&gScreenBuffer[1]);
			map_PutTile(&gScreenBuffer[1],tx,ty,2); 
            map_PutTile(&gScreenBuffer[1],center_x,center_y,5); 
			map_PutTile(&gScreenBuffer[1],target_x,target_y,1) ;
			
			gPlayerObject.fpDraw(&gPlayerObject,&gScreenBuffer[1]);

            //gotoxy(0,0);
			//Plane_Draw(&gPlayerObject,&gScreenBuf[1]);

			//map_dump(&gScreenBuf[1],Default_Tilepalete);
            map_dump(&gScreenBuffer[1],Default_Tilepalete);
            
			acc_tick = 0;
		}

	}

	
	return 0;

}
示例#13
0
文件: ex7.c 项目: JuWonKuk/jtest
int main()
{
	set_conio_terminal_mode();
	acc_tick = last_tick = 0;

	for(int i=0;i<2;i++) {
		map_init(&gScreenBuffer[i]);
		map_new(&gScreenBuffer[i],35,15);
	}
	
	system("clear");
	
	double target_x,target_y;
	double center_x,center_y;
	center_x = 14;
	center_y = 7;
	target_x = 14;
	target_y = 3;
	double target_x2,target_y2;
	double center_x2,center_y2;
	center_x2 = 14;
	center_y2 = 3;
	target_x2 = 14;
	target_y2 = 2;

	double angle = 0;
	while(bLoop) {
		//타이밍 처리
		clock_gettime(CLOCK_MONOTONIC, &work_timer);
		double cur_tick = work_timer.tv_sec + 
			(double)(work_timer.tv_nsec * 1e-9);
		double delta_tick = cur_tick - last_tick;
		last_tick = cur_tick;
		//실시간 입력
		if(kbhit() != 0) {
			char ch = getch();
			if(ch == 'q') {
				bLoop = 0;
				puts("bye~ \r");
			}
			
		}
		/////////////////////////////////

		//apply 위치...
		angle += (delta_tick * 45);
		double tx,ty;
		double rad = angle/180 * 3.141592; 
		tx = (target_x-center_x) * cos(rad) - (target_y - center_y)*sin(rad) ;
		ty = (target_x-center_x) * sin(rad) + (target_y - center_y)*cos(rad) ;

		tx += center_x;
		ty += center_y;
		
		double tx2,ty2;
		double rad2 = angle/180 * 3.141592; 
		tx2 = (target_x2-center_x2) * cos(rad2) - (target_y2 - center_y2)*sin(rad2) ;
		ty2 = (target_x2-center_x2) * sin(rad2) + (target_y2 - center_y2)*cos(rad2) ;

		tx2 += center_x2;
		ty2 += center_y2;


		//타이밍 계산
		acc_tick += delta_tick;
		if(acc_tick > 0.1) {
			//puts("tick...\r");
			map_drawTile(&gScreenBuffer[0],0,0,&gScreenBuffer[1]);
			map_PutTile(&gScreenBuffer[1],tx,ty,2);
			map_PutTile(&gScreenBuffer[1],center_x,center_y,5);
			map_PutTile(&gScreenBuffer[1],target_x,target_y,1);
			map_PutTile(&gScreenBuffer[1],target_x2,target_y2,3);
			gotoxy(0,0);
			map_dump(&gScreenBuffer[1],Default_Tilepalette);
			acc_tick = 0;
		}

	}
}
示例#14
0
文件: ex3.c 项目: dlawltjs/gittest
int main()
{
	system("clear");

	for(int i=0;i<2;i++) {
		map_init(&gScreenBuf[i]);
		map_new(&gScreenBuf[i],35,16);
	
	
	}

	map_init(&gPlayerModel);
	map_load(&gPlayerModel,"plane1.dat");

	map_init(&gBulletModel);
	map_load(&gBulletModel,"plasma.dat");
	
	Plane_init(&gPlayerObject,&gPlayerModel,17,10);
	bullet_init(&gTestBullet,0,0,0,&gBulletModel);

	set_conio_terminal_mode();
	acc_tick = last_tick = 0;

	//플레이상태로 만들기
	gPlayerObject.m_nFSM = 1;
	
	
	while(bLoop) {

		//타이밍처리
		clock_gettime(CLOCK_MONOTONIC,&work_timer);
		double cur_tick = work_timer.tv_sec + (double)(work_timer.tv_nsec * 1e-9);
		double delta_tick = cur_tick - last_tick;
		last_tick = cur_tick;

		//실시간입력	
		if(kbhit() != 0) {
			char ch = getch();
			if(ch == 'q') {
				bLoop = 0;
				puts("bye~\r");
			}
			else if(ch == 'j') {
				
				double bullet_pos_x = 0;
				double bullet_pos_y = 0;

				double target_pos_x = gPlayerObject.m_fXpos;
				double target_pos_y = gPlayerObject.m_fYpos;

				double vx = target_pos_x - bullet_pos_x;
				double vy = target_pos_y - bullet_pos_y;
				double dist = sqrt(vx*vx+vy*vy);
				
				vx /= dist;
				vy /= dist;
				

				gTestBullet.pfFire(&gTestBullet,bullet_pos_x,bullet_pos_y,10.0,vx,vy,10);

			}

			gPlayerObject.pfApply(&gPlayerObject,delta_tick,ch);
		}
		gTestBullet.pfApply(&gTestBullet,delta_tick);

		if(gTestBullet.m_nFSM != 0) {
			double bullet_pos_x = gTestBullet.m_fXpos;
			double bullet_pos_y = gTestBullet.m_fYpos;

			double target_pos_x = gPlayerObject.m_fXpos;
			double target_pos_y = gPlayerObject.m_fYpos;

			double vx = target_pos_x - bullet_pos_x;
			double vy = target_pos_y - bullet_pos_y;
			double dist = sqrt(vx*vx+vy*vy);

			if(dist < 0.25) {
				gTestBullet.m_nFSM = 0;
				gPlayerObject.m_nFSM = 0;
	
			}

		}



		//타이밍계산
		acc_tick += delta_tick;
		if(acc_tick > 0.1) {
			//puts("tick...\r");
			gotoxy(0,0);
			map_drawTile(&gScreenBuf[0],0,0,&gScreenBuf[1]);
			gPlayerObject.pfDraw(&gPlayerObject,&gScreenBuf[1]);
			gTestBullet.pfDraw(&gTestBullet,&gScreenBuf[1]);
				
			map_dump(&gScreenBuf[1],Default_Tilepalete);
			acc_tick = 0;
		}
	}


	return 0;
}
示例#15
0
int main()
{
	system("clear");

	for(int i=0;i<2;i++)
	{
		map_init(&gScreenBuf[i]);
		map_new(&gScreenBuf[i],35,30);
	}

	map_init(&gPlayerModel);
	map_load(&gPlayerModel,"plane5.dat");


	map_init(&gBulletModel);
	map_load(&gBulletModel,"target5.dat");


	Plane_init(&gPlayerObject,&gPlayerModel,17,24);
	bullet_init(&gTestBullet,0,0,0,&gBulletModel);

	set_conio_terminal_mode();
	acc_tick=last_tick=0;

	gPlayerObject.m_nFSM = 1;

	while(bLoop) {
		//타이밍처리 
		clock_gettime(CLOCK_MONOTONIC,&work_timer);
		double cur_tick = work_timer.tv_sec + 
			(double)(work_timer.tv_nsec * 1e-9);
		double delta_tick = cur_tick - last_tick;
		last_tick = cur_tick;
		//실시간입력	
		if(kbhit() != 0) {
			char ch = getch();
			if(ch == 'q') {
				bLoop = 0;
				puts("Good bye~ \r");
			}
			else if (ch == 'j') {

				double vx,vy;
				gTestBullet.m_fXpos = 0;
				gTestBullet.m_fYpos = 0;
				getDirection(&gTestBullet,&gPlayerObject,&vx,&vy);
				gTestBullet.pfFire(&gTestBullet,
				gTestBullet.m_fXpos,
				gTestBullet.m_fYpos,
				10,vx,vy,10);
			}

			gPlayerObject.pfApply(&gPlayerObject,delta_tick,ch);
		}

		gTestBullet.pfApply(&gTestBullet,delta_tick);

		if(gTestBullet.m_nFSM != 0)	{
	
			double dist = getDistance(&gTestBullet,&gPlayerObject);

			if(dist < 2.0) {
				gTestBullet.m_nFSM = 0;
				gPlayerObject.m_nFSM = 0;
			}

		}


		//타이밍계산
		acc_tick += delta_tick;
		if(acc_tick > 0.1) {
			gotoxy(0,0);
			map_drawTile(&gScreenBuf[0],0,0,&gScreenBuf[1]);

			gPlayerObject.pfDraw(&gPlayerObject,&gScreenBuf[1]);
			gTestBullet.pfDraw(&gTestBullet,&gScreenBuf[1]);	

			map_dump(&gScreenBuf[1],Default_Tilepalete);
			acc_tick = 0;
		}
	}

	return 0;
}
示例#16
0
int main()
{

	for(int i=0;i<2;i++){
		map_init(&gScreenBuf[i]);
		map_new(&gScreenBuf[i],45,30);
	}

	map_init(&gPlayerModel);
	map_load(&gPlayerModel,"plane1.dat");

	map_init(&gPlasmaModel);
	map_load(&gPlasmaModel,"plasma.dat");

	map_init(&gAlienModel);
	map_load(&gAlienModel,"alien.dat");

	map_init(&gPlaneBulletModel);
	map_load(&gPlaneBulletModel,"bullet1.dat");

	map_init(&gPotal);
	map_load(&gPotal,"potal.dat");

	map_init(&gPotalBulletModel);
	map_load(&gPotalBulletModel,"potal_bullet.dat");

	Plane_init(&gPlayerObject,&gPlayerModel,30,26);
	Potal_init(&gPlayerPotal,&gPotal,1,1);
	Potal_Bullet_init(&gPotalBulletObject,0,0,0,&gPotalBulletModel);

	gPlayerObject.m_nFSM=1;

	for(int i=0;i<sizeof(gPlaneBulletObjects)/sizeof(_S_BULLET_OBJECT);i++){
		bullet_init(&gPlaneBulletObjects[i],0,0,0,&gPlaneBulletModel);
	}

	for(int i=0;i<sizeof(gBulletObjects)/sizeof(_S_BULLET_OBJECT);i++){
		bullet_init(&gBulletObjects[i],0,0,0,&gPlasmaModel);
	}

	double TablePosition[]={0,10,20,30,40};

	for(int i=0;i<5;i++){
		_S_ALIEN_OBJECT *pObj=&gAlienObjects[i];
		alien_init(pObj,&gAlienModel);
		pObj->m_fXpos=TablePosition[i];
		pObj->m_fYpos=5;
		pObj->m_nFSM=1;
		gAlienObjects[i].m_pBullet=&gBulletObjects[i];

	}

	system("clear");

	set_conio_terminal_mode();
	acc_tick=last_tick=0;
	acc_guid_delay_tick=0;
	acc_bullet_delay_tick=0;

	while(bLoop) {
		//타이밍처리 
		clock_gettime(CLOCK_MONOTONIC,&work_timer);
		double cur_tick = work_timer.tv_sec + 
			(double)(work_timer.tv_nsec * 1e-9);
		double delta_tick = cur_tick - last_tick;
		last_tick = cur_tick;

		//실시간 입력
		if(kbhit()!=0) {
			char ch = getch();
			if(ch=='q') {
				bLoop=0;
				puts("bye~ \r");
			}

			else if(ch=='j') {

				for(int i=0;i<sizeof(gPlaneBulletObjects)/sizeof(_S_BULLET_OBJECT);i++) {
					double vx,vy,c;

					vx=gAlienObjects[i].m_fXpos-gPlayerObject.m_fXpos;
					vy=gAlienObjects[i].m_fYpos-gPlayerObject.m_fYpos;
					c=sqrt(vx*vx+vy*vy);
					vx/=c;	vy/=c;

					_S_BULLET_OBJECT *pObj = &gPlaneBulletObjects[i];
					if(pObj->m_nFSM==0) { //슬립상태
						pObj->pfFire(pObj,gPlayerObject.m_fXpos,gPlayerObject.m_fYpos,10.0,vx,vy,10.0);
						break;
					}
				}

			}
			
			_S_Potal_Bullet_Object *pObj=&gPotalBulletObject;
			if(pObj->m_nFSM==0){
				double potal_bullet_posx=gPlayerPotal.m_nXpos;
				double potal_bullet_posy=gPlayerPotal.m_nYpos;

				double target_x=gPlayerObject.m_fXpos;
				double target_y=gPlayerObject.m_fYpos;

				double vx=target_x-potal_bullet_posx;
				double vy=target_y-potal_bullet_posy;

				/*  double angle=0;
					angle+=(delta_tick*45);
					double rad=(angle/180.0)*PI;

					double vx=(target_x-potal_bullet_posx)*cos(rad)-(target_y-potal_bullet_posy)*sin(rad);
					double vy=(target_x-potal_bullet_posx)*sin(rad)+(target_y-potal_bullet_posy)*cos(rad);

*/
				double dist=sqrt(vx*vx+vy*vy);
				vx/=dist; vy/=dist;

				Potal_Bullet_Fire(&gPotalBulletObject,gPlayerPotal.m_nXpos,gPlayerPotal.m_nYpos,10,vx,vy,10.0);
			}
			gPlayerObject.pfApply(&gPlayerObject,delta_tick,ch);	

		}
		//apply
		Potal_Bullet_Apply(&gPotalBulletObject,delta_tick);

		for(int i=0;i<sizeof(gPlaneBulletObjects)/sizeof(_S_BULLET_OBJECT);i++) {
			_S_BULLET_OBJECT *pObj=&gPlaneBulletObjects[i];
			pObj->pfApply(pObj,delta_tick);

		}

		for(int i=0;i<5;i++ ){
			_S_ALIEN_OBJECT *pObj=&gAlienObjects[i];
			pObj->pfApply(pObj,delta_tick);

		}

		//potal_bullet
		{
			double potal_bullet_posx=gPlayerPotal.m_nXpos;
			double potal_bullet_posy=gPlayerPotal.m_nYpos;

			double target_x=gPlayerObject.m_fXpos;
			double target_y=gPlayerObject.m_fYpos;

			/*	double vx=target_x-potal_bullet_posx;
				double vy=target_y-potal_bullet_posy;*/

			double angle=0;
			angle+=(delta_tick*45);
			double rad=(angle/180.0)*PI;

			double vx=(target_x-potal_bullet_posx)*cos(rad)-(target_y-potal_bullet_posy)*sin(rad);
			double vy=(target_x-potal_bullet_posx)*sin(rad)+(target_y-potal_bullet_posy)*cos(rad);

			double dist=sqrt(vx*vx+vy*vy);

			if(dist<0.1){
				gPotalBulletObject.m_nFSM=0;
			}
		}

		acc_bullet_delay_tick+=delta_tick;
		if(acc_bullet_delay_tick>2.0){	//2초동안 방향설정

			acc_bullet_delay_tick=0;

			double bullet_posx=gPotalBulletObject.m_fXpos;
			double bullet_posy=gPotalBulletObject.m_fYpos;

			double target_posx=gPlayerObject.m_fXpos;
			double target_posy=gPlayerObject.m_fYpos;

			double vx=target_posx-bullet_posx;
			double vy=target_posy-bullet_posy;

			double dist=sqrt(vx*vx+vy*vy);

			vx/=dist; vy/=dist;

			gPotalBulletObject.m_fvx=vx;
			gPotalBulletObject.m_fvy=vy;
		}

		//총알 맞았을때 게임오버
		for(int i=0;i<sizeof(gBulletObjects)/sizeof(_S_BULLET_OBJECT);i++) {
			if(gBulletObjects[i].m_nFSM!=0) {
				double bullet_posx=gBulletObjects[i].m_fXpos;
				double bullet_posy=gBulletObjects[i].m_fYpos;

				double target_posx=gPlayerObject.m_fXpos;
				double target_posy=gPlayerObject.m_fYpos;

				double vx=target_posx-bullet_posx;
				double vy=target_posy-bullet_posy;

				double dist=sqrt(vx*vx+vy*vy);

				if(dist<0.1) {
					gBulletObjects[i].m_nFSM=0;
					gPlayerObject.m_nFSM=0;
					gAlienObjects[i].m_nFSM=0;
				}
			}
		}

		//alien 총알 맞았을때
		for(int i=0;i<sizeof(gPlaneBulletObjects)/sizeof(_S_BULLET_OBJECT);i++) {
			if(gPlaneBulletObjects[i].m_nFSM!=0) {
				double bullet_posx=gPlaneBulletObjects[i].m_fXpos;
				double bullet_posy=gPlaneBulletObjects[i].m_fYpos;

				double target_posx= gAlienObjects[i].m_fXpos;
				double target_posy= gAlienObjects[i].m_fYpos;

				double vx=target_posx-bullet_posx;
				double vy=target_posy-bullet_posy;
				double dist=sqrt(vx*vx+vy*vy);

				if(dist<5.0) {
					gAlienObjects[i].m_nFSM=0;
				}
			}
		}	

		for(int i=0;i<sizeof(gBulletObjects)/sizeof(_S_BULLET_OBJECT);i++) {
			gBulletObjects[i].pfApply(&gBulletObjects[i],delta_tick);

		}

		//타이밍 계산 
		acc_tick += delta_tick;
		if(acc_tick > 0.1) {
			gotoxy(0,0);
			map_drawTile(&gScreenBuf[0],0,0,&gScreenBuf[1]);

			gPlayerObject.pfDraw(&gPlayerObject,&gScreenBuf[1]);
			Potal_Draw(&gPlayerPotal,&gScreenBuf[1]);

			for(int i=0;i<5;i++) {
				_S_ALIEN_OBJECT *pObj = &gAlienObjects[i];
				pObj->pfDraw(pObj,&gScreenBuf[1]);
			}

			for(int i=0;i<sizeof(gBulletObjects)/sizeof(_S_BULLET_OBJECT);i++){
				gBulletObjects[i].pfDraw(&gBulletObjects[i],&gScreenBuf[1]);
			}

			for(int i=0;i<sizeof(gPlaneBulletObjects)/sizeof(_S_BULLET_OBJECT);i++){
				_S_BULLET_OBJECT *pObj = &gPlaneBulletObjects[i];
				pObj->pfDraw(pObj,&gScreenBuf[1]);
			}

			puts("---------------------------------------------\r");
			map_dump(&gScreenBuf[1],Default_Tilepalete);
			puts("---------------------------------------------\r");

			puts("move : w,a,s,d \r");
			puts("quit : q \r");
			acc_tick = 0;

		}

	}

	return 0;

}
示例#17
0
文件: ex1.c 项目: dlawltjs/gittest
int main()
{
	set_conio_terminal_mode();
	acc_tick = last_tick = 0;

	for(int i=0;i<2;i++) {
		map_init(&gScreenBuffer[i]);
		map_new(&gScreenBuffer[i],35,15);

	}

	map_init(&gBulletModel);
	map_load(&gBulletModel,"plasma.dat");
	bullet_init(&gBulletObject,0,0,0,&gBulletModel);
	
	system("clear");

	while(bLoop) {

		//타이밍처리
		clock_gettime(CLOCK_MONOTONIC,&work_timer);
		double cur_tick = work_timer.tv_sec + (double)(work_timer.tv_nsec * 1e-9);
		double delta_tick = cur_tick - last_tick;
		last_tick = cur_tick;

		//실시간입력	
		if(kbhit() != 0) {
			char ch = getch();
			if(ch == 'q') {
				bLoop = 0;
				puts("bye~\r");
			}
			else if(ch == 'j') {
				double vx,vy,c;
				vx = 1.0;
				vy = 1.0;
				c = sqrt(vx*vx + vy*vy);
				vx /= c; vy /= c;

				bullet_fire(&gBulletObject,17,7,1.0,vx,vy,10.0);

			}

		}


		//apply 위치
		bullet_apply(&gBulletObject,delta_tick);

		
		//타이밍계산
		acc_tick += delta_tick;
		if(acc_tick > 0.1) {
			//puts("tick...\r");
			map_drawTile(&gScreenBuffer[0],0,0,&gScreenBuffer[1]);
			bullet_draw(&gBulletObject,&gScreenBuffer[1]);
			gotoxy(0,0);
			map_dump(&gScreenBuffer[1],Default_Tilepalete);
			acc_tick = 0;
		}
	}


	return 0;
}
示例#18
0
文件: np25.c 项目: drpjk/NP25
//________________________________________________________________________________
int main() {

#ifdef EMBEDDED
    WDTCTL  = WDTPW + WDTHOLD; 	// Stop WDT
	__use_cal_clk(MHZ);
	//FCTL2 = FWKEY + FSSEL0 + FN1;	// MCLK/3 for Flash Timing Generator
	FCTL2 = FWKEY + FSSEL0 + FN2;	// for 12Mhz

#ifdef C_STANDALONE

	TA0CCR0  = MHZ * 1000;		// start w/ 1ms
	TA0CCTL0 = CCIE;
	TA0CTL = TASSEL_2 + MC_2;	// SMCLK, cont.

	P1SEL = P2SEL = 0;

	P1OUT = ALL_DIGITS_P1;
	P2OUT = ALL_DIGITS_P2;
	P1DIR = P2DIR = 0xff;

	SPOUT |= ALL_SCANS;
	SPREN |= ALL_SCANS;
	SPDIR &= ~ALL_SCANS;

#else
	uint8_t usage = 0;
	uart_init();
#endif

    __bis_SR_register(GIE);

#else
	set_conio_terminal_mode();

#endif

 
	/*
	key_map['0'] = 0x92; key_map['1'] = 0x72; key_map['2'] = 0x71; key_map['3'] = 0x70;
	key_map['4'] = 0xa2; key_map['5'] = 0xa1; key_map['6'] = 0xa0; key_map['7'] = 0x62;
	key_map['8'] = 0x61; key_map['9'] = 0x60; key_map['.'] = 0x91; key_map['-'] = 0x63;
	key_map['+'] = 0xa3; key_map['*'] = 0x73; key_map['/'] = 0x93; key_map['\r'] = 0x90;	// run/stop
	key_map['a'] = 0xb3; key_map['s'] = 0xb2; key_map['d'] = 0xb1; key_map['f'] = 0xb0; key_map['g'] = 0xb4; // SST BST GTO F   G
	key_map['q'] = 0x43; key_map['w'] = 0x42; key_map['e'] = 0x41; key_map['r'] = 0x40; key_map['t'] = 0x44; // X.Y RV  STO RCL E+
	key_map[' '] = 0xd3; key_map['z'] = 0xd1; key_map['x'] = 0xd0; key_map['c'] = 0xd4;					     // ETR ETR CHS EEX CLX
	*/
#define RAM_OFFSET	(7*9)
#define RAM_SIZE	(7*7)		// 49 program steps

	woodstock_clear_memory();
	//______ load from flash, we just need the status config, but we load everything since
	//       we might need to write it back and flash always write in full blocks
	uint8_t idx = RAM_SIZE + 1 + 12;	// 49 program steps + config byte + 12 byte greeting
	while (idx--) ((char*) act_reg->ram)[idx+RAM_OFFSET] = *((char*) (0x1040+idx));
	_state = ((char*) (act_reg->ram))[RAM_OFFSET+RAM_SIZE] & (ST_HW_SLOW|ST_ROM);

	for (idx=0;idx<12;idx++) _greetings[idx] = ((uint8_t*) act_reg->ram)[RAM_OFFSET+50+idx];
	_MSG_PTR = (uint8_t*) _greetings;

	LPM0;

	while (_key == 35) _state |= ST_HW_TEST;		// pgm key pressed, enter setup

	_EDIT_POS = 99;
	uint8_t save_state = _state;
	switch (_key) {
		//
		case 17: 	// "goto" key for edit easter egg message
			while (!(_state&ST_KEY_RELEASED)) __asm("nop");
			_state &= ~ST_KEY_RELEASED;
			{
				uint8_t *p= (uint8_t*) _MSG_PTR;
				//uint8_t i=0;
				_EDIT_POS = 0;
				_MSG_POS = 0;
				_MSG_LEN = 12;
				_LAST_KEY = 99;
				_state |= ST_ALPHA_MSG;		// start show
				while (1) {
					LPM0;					// wait key
					uint8_t k = _key;
					if (k == 41) break;
					if (k == 38) {
						_EDIT_POS++;
						p++;
						_LAST_KEY = 99;
						if (_EDIT_POS>=12) {
							//__________ the last 12 bytes are the greetings
							flash_write(0, (char*) act_reg->ram + RAM_OFFSET, RAM_SIZE);
							break;
						}//if
					}//if
					switch (k) {
						case 10: k = 0; break;
						case 9:  k = 1; break;
						case 45: k = 2; break;
						case 37: k = 3; break;
						case 11: k = 4; break;
						case 47: k = 5; break;
						case 39: k = 6; break;
						case 23: k = 7; break;
						case 31: k = 8; break;
						case 43: k = 9; break;
						default: k = 10; break;
					}//switch
					const uint8_t key_adv[] = { 'A', 'D', 'G', 'J', 'M', 'P', 'T', 'W', '[', };
					if (k < 10) {
						if (k == _LAST_KEY) {
							if (k >= 2) {
								if (*p <= '9') {
									*p = key_adv[k-2];
								}//if
								else {
									*p = *p + 1;
									if (*p == key_adv[k-1])
										*p = '0' + k;
								}//else
							}//if
							else {
								if (k == 0) {
									*p = *p == '0' ? '?' : '0';
								}//if
							}//else
						}//if
						else {
							if (k < 10) {
								*p = '0' + k;
								_LAST_KEY = k;
							}//if
						}//else
					}//if
				}//while
			}
			_state &= ~ST_ALPHA_MSG;
			break;
		//
		case 33: 	// F key, show secret message
			show_msg(_MSG_PTR, 100);
			break;
		// right top, going down on same column
		case 34: 
			_state = 1;
			show_msg((const uint8_t*) "HP33C ROM", 100);
			break;
		case 42: 
			_state = 2;
			show_msg((const uint8_t*) "HP25C ROM", 100);
			break;
		case 41: 
			_state = 3;
			show_msg((const uint8_t*) "HP21 ROM", 100);
			break;
		case 43:
			show_msg((const uint8_t*) "NP25 VER 3", 100);
			break;
	}//switch
	if (save_state&ST_HW_SLOW) _state |= ST_HW_SLOW;

	while (_state&ST_HW_TEST) {
		LPM0;
		switch (_key) {
			case 35: 	// pgm/run key
				_state &= ~ST_HW_TEST; 
				flash_write(0, (char*) act_reg->ram + RAM_OFFSET, RAM_SIZE);
				break;
			case 33:	// F key to rotate rom
			// 00..01, 01..10, 10..11, 11..01
				if ((_state&ST_ROM)==0x03)
					_state &= ~ST_ROM;
				_state++;
				break;
			case 34:	// G key to toggle fast and slow cpu
				_state ^= ST_HW_SLOW;
				break;
		}//switch
	}//while

	/*
	if ((_state&ST_ROM)==0x02) {	// 25c use alternate rom
		uint8_t i = 7*16 + 1;
		while (i--) ((char*) act_reg->ram)[i] = *((char*) (0x1040+i));
	}//if
	*/

	woodstock_set_rom(_state&ST_ROM);
	woodstock_new_processor();

	_state &= ~(ST_RAM_LOADED|ST_KEY_PRESSED|ST_KEY_RELEASED);

	uint8_t done=0;
#ifdef C_STANDALONE
#else
	uint8_t c=0;
#endif
	uint8_t release_in=0;

	woodstock_set_ext_flag (3, _pgm_run);		// set run mode

	while (!done) {
#ifdef C_STANDALONE
		if (_state) {
			if (_state & ST_KEY_PRESSED) {
				if (!(_state&ST_RAM_LOADED)) {
					//______ lets load ram from flash (pretend continous memory) at 1st key
					//       need to do it here after cpu initialized
					if (_pgm_run && ((_state&ST_ROM) != 0x03)) {
						_state |= ST_RAM_LOADED;
						char *src = (char*) 0x1040;
						uint8_t c = RAM_SIZE;
						if (!(_state&ST_ROM_BIT0)) src += 0x40;		// next infomem block for hp25
						while (c--) ((char*) act_reg->ram)[c+RAM_OFFSET] = *(src + c);
					}//if
				}//if
				if (_key == 35) {
					woodstock_set_ext_flag (3, _pgm_run ^= 1);		// pgm-run toggle
					//___ to run mode, write flash
					if (_pgm_run && ((_state&ST_ROM) != 0x03)) {
						uint16_t des = 0x1040;
						if (!(_state&ST_ROM_BIT0)) des += 0x40;
						flash_write(_state&ST_ROM_BIT0 ? 0 : 1,
							(char*) act_reg->ram + RAM_OFFSET, RAM_SIZE);
					}//if
				}//if
				else {
					//if (session_key_map[_key]) woodstock_press_key(session_key_map[_key]);
					sim_check_key(_key);
				}//else
				_state &= ~ST_KEY_PRESSED;
			}//if
			else if (_state & ST_KEY_RELEASED) {
				woodstock_release_key();
				_state &= ~ST_KEY_RELEASED;
			}//if
		}//if
#else
#ifdef EMBEDDED
		if (c || uart_getc(&c)) {
			//P1OUT ^= BIT0;
			if (!usage) {
				usage = 1;
				uart_puts("\x1b[1;1H");
				uart_puts("\x1b[0J");
				uart_puts("\n\r\n\r\n\r");
				uart_puts(" SST  BST  GTO   F    G \n\r");
				uart_puts(" X.Y  RV   STO  RCL  E+ \n\r");
				uart_puts(" ETR  ETR  CHS  EEX  CLX\n\r");
				uart_puts("  -     7      8      9  \n\r");
				uart_puts("  +     4      5      6  \n\r");
				uart_puts("  x     1      2      4  \n\r");
				uart_puts("  /     0      .     R/S \n\r\n\r");
				uart_puts("\x1b[9A");
			}//if
#else
		if (kbhit()) {
			c = getch();
#endif
			switch (c) {
				case 27: 
					done = 1; 
					break;
				case '\\': 
					woodstock_new_processor();
					_pgm_run = 0;
					break;
				case '=': 
					woodstock_set_ext_flag (3, _pgm_run ^= 1);		// pgm-run toggle
					//if (_pgm_run) flash_write(0xfc00, (char*)act_reg->ram, 7*__USE_RAM);
					break;
				default:
#ifdef C_SPICE
					c += 128;
#endif
					if (key_map[c]) {
						woodstock_press_key(key_map[c]);
						release_in = 10;
					}//if
					break;
			}//switch
			c = 0;
		}//if
#endif
		if (!woodstock_execute_instruction()) break;
		if (release_in) {
			if (release_in == 1) woodstock_release_key();
			release_in--;
		}//if

#ifdef EMBEDDED
		if (_state&ST_HW_SLOW) __delay_cycles(MHZ*150);
#else
		//usleep(100);
#endif
	}//while

	return 0;

}

#ifdef EMBEDDED
#ifdef C_STANDALONE

volatile uint8_t _data=0;
volatile uint8_t _digit=0;
volatile uint8_t _keyscan=0;

//________________________________________________________________________________
uint8_t hwtest_load_segments(uint8_t digit) {
	uint8_t res = 0x0f;

	switch (digit) {
		case 0: res = 'H'-'0'; break;
		case 1: res = 'P'-'0'; break;
		case 2: res = _state&ST_ROM_BIT1 ? 2 : 3; break;
		case 3:
			res = _state&ST_ROM_BIT0 ? (_state&ST_ROM_BIT1 ? 1 : 3) : 5; 
			break; 
		case 5: res = _state&ST_HW_SLOW ? 'S'-'0' : 'F'-'0'; break; 
		case 6: res = _state&ST_HW_SLOW ? 'L'-'0' : 'A'-'0'; break; 
		case 7: res = _state&ST_HW_SLOW ? 'O'-'0' : 'S'-'0'; break; 
		case 8: res = _state&ST_HW_SLOW ? 'W'-'0' : 'T'-'0'; break; 
		//case 7: res = _clicks/10; break;
		//case 8: res = _clicks%10; break;
		case 10: res = _key/10; break;
		case 11: res = _key%10; break;
	}//switch

	return seg_map[res];
}
示例#19
0
int main(int argc, char **argv)
{
    if (argc != 3) {
        fprintf(stderr, "usage: %s file.wav file.map\n", argv[0]);
        fprintf(stderr, "  where file.wav and file.map are created by the permute tool\n");
        return EXIT_FAILURE;
    }

    SLresult result;

    // create engine
    SLObjectItf engineObject;
    result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
    ASSERT_EQ(SL_RESULT_SUCCESS, result);
    result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
    ASSERT_EQ(SL_RESULT_SUCCESS, result);
    SLEngineItf engineEngine;
    result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);
    ASSERT_EQ(SL_RESULT_SUCCESS, result);

    // create output mix
    SLObjectItf outputmixObject;
    result = (*engineEngine)->CreateOutputMix(engineEngine, &outputmixObject, 0, NULL, NULL);
    ASSERT_EQ(SL_RESULT_SUCCESS, result);
    result = (*outputmixObject)->Realize(outputmixObject, SL_BOOLEAN_FALSE);
    ASSERT_EQ(SL_RESULT_SUCCESS, result);

    // create an audio player with URI source and output mix sink
    SLDataSource audiosrc;
    SLDataSink audiosnk;
    SLDataLocator_OutputMix locator_outputmix;
    SLDataLocator_URI locator_uri;
    SLDataFormat_MIME mime;
    locator_uri.locatorType = SL_DATALOCATOR_URI;
    locator_uri.URI = (SLchar *) argv[1];
    locator_outputmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
    locator_outputmix.outputMix = outputmixObject;
    mime.formatType = SL_DATAFORMAT_MIME;
    mime.mimeType = (SLchar *) NULL;
    mime.containerType = SL_CONTAINERTYPE_UNSPECIFIED;
    audiosrc.pLocator = &locator_uri;
    audiosrc.pFormat = &mime;
    audiosnk.pLocator = &locator_outputmix;
    audiosnk.pFormat = NULL;
    SLObjectItf playerObject;
    SLInterfaceID ids[1] = {SL_IID_SEEK};
    SLboolean flags[1] = {SL_BOOLEAN_TRUE};
    result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audiosrc, &audiosnk,
            1, ids, flags);
    ASSERT_EQ(SL_RESULT_SUCCESS, result);
    result = (*playerObject)->Realize(playerObject, SL_BOOLEAN_FALSE);
    ASSERT_EQ(SL_RESULT_SUCCESS, result);
    SLPlayItf playerPlay;
    result = (*playerObject)->GetInterface(playerObject, SL_IID_PLAY, &playerPlay);
    ASSERT_EQ(SL_RESULT_SUCCESS, result);
    SLSeekItf playerSeek;
    result = (*playerObject)->GetInterface(playerObject, SL_IID_SEEK, &playerSeek);
    ASSERT_EQ(SL_RESULT_SUCCESS, result);
    SLmillisecond duration;
    result = (*playerPlay)->GetDuration(playerPlay, &duration);
    ASSERT_EQ(SL_RESULT_SUCCESS, result);
    result = (*playerPlay)->SetPlayState(playerPlay, SL_PLAYSTATE_PAUSED);
    ASSERT_EQ(SL_RESULT_SUCCESS, result);
    result = (*playerPlay)->GetDuration(playerPlay, &duration);
    ASSERT_EQ(SL_RESULT_SUCCESS, result);
    result = (*playerPlay)->SetPlayState(playerPlay, SL_PLAYSTATE_PLAYING);
    ASSERT_EQ(SL_RESULT_SUCCESS, result);

#if 1
    // play back a file in permuted order using the seek map
    FILE *fp_map = fopen(argv[2], "r");
    if (fp_map != NULL) {
        unsigned position, duration;
        while (fscanf(fp_map, "%u %u", &position, &duration) == 2) {
            printf("%u %u\n", position, duration);
            result = (*playerSeek)->SetPosition(playerSeek, (SLmillisecond) position,
                    SL_SEEKMODE_ACCURATE);
            ASSERT_EQ(SL_RESULT_SUCCESS, result);
            if (duration > 0)
                usleep(duration * 1000);
        }
    }
#else
    set_conio_terminal_mode();

    // loop repeatedly, inflicting seek pain each cycle
    for (;;) {
        if (kbhit()) {
            switch (getch()) {
            case 'q':
                goto out;
            }
        }
        SLmillisecond delay = 100 + (rand() & 8191);
        printf("sleep %u\n", (unsigned) delay);
        usleep(delay * 1000);
        SLmillisecond newPos = duration * ((rand() & 65535) / 65536.0);
        printf("seek %u\n", (unsigned) newPos);
        result = (*playerSeek)->SetPosition(playerSeek, newPos, SL_SEEKMODE_ACCURATE);
        ASSERT_EQ(SL_RESULT_SUCCESS, result);
        SLmillisecond nowPos;
        result = (*playerPlay)->GetPosition(playerPlay, &nowPos);
        ASSERT_EQ(SL_RESULT_SUCCESS, result);
        printf("now %u\n", (unsigned) newPos);
    }
out:
#endif

    return EXIT_SUCCESS;
}
示例#20
0
文件: ex2.c 项目: yeongeun0325/cygwin
int main()
{	
	system("clear");

	for(int i=0;i<2;i++){
		map_init(&gScreenBuffer[i]);
		gScreenBuffer[i].fpnew(&gScreenBuffer[i],35,16);
		//map_new(&gScreenBuffer[i],35,16);
	}

	map_init(&gPlayerModel);
	map_load(&gPlayerModel,"plane.dat");

	Plane_init(&gPlayerObject,&gPlayerModel,17,10);
	bullet_init(&gBulletObject,0,0,0,&gPlayerModel);

	map_init(&gBulletModel);
	map_load(&gBulletModel,"plasma.dat");

	bullet_init(&gBulletObject,0,0,0,&gBulletModel);
	
	set_conio_terminal_mode();
	acc_tick=last_tick=0;
	acc_bullet_delay_tick=0;

	while(bLoop) {
		//타이밍처리 
		clock_gettime(CLOCK_MONOTONIC,&work_timer);
		double cur_tick = work_timer.tv_sec + 
			(double)(work_timer.tv_nsec * 1e-9);
		double delta_tick = cur_tick - last_tick;
		last_tick = cur_tick;
		//실시간 입력
		if(kbhit() != 0) {
			char ch = getch();
			if(ch == 'q') {
				bLoop = 0;
				puts("bye~ \r");
			}
			else if(ch=='j'){
				double bullet_posx=0;
				double bullet_posy=0;

				double target_posx=gPlayerObject.m_fXpos;
				double target_posy=gPlayerObject.m_fYpos;

				double vx=target_posx-bullet_posx;
				double vy=target_posy-bullet_posy;

				double dist=sqrt(vx*vx+vy*vy);

				vx/=dist; vy/=dist;

				gBulletObject.pfFire(&gBulletObject,bullet_posx,bullet_posy,10,vx,vy,10.0);
			}
			gPlayerObject.pfApply(&gPlayerObject,delta_tick,ch);
			//Plane_Apply(&gPlayerObject,delta_tick,ch);
		}

		acc_bullet_delay_tick+=delta_tick;
		if(acc_bullet_delay_tick>2.0){	//2초동안 방향설정

			acc_bullet_delay_tick=0;

			double bullet_posx=gBulletObject.m_fXpos;
			double bullet_posy=gBulletObject.m_fYpos;

			double target_posx=gPlayerObject.m_fXpos;
			double target_posy=gPlayerObject.m_fYpos;

			double vx=target_posx-bullet_posx;
			double vy=target_posy-bullet_posy;

			double dist=sqrt(vx*vx+vy*vy);

			vx/=dist; vy/=dist;

			gBulletObject.m_fvx=vx;
			gBulletObject.m_fvy=vy;
		}


		//apply위치
		gBulletObject.pfApply(&gBulletObject,delta_tick);
	
		//타이밍 계산 
		acc_tick += delta_tick;
		
		if(acc_tick > 0.1) {
			//puts("tick..\r");
			gotoxy(0,0);
			map_drawTile(&gScreenBuffer[0],0,0,&gScreenBuffer[1]);
			gPlayerObject.pfDraw(&gPlayerObject,&gScreenBuffer[1]);
			gBulletObject.pfDraw(&gBulletObject,&gScreenBuffer[1]);
			
			//Plane_Draw(&gPlayerObject,&gScreenBuffer[1]);
			map_dump(&gScreenBuffer[1],Default_Tilepalete);
			acc_tick = 0;
		}

	}

	return 0;

}
示例#21
0
int main()
{
	set_conio_terminal_mode();
	acc_tick=last_tick=0;
	system("clear");
	map_init(&gScreenBuffer);
	map_new(&gScreenBuffer,45,20);

	map_init(&gBackBuffer);
	map_new(&gBackBuffer,45,20);

	map_init(&gF22Raptor);
	map_load(&gF22Raptor,"plane.dat");

	map_init(&gF22Bullet);
	map_load(&gF22Bullet,"bullet1.dat");

	map_init(&gPotal);
	map_load(&gPotal,"potal.dat");

	map_init(&gPotalBulletModel);
	map_load(&gPotalBulletModel,"plasma.dat");

	Plane_init(&gPlayerPlane,&gF22Raptor,35,17);
	Potal_init(&gPlayerPotal,&gPotal,1,1);
	//Potal_Bullet_init(&gPotalBulletObject,0,0,0,&gPotalBulletModel);

	for(int i=0;i<sizeof(g_bullets)/sizeof(_S_Bullet_Object);i++){
		bullet_init(&g_bullets[i],0,0,0,&gF22Bullet);
	}

	for(int i=0;i<sizeof(gPotalBulletObject)/sizeof(_S_Potal_Bullet_Object);i++){
		Potal_Bullet_init(&gPotalBulletObject[i],0,0,0,&gPotalBulletModel);
	}

	while(bLoop) {
		//타이밍처리 
		clock_gettime(CLOCK_MONOTONIC,&work_timer);
		double cur_tick = work_timer.tv_sec + 
			(double)(work_timer.tv_nsec * 1e-9);
		double delta_tick = cur_tick - last_tick;
		last_tick = cur_tick;

		clock_gettime(CLOCK_MONOTONIC,&work_timer2);
		double cur_tick2 = work_timer2.tv_sec + 
			(double)(work_timer2.tv_nsec * 1e-9);
		double delta_tick2 = cur_tick2 - last_tick2;
		last_tick2 = cur_tick2;

		//실시간 입력
		if(kbhit() != 0) {
			char ch = getch();
			if(ch == 'q') {
				bLoop = 0;
				puts("bye~ \r");
			}
			
			else if(ch=='j'){
				for(int i=0;i<sizeof(g_bullets)/sizeof(_S_Bullet_Object);i++){
					_S_Bullet_Object *pObj=&g_bullets[i];
					if(pObj->m_nFSM==0){	//슬립상태
						bullet_fire(pObj,gPlayerPlane.m_nXpos,gPlayerPlane.m_nYpos,10,5.0);
						break;
					}
				}
			}

			else if(ch=='k'){

				for(int i=0;i<sizeof(gPotalBulletObject)/sizeof(_S_Potal_Bullet_Object);i++){
					_S_Potal_Bullet_Object *pObj=&gPotalBulletObject[i];

					if(pObj->m_nFSM==0){

					double vx,vy,c;
					double angle=0;

					angle+=(delta_tick2*45);
					double rad=(angle/180.0)*PI;

					vx=(gPlayerPlane.m_nXpos-gPlayerPotal.m_nXpos)*cos(rad)-(gPlayerPlane.m_nYpos-gPlayerPotal.m_nYpos)*sin(rad);
					vy=(gPlayerPlane.m_nXpos-gPlayerPotal.m_nXpos)*sin(rad)+(gPlayerPlane.m_nYpos-gPlayerPotal.m_nYpos)*cos(rad);
	/*
					vx=gPlayerPlane.m_nXpos-gPlayerPotal.m_nXpos;
					vy=gPlayerPlane.m_nYpos-gPlayerPotal.m_nYpos;
	*/				
					c=sqrt(vx*vx+vy*vy);
					
					vx/=c; vy/=c;

					Potal_Bullet_Fire(&gPotalBulletObject[i],gPlayerPotal.m_nXpos,gPlayerPotal.m_nYpos,vx,vy,10,0);
					
					

					break;
					}
				}
			}
	
			Plane_Apply(&gPlayerPlane,delta_tick2,ch);

		}

		for(int i=0;i<sizeof(g_bullets)/sizeof(_S_Bullet_Object);i++){
				_S_Bullet_Object *pObj=&g_bullets[i];
				bullet_apply(pObj,delta_tick);
		}
		//apply 위치..
		//Potal_Bullet_Apply(&gPotalBulletObject,delta_tick2);

		//타이밍 계산 
		acc_tick += delta_tick;
		acc_tick2 += delta_tick2;
		if(acc_tick && acc_tick2 > 0.1) {
			
			map_drawTile(&gBackBuffer,0,0,&gScreenBuffer); //클리어 

			//map_drawTile_trn(&gF22Raptor,xpos,ypos,&gScreenBuffer);//오브잭트 출력 
			
			Plane_Draw(&gPlayerPlane,&gScreenBuffer);
			Potal_Draw(&gPlayerPotal,&gScreenBuffer);
			
			for(int i=0;i<sizeof(g_bullets)/sizeof(_S_Bullet_Object);i++){
				_S_Bullet_Object *pObj=&g_bullets[i];
				bullet_draw(pObj,&gScreenBuffer);
			}

			for(int i=0;i<sizeof(gPotalBulletObject)/sizeof(_S_Potal_Bullet_Object);i++){
				_S_Potal_Bullet_Object *pObj=&gPotalBulletObject[i];
				Potal_Bullet_Draw(pObj,&gScreenBuffer);
			}

			gotoxy(0,0);
			puts("---------------------------------------------\r");
			map_dump(&gScreenBuffer,Default_Tilepalete);
			puts("---------------------------------------------\r");

			puts("move : w,a,s,d \r");
			puts("quit : q \r");
			
			acc_tick = 0;
			acc_tick2 = 0;
		}

	}

	return 0;

}
示例#22
0
文件: ex3.game.c 项目: chaem/test
int main(int argc, char *argv[])
{
	if (argc < 2) {
		gnPlayerIndex = 0;
	}
	else {
		gnPlayerIndex = atoi(argv[1]);
	}
	printf("ready player %d \r\n",gnPlayerIndex);

// socket connecting try
	struct sockaddr_in server;

	socket_desc = socket(AF_INET,SOCK_STREAM,0);
	if(socket_desc == -1)
	{
		puts("err create socket");
	}
	server.sin_addr.s_addr = inet_addr("127.0.0.1");
	server.sin_family = AF_INET;
	server.sin_port = htons(8080);
	if(connect(socket_desc,(struct sockaddr *)&server,sizeof(server)) < 0) {
		puts("connect error");
		return 1;
	}

	puts("connect ok!");
// thread operate
	{
		int err = pthread_create(&tid,NULL,&InputThread,NULL);
		if(err != 0) {
			printf("err : %s \r\n",strerror(err));
		}
		else {
			printf("thread create success \r\n");
		}
	}

	{
		int err = pthread_create(&tid,NULL,&ListenThread,NULL);
		if(err != 0) {
			printf("err : %s \r\n",strerror(err));
		}
		else {
			printf("thread create success \r\n");
		}
	}
	puts("sytemp ready!");
	sleep(3);

// game resource loading
	for(int i=0;i<2;i++)
	{
		map_init(&gScreenBuf[i]);
		map_new(&gScreenBuf[i],35,16);
	}

	map_init(&gPlayerModel);
	map_load(&gPlayerModel,"plane1.dat");

	Plane_init(&gPlayerObject[0],&gPlayerModel,0,0);
	gPlayerObject[0].m_nFSM = 1;

	Plane_init(&gPlayerObject[1],&gPlayerModel,0,0);
	gPlayerObject[1].m_nFSM = 1;

	puts("object setup complete!");
	sleep(1);	
	system("clear");

	set_conio_terminal_mode();
	acc_tick=last_tick=0;

	while(bLoop) {
		clock_gettime(CLOCK_MONOTONIC,&work_timer);
		double cur_tick = work_timer.tv_sec + 
			(double)(work_timer.tv_nsec * 1e-9);
		double delta_tick = cur_tick - last_tick;
		last_tick = cur_tick;

		acc_tick += delta_tick;
		if(acc_tick > 0.1) {
			gotoxy(0,0);
			map_drawTile(&gScreenBuf[0],0,0,&gScreenBuf[1]);
		
			gPlayerObject[0].pfDraw(&gPlayerObject[0],&gScreenBuf[1]);
			gPlayerObject[1].pfDraw(&gPlayerObject[1],&gScreenBuf[1]);

			map_dump(&gScreenBuf[1],Default_Tilepalete);
			acc_tick = 0;
		}

	}

	return 0;

}
示例#23
0
int main(int argc,char *argv[])
{
	if(argc < 2) {
		gnPlayerIndex = 0;
	}
	else {
		gnPlayerIndex = atoi(argv[1]);
	}

	printf("ready player %d \r\n",gnPlayerIndex);
	

//소켓 연결 시도...
	struct sockaddr_in server;

	socket_desc = socket(AF_INET,SOCK_STREAM,0);
	if(socket_desc == -1)
	{
		puts("err create socket");
	}
	server.sin_addr.s_addr = inet_addr("127.0.0.1");
	server.sin_family = AF_INET;
	server.sin_port = htons(8080);
	if(connect(socket_desc,(struct sockaddr *)&server,sizeof(server)) < 0) {
		puts("connect error");
		return 1;
	}

	puts("connect ok!");
//쓰레드 기동 ..
	{
		int err = pthread_create(&tid,NULL,&InputThread,NULL);
		if(err != 0) {
			printf("err : %s \r\n",strerror(err));
		}
		else {
			printf("thread create success \r\n");
		}
	}

	{
		int err = pthread_create(&tid,NULL,&ListenThread,NULL);
		if(err != 0) {
			printf("err : %s \r\n",strerror(err));
		}
		else {
			printf("thread create success \r\n");
		}
	}

	puts("system ready!");
	sleep(3);

//게임 리소스 로딩 
	for(int i=0;i<2;i++)
	{
		map_init(&gScreenBuf[i]);
		map_new(&gScreenBuf[i],60,30);
	}

	map_init(&gPlayerModel);
	map_load(&gPlayerModel,"plane1.dat");

	map_init(&gPlaneBulletModel);
	map_load(&gPlaneBulletModel,"bullet1.dat");

	map_init(&gPotal);
	map_load(&gPotal,"potal.dat");

	map_init(&gAlienModel);
	map_load(&gAlienModel,"alien.dat");

	map_init(&gPlasmaModel);
	map_load(&gPlasmaModel,"plasma.dat");

    Plane_init(&gPlayerObject[0],&gPlayerModel,5,25);
	gPlayerObject[0].m_nFSM = 1;

    Plane_init(&gPlayerObject[1],&gPlayerModel,50,25);
	gPlayerObject[1].m_nFSM = 1;

	Potal_init(&gPlayerPotal,&gPotal,1,1);

    for(int i=0;i<sizeof(gPlaneBulletObjects)/sizeof(_S_PLANE_BULLET_OBJECT);i++){
		plane_bullet_init(&gPlaneBulletObjects[i],0,0,0,&gPlaneBulletModel);
	}

	for(int i=0;i<sizeof(gPlasmaObjects)/sizeof(_S_BULLET_OBJECT);i++){
		bullet_init(&gPlasmaObjects[i],0,0,0,&gPlasmaModel);
	}

    double TablePosition[]={0,10,20,30,40,50,60};

	for(int i=0;i<6;i++){
		_S_ALIEN_OBJECT *pObj=&gAlienObjects[i];
		alien_init(pObj,&gAlienModel);
		pObj->m_fXpos=TablePosition[i];
		pObj->m_fYpos=5;
		pObj->m_nFSM=1;
		gAlienObjects[i].m_pBullet=&gPlasmaObjects[i];

	}

	puts("object setup ok!");
	sleep(1);

	system("clear");

	set_conio_terminal_mode();
	acc_tick=last_tick=0;

	while(bLoop) {
		//타이밍처리 
		clock_gettime(CLOCK_MONOTONIC,&work_timer);
		double cur_tick = work_timer.tv_sec + 
			(double)(work_timer.tv_nsec * 1e-9);
		double delta_tick = cur_tick - last_tick;
		last_tick = cur_tick;

        for(int i=0;i<sizeof(gPlaneBulletObjects)/sizeof(_S_PLANE_BULLET_OBJECT);i++) {
			_S_PLANE_BULLET_OBJECT *pObj=&gPlaneBulletObjects[i];
			pObj->pfApply(pObj,delta_tick);

		}

		for(int i=0;i<6;i++ ){
			_S_ALIEN_OBJECT *pObj=&gAlienObjects[i];
			pObj->pfApply(pObj,delta_tick);

		}

		// _S_Potal_Bullet_Object *pObj=&gPotalBulletObject;
		// 	if(pObj->m_nFSM==0){
        //             double potal_bullet_posx=gPlayerPotal.m_nXpos;
        //             double potal_bullet_posy=gPlayerPotal.m_nYpos;

        //             double target_x=gPlayerObject[0].m_fXpos;
        //             double target_y=gPlayerObject[0].m_fYpos;

		// 			double vx=target_x-potal_bullet_posx;
        //             double vy=target_y-potal_bullet_posy;

        //             double dist=sqrt(vx*vx+vy*vy);
        //             vx/=dist; vy/=dist;

		// 			Potal_Bullet_Fire(&gPotalBulletObject,gPlayerPotal.m_nXpos,gPlayerPotal.m_nYpos,10,vx,vy,10.0);
		// 	}

		//총알 맞았을때 게임오버
		for(int i=0;i<sizeof(gPlasmaObjects)/sizeof(_S_BULLET_OBJECT);i++) {
			if(gPlasmaObjects[i].m_nFSM!=0) {
				
				double bullet_posx=gPlasmaObjects[i].m_fXpos;
				double bullet_posy=gPlasmaObjects[i].m_fYpos;

				double target_posx=gPlayerObject[0].m_fXpos;
				double target_posy=gPlayerObject[0].m_fYpos;

				double vx=target_posx-bullet_posx;
				double vy=target_posy-bullet_posy;

				double dist=sqrt(vx*vx+vy*vy);

				if(dist<0.1) {
					gPlasmaObjects[i].m_nFSM=0;
					gPlayerObject[0].m_nFSM=0;
					gAlienObjects[i].m_nFSM=0;
					system("clear");
					printf("----------------------\r\n");
					printf("      Game over\r\n");
					printf("----------------------\r\n");

					bLoop=0;
				}
			}
		}

		//alien 총알 맞았을때
		for(int i=0;i<sizeof(gPlaneBulletObjects)/sizeof(_S_PLANE_BULLET_OBJECT);i++) {
			if(gPlaneBulletObjects[i].m_nFSM!=0) {
				double bullet_posx=gPlaneBulletObjects[i].m_fXpos;
				double bullet_posy=gPlaneBulletObjects[i].m_fYpos;

				double target_posx= gAlienObjects[i].m_fXpos;
				double target_posy= gAlienObjects[i].m_fYpos;

				double vx=target_posx-bullet_posx;
				double vy=target_posy-bullet_posy;
				double dist=sqrt(vx*vx+vy*vy);

				if(dist<5.0) {
					gAlienObjects[i].m_nFSM=0;
				}
			}
		}	

		for(int i=0;i<sizeof(gPlasmaObjects)/sizeof(_S_BULLET_OBJECT);i++) {
			gPlasmaObjects[i].pfApply(&gPlasmaObjects[i],delta_tick);

		}

		Potal_Bullet_Apply(&gPotalBulletObject,delta_tick);

        //충돌여부확인-거리계산
        {
            double potal_bullet_posx=gPlayerPotal.m_nXpos;
            double potal_bullet_posy=gPlayerPotal.m_nYpos;

            double target_x=gPlayerObject[0].m_fXpos;
            double target_y=gPlayerObject[0].m_fYpos;

            double angle=0;
    		angle+=(delta_tick*45);
	    	double rad=(angle/180.0)*PI;

			double vx=(target_x-potal_bullet_posx)*cos(rad)-(target_y-potal_bullet_posy)*sin(rad);
			double vy=(target_x-potal_bullet_posx)*sin(rad)+(target_y-potal_bullet_posy)*cos(rad);
		
            double dist=sqrt(vx*vx+vy*vy);

            if(dist<0.1){
                gPotalBulletObject.m_nFSM=0;
            }
         }

        acc_bullet_delay_tick+=delta_tick;
		if(acc_bullet_delay_tick>2.0){	//2초동안 방향설정

			acc_bullet_delay_tick=0;

			double bullet_posx=gPotalBulletObject.m_fXpos;
			double bullet_posy=gPotalBulletObject.m_fYpos;

			double target_posx=gPlayerObject[0].m_fXpos;
			double target_posy=gPlayerObject[0].m_fYpos;

			double vx=target_posx-bullet_posx;
			double vy=target_posy-bullet_posy;

			double dist=sqrt(vx*vx+vy*vy);

			vx/=dist; vy/=dist;

			gPotalBulletObject.m_fvx=vx;
			gPotalBulletObject.m_fvy=vy;
		}

		//타이밍 계산 
		acc_tick += delta_tick;
		if(acc_tick > 0.1) {
			gotoxy(0,0);
			map_drawTile(&gScreenBuf[0],0,0,&gScreenBuf[1]);
			
			for(int i=0;i<2;i++){
		    	gPlayerObject[i].pfDraw(&gPlayerObject[i],&gScreenBuf[1]);
            }

			Potal_Draw(&gPlayerPotal,&gScreenBuf[1]);
			Potal_Bullet_Draw(&gPotalBulletObject,&gScreenBuf[1]);

            for(int i=0;i<sizeof(gPlaneBulletObjects)/sizeof(_S_PLANE_BULLET_OBJECT);i++){
				_S_PLANE_BULLET_OBJECT *pObj = &gPlaneBulletObjects[i];
				pObj->pfDraw(pObj,&gScreenBuf[1]);
			}

            for(int i=0;i<6;i++) {
				_S_ALIEN_OBJECT *pObj = &gAlienObjects[i];
				pObj->pfDraw(pObj,&gScreenBuf[1]);
			}

			for(int i=0;i<sizeof(gPlasmaObjects)/sizeof(_S_BULLET_OBJECT);i++){
				gPlasmaObjects[i].pfDraw(&gPlasmaObjects[i],&gScreenBuf[1]);
			}
			
			puts("------------------------------------------------------------\r");
			map_dump(&gScreenBuf[1],Default_Tilepalete);
			puts("------------------------------------------------------------\r");

			puts("move :  w,  a,  s,  d \r");
            puts("player0 fire : j   player1 fire : k");
			puts("quit : q \r");
			acc_tick = 0;
		}

	}

	return 0;

}
示例#24
0
int main(){	
	InitFramebuffer(&width, &height);
	// Image spaceshipImage = LoadBitmapAsImage("spaceship.bmp");
	Image parachuteImage = LoadBitmapAsImage("parachute.bmp");
	parachuteImage.pivot.y = 0;
	Image backgroundImage = LoadBitmapAsImage("background.bmp");
	Image rocketImage = LoadBitmapAsImage("rocket.bmp");
	Image missileImage = LoadBitmapAsImage("rocket.bmp");
	Image planeImage = LoadBitmapAsImage("plane.bmp");
	Image propellerImage = LoadBitmapAsImage("propeller.bmp");

	int rot = 0;
	int rocket_rot=0;
	int missile_rot = 0;
	int rot_offset = 6;
	int rocket_offset = 6;
	int rot_max = 50;
	int y_parachute = 300;
	int y_parachute2 = 300;
	int y_parachute_offset = 10;
	int i;
	
	//Plane vars
	int plane_x = width/2 -20;
	int plane_y = height/2 -35;
	float plane_scale = 1.0;
	int plane_rot = 0;
	int isPlaneFall = 0;
	
	//Propeller vars
	int propeller_rot = 0;
	float propeller_scale = 1.0;
	
	//Missile Variable
	int missile_launched = 0;
	int missile_offset = 15;
	int missile_x = backgroundImage.w/2;
	int missile_y = backgroundImage.h;
	float missile_scale = 0;
	int missile_rotation = 0;

	set_conio_terminal_mode();

	for(i=0; i < 10000; i++){
		ClearScreen();
		
		rot = ((rot + rot_offset)% rot_max);
		if (rot_max - rot < 3){
			rot_offset *=  -1;
		}
		else if (rot_max - rot > 97){
			rot_offset *=  -1;
		}

		propeller_rot+=35;
		propeller_rot %= 360;
		propeller_scale += 0.03;
		
		
		DrawImage(width/2, height/2, &backgroundImage, 1.0f, 0);
		DrawImage(300,y_parachute += y_parachute_offset, &parachuteImage, 0.5f, rot);
		DrawImage(backgroundImage.w/2, backgroundImage.h, &rocketImage, 1.0f, rocket_rot);
		if(i>20)
			isPlaneFall = 1;
		//draw plane
		if(!isPlaneFall){
			DrawImage(plane_x, plane_y, &planeImage, plane_scale, plane_rot);
			plane_scale += 0.03;
		}
		else{
			DrawImage(plane_x, plane_y, &planeImage, plane_scale, plane_rot);
			plane_y += 8;
			plane_rot = (plane_rot + 2) % 360;
		}
		
		//draw propeller
		DrawImage(width/2, height/2, &propellerImage, propeller_scale, propeller_rot);
		
		if (missile_launched == 1){
			DrawImage(missile_x += missile_rot,missile_y -= missile_offset, &rocketImage, 1.0f, missile_rot);			
		}
		if (missile_finished_launched(missile_x,missile_y,backgroundImage.w) ){
			missile_x = backgroundImage.w/2;
			missile_y = backgroundImage.h;
			missile_launched = 0;
			missile_rot = rocket_rot;
		}

		DrawLine(0,0, 700, 600, (Color32){255,0,0,255});
		
		if(kbhit()){
			char c = getch();
			if(c == 'a'){
				if (rot_max - rocket_rot < 3){
				}
				else{
					rocket_rot = ((rocket_rot - rocket_offset)% rot_max);
				}
				fflush(stdin);

			} 
			else if(c == 'd'){
				printf("Kanan");
				printf("%d", rocket_rot);
				if (rot_max - rocket_rot > 97){
				}else{
					rocket_rot = ((rocket_rot + rocket_offset)% rot_max);
				}

			}
			else if(c == 'z'){
				missile_launched = 1;
			}

			else if (c == 'x'){
				break;
			}
			
		}
		
		SwapBuffers();
		usleep(33333);
	}
	
	//free image
	FreeImage(&parachuteImage);
	FreeImage(&backgroundImage);
	FreeImage(&planeImage);
	FreeImage(&propellerImage);
	CloseFramebuffer();
	return 0;
}
示例#25
0
int main()
{
	{
		int err = pthread_create(&tid,NULL,&InputThread,NULL);
		if(err != 0) {
			printf("err : %s \r\n",strerror(err));
		}
		else {
			printf("thread create success \r\n");
		}
	}

	struct sockaddr_in server;

	socket_desc = socket(AF_INET,SOCK_STREAM,0);
	if(socket_desc == -1)
	{
		puts("err create socket");
	}
	server.sin_addr.s_addr = inet_addr("127.0.0.1");
	server.sin_family = AF_INET;
	server.sin_port = htons(8080);
	if(connect(socket_desc,(struct sockaddr *)&server,sizeof(server)) < 0) {
		puts("connect error");
		return 1;
	}

	for(int i=0;i<2;i++)
	{
		map_init(&gScreenBuf[i]);
		map_new(&gScreenBuf[i],35,16);
	}

	map_init(&gPlayerModel);
	map_load(&gPlayerModel,"plane.dat");

	Plane_init(&gPlayerObject,&gPlayerModel,15,10);
	gPlayerObject.m_nFSM = 1;
	system("clear");

	set_conio_terminal_mode();
	acc_tick=last_tick=0;

	while(bLoop) {
		//타이밍처리 
		clock_gettime(CLOCK_MONOTONIC,&work_timer);
		double cur_tick = work_timer.tv_sec + 
			(double)(work_timer.tv_nsec * 1e-9);
		double delta_tick = cur_tick - last_tick;
		last_tick = cur_tick;

		//타이밍 계산 
		acc_tick += delta_tick;
		if(acc_tick > 0.1) {
			gotoxy(0,0);
			map_drawTile(&gScreenBuf[0],0,0,&gScreenBuf[1]);
		
			gPlayerObject.pfDraw(&gPlayerObject,&gScreenBuf[1]);
			
			map_dump(&gScreenBuf[1],Default_Tilepalete);
			acc_tick = 0;
		}

	}

	return 0;

}
示例#26
0
int main()
{

	system("clear");
	for(int i=0;i<10;i++)
	{
		map_init(&gScreenBuf[i]);
		map_new(&gScreenBuf[i],35,30);
	}
	map_init(&gPlaneModel);
	map_load(&gPlaneModel,"plane5.dat");


	map_init(&gAlienModel);
	map_load(&gAlienModel,"alien5.dat");

	map_init(&gPlasmaModel);
	map_load(&gPlasmaModel,"bullet5.dat");

	map_init(&gBulletModel);
	map_load(&gBulletModel,"bullet5.dat");


	Plane_init(&gTestPlaneObject,&gPlaneModel,17,25);
	

	gTestPlaneObject.m_nFSM = 1;

	double TablePosition[] = {0,3.0,6.0,9.0,12.0,15.0,18.0,21.0,24.0};

	for(int i=0;i< sizeof(gTestBulletObject)/sizeof(_S_BULLET_OBJECT); i++)
	{
		bullet_init(&gTestBulletObject[i],0,0,0,&gBulletModel);
	}
		for(int i=0;i< 10; i++)
	{
		bullet_init(&gTestBulletObject2[i],0,0,0,&gPlasmaModel);
	}
	
	
	for(int i=0;i<10;i++)
	{
		_S_ALIEN_OBJECT *pObj = &gTestAlienObject[i];
		alien_init(pObj,&gAlienModel,1,2);
		pObj->m_fXpos = TablePosition[i];
		pObj->m_fYpos = 3;
		pObj->m_nFSM = 1;
		gTestAlienObject[i].m_pBullet = &gTestBulletObject2[i];
	}


	set_conio_terminal_mode();
	acc_tick=last_tick=0;

	while(bLoop) {
		//타이밍처리 
		clock_gettime(CLOCK_MONOTONIC,&work_timer);
		double cur_tick = work_timer.tv_sec + 
			(double)(work_timer.tv_nsec * 1e-9);
		double delta_tick = cur_tick - last_tick;
		last_tick = cur_tick;
		//실시간 입력
		if(kbhit() != 0) {
			char ch = getch();
			if(ch == 'q') {
				bLoop = 0;
				puts("bye~ \r");
			}
			if(ch == 'j') {
				for(int i=0;i<sizeof(gTestBulletObject)/sizeof(_S_BULLET_OBJECT);i++) {
					_S_BULLET_OBJECT *pObj = &gTestBulletObject[i];
					if(pObj->m_nFSM == 0) { //슬립상태라면...
						pObj->pfFire(pObj,
								gTestPlaneObject.m_fXpos,
								gTestPlaneObject.m_fYpos,5,0,-2,10);
						break;
					}

				}
			}
		
			gTestPlaneObject.pfApply(&gTestPlaneObject,delta_tick,ch);
		}
	
		

		for(int i=0;i<sizeof(gTestBulletObject)/sizeof(_S_BULLET_OBJECT);i++) {
			_S_BULLET_OBJECT *pObj = &gTestBulletObject[i];
			pObj->pfApply(pObj,delta_tick);


		}
		for(int i=0;i<10;i++) {
			_S_ALIEN_OBJECT *pObj = &gTestAlienObject[i];
			pObj->pfApply(pObj,delta_tick);		
	
		}
		for(int i=0;i<10;i++) {
			gTestBulletObject2[i].pfApply(&gTestBulletObject2[i],delta_tick);
		

		if(gTestBulletObject2[i].m_nFSM != 0)	{
	
			double dist = getDistance(&gTestBulletObject2[i],&gTestPlaneObject);

			if(dist < 1.0) {
				gTestBulletObject2[i].m_nFSM = 0;
				gTestPlaneObject.m_nFSM = 0;
			}
		}

}
	

		//타이밍 계산 
		acc_tick += delta_tick;
		if(acc_tick > 0.1) {
			gotoxy(0,0);
			map_drawTile(&gScreenBuf[0],0,0,&gScreenBuf[1]);
			gTestPlaneObject.pfDraw(&gTestPlaneObject,&gScreenBuf[1]);

			for(int i=0;i<sizeof(gTestBulletObject)/sizeof(_S_BULLET_OBJECT);i++) {
				_S_BULLET_OBJECT *pObj = &gTestBulletObject[i];
				pObj->pfDraw(pObj,&gScreenBuf[1]);	
			}



			for(int i=0;i<10;i++) {

				_S_ALIEN_OBJECT *pObj = &gTestAlienObject[i];
				pObj->pfDraw(pObj,&gScreenBuf[1]);
			}
			for(int i=0;i<4;i++) {

				_S_BULLET_OBJECT *pObj = &gTestBulletObject2[i];
				pObj->pfDraw(pObj,&gScreenBuf[1]);
			}


			map_dump(&gScreenBuf[1],Default_Tilepalete);
			acc_tick = 0;
		}

	}

	return 0;

}
示例#27
0
文件: game.c 项目: chaem/test
/*=======================================================*/
int main()
{
    set_conio_terminal_mode();
	acc_tick = last_tick = 0;

 	while(bLoop) {
		// time process
		clock_gettime(CLOCK_MONOTONIC,&work_timer);
		double cur_tick = work_timer.tv_sec + 
			(double)(work_timer.tv_nsec * 1e-9);
		double delta_tick = cur_tick - last_tick;
		last_tick = cur_tick;

		// input
		if (nFSM == 0) {
			gameStart_Title(delta_tick);

		}
		else if (nFSM == 1) { 
			gameStart_Play();

		}

        if(kbhit() != 0) {
			char ch = getch();
			if(ch == 'q') {
				bLoop = 0;
				puts("bye~ \r");
			}
            else if (ch =='p') {  //laser
				double bullet_pos_x = gTestBulletObject.m_fXpos;
				double bullet_pos_y = gTestBulletObject.m_fYpos;
			
				double target_pos_x = gPlaneObject.m_fXpos;
				double target_pos_y = gPlaneObject.m_fYpos;

				double vx = target_pos_x - bullet_pos_x;
				double vy = target_pos_y - bullet_pos_y;
				double dist  = sqrt(vx*vx+vy*vy);
				vx /= dist;
				vy /= dist;

				gLaserObject.pfFire(&gLaserObject,
				gPlaneObject.m_fXpos,gPlaneObject.m_fYpos,
				-1,0,gPlaneObject.m_fYpos,15);

			}

			gPlaneObject.pfApply(&gPlaneObject,delta_tick,ch);

        }
        gTestAlienObject.pfApply(&gTestAlienObject,delta_tick);
		gTestBulletObject.pfApply(&gTestBulletObject,delta_tick);
		gLaserObject.pfApply(&gLaserObject,delta_tick);

		if (gTestBulletObject.m_nFSM != 0) {
			double bullet_pos_x = gTestBulletObject.m_fXpos;
			double bullet_pos_y = gTestBulletObject.m_fYpos;

			double target_pos_x = gPlaneObject.m_fXpos;
			double target_pos_y = gPlaneObject.m_fYpos;

			double vx = target_pos_x + bullet_pos_x;
			double vy = target_pos_y + bullet_pos_y;
			double dist  = sqrt(vx*vx+vy*vy);

			if(dist < 2) {
				gTestBulletObject.m_nFSM = 0;
				gPlaneObject.m_nFSM = 0;
				
			}

		}
        acc_tick += delta_tick;
		if(acc_tick > 0.1) {
			gotoxy(0,0);
			map_drawTile(&gScreenBuf[0],0,0,&gScreenBuf[1]);

			setColor(33,40);
			gPlaneObject.pfDraw(&gPlaneObject,&gScreenBuf[1]);
			gTestAlienObject.pfDraw(&gTestAlienObject,&gScreenBuf[1]);
			gTestBulletObject.pfDraw(&gTestBulletObject,&gScreenBuf[1]);
			gLaserObject.pfDraw(&gLaserObject,&gScreenBuf[1]);

			map_dump(&gScreenBuf[1],Default_Tilepalete);
			acc_tick = 0;
		}

     }

    return 0;

}
示例#28
0
文件: game.c 项目: dldud/gittest
int main()
{

	for(int i=0;i<2;i++)
	{
		map_init(&gScreenBuf[i]);
		map_new(&gScreenBuf[i],35,35);
	}

	map_init(&gPlayerModel);
	map_load(&gPlayerModel,"airplane.dat");
	
	map_init(&gBulletModel);
	map_load(&gBulletModel,"bullet1.dat");
	
	map_init(&gAlienModel);
	map_load(&gAlienModel,"tank1.dat");
	
	Plane_init(&gPlayerObject,&gPlayerModel,17,10);
	//bullet_init(&gBulletModel,0,0,0,&gBulletModel);
		
	gPlayerObject.m_nFSM = 1;

	double TablePosition[] = {0,8,16,24};
	
/*	for(int i=0;i<2;i++)
	{
		_S_BULLET_OBJECT *pObj = &gBulletObject[i];
		bullet_init(pObj,&gBulletObject[i];
		pObj->m_nFSM = 1;
	}
*/
	for(int i=0;i<4;i++)
	{
		_S_ALIEN_OBJECT *pObj = &gAlienObjects[i];
		alien_init(pObj,&gAlienModel);
		pObj->m_fXpos = TablePosition[i];
		pObj->m_fYpos = 2;
		pObj->m_nFSM = 1;
	}
/*	set_conio_terminal_mode();
	acc_tick=last_tick=0;

	int targetx,targety;

	int fire_x, fire_y;
*/
	
	system("clear");
	
	set_conio_terminal_mode();
	acc_tick=last_tick=0;

	while(bLoop) {
		//타이밍처리 
		clock_gettime(CLOCK_MONOTONIC,&work_timer);
		double cur_tick = work_timer.tv_sec + 
			(double)(work_timer.tv_nsec * 1e-9);
		double delta_tick = cur_tick - last_tick;
		last_tick = cur_tick;
		//실시간 입력
		
/*		fire_x = gAlienObjects.m_nXpos;
		fire_y = gAlienObjects.m_nYpos;

		targetx = gPlayerObject.m_nXpos;
		targety = gPlayerObject.m_nypos;
*/	
		if(kbhit() != 0) {
			char ch = getch();
			if(ch == 'q') {
				bLoop = 0;
				puts("bye~ \r");
			}
/*			else if(ch == 'j') {
				double vx,vy,c;
				vx = targetx - fire_x;
				vy = targety - fire_y;
				c = sqrt(vx*vx+vy*vy);
				vx /= c;
				vy /= c;

				bullet_fire(&gBulletObject,fire_x,fire_y,10.0,vx,vy,10.0);
			
			}*/
		gPlayerObject.pfApply(&gPlayerObject,delta_tick,ch);
//		bullet_apply(&gBulletObject,delta_tick);
		}

		for(int i=0;i<4;i++ ) 
		{
			_S_ALIEN_OBJECT *pObj = &gAlienObjects[i];
			pObj->pfApply(pObj,delta_tick);

		}


		//타이밍 계산 
		acc_tick += delta_tick;
		if(acc_tick > 0.1) {
			gotoxy(0,0);
			map_drawTile(&gScreenBuf[0],0,0,&gScreenBuf[1]);
	//		bullet_draw(&gBulletObjects, &gScreenBuf[1]);
			gPlayerObject.pfDraw(&gPlayerObject,&gScreenBuf[1]);
				
			for(int i=0;i<4;i++ ) 
			{
				_S_ALIEN_OBJECT *pObj = &gAlienObjects[i];
				pObj->pfDraw(pObj,&gScreenBuf[1]);
			}

			map_dump(&gScreenBuf[1],Default_Tilepalete);
			acc_tick = 0;
		}

	}

	return 0;
}
示例#29
0
void cons_init(void)
{
    set_conio_terminal_mode();
}
示例#30
0
文件: ex1.c 项目: chaem/test
int main()
{
	set_conio_terminal_mode();
	acc_tick=last_tick=0;

	for (int i=0; i<2; i++) {
		map_init(&gScreenBuffer[i]);
		map_new(&gScreenBuffer[i],35,15);

	}
	map_init(&gMissile);
	map_load(&gMissile,"plasma.dat");
	missile_init(&gMissileObject,0,0,0,&gMissile);

	system("clear");	

	//target
	int targetx, targety;
	targety = 3;
	targetx = 2; 

	int fire_x = 24;
	int fire_y = 12;


	while(bLoop) {
		//time process
		clock_gettime(CLOCK_MONOTONIC,&work_timer);
		double cur_tick = work_timer.tv_sec + 
			(double)(work_timer.tv_nsec * 1e-9);
		double delta_tick = cur_tick - last_tick;
		last_tick = cur_tick;
		//input
		if(kbhit() != 0) {
			char ch = getch();
			if(ch == 'q') {
				bLoop = 0;
				puts("bye~ \r");
			}
			else if (ch == 'j') {
				double vx, vy, c;
				vx = targetx - fire_x;
				vy = targety - fire_y;
				c = sqrt(vx*vx + vy*vy);
				vx /= c;
				vy /= c;
		
				missile_fire(&gMissileObject,
				fire_x, fire_y,
				10.0, vx, vy,
				10);
					
			}
			else if (ch == 'a') {
				targetx -= 1;

			}
			else if (ch == 'd') {
				targetx += 1;

			}

		}

		// apply location
		missile_apply(&gMissileObject,delta_tick);

		// time calculate
		acc_tick += delta_tick;
		if(acc_tick > 0.1) {
			//puts("tick...\r");
			map_drawTile(&gScreenBuffer[0],0,0,&gScreenBuffer[1]);
			missile_draw(&gMissileObject,&gScreenBuffer[1]);	
			gotoxy(0,0);
			
			map_PutTile(&gScreenBuffer[1],fire_x,fire_y,1);
			map_PutTile(&gScreenBuffer[1],targetx,targety,5);

			map_dump(&gScreenBuffer[1],Default_Tilepalete);
			acc_tick = 0;
		}

	}

	return 0;

}