本文整理汇总了C++中_S_Plane类的典型用法代码示例。如果您正苦于以下问题:C++ _S_Plane类的具体用法?C++ _S_Plane怎么用?C++ _S_Plane使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了_S_Plane类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
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;
}
开发者ID:dlawltjs,项目名称:gittest,代码行数:56,代码来源:ex8.c
示例2: getch
void *InputThread(void *arg)
{
while(1)
{
if(kbhit() != 0 ) {
char ch = getch();
if(ch == 'q') {
bLoop = 0;
puts("bye~ \r");
}
gPlayerObject.pfApply(&gPlayerObject,0,ch);
_S_PACKET_REQ_SETPOS packet_setpos = {
{1004,200,},0,
gPlayerObject.m_fXpos,
gPlayerObject.m_fYpos
};
if(send(socket_desc,
&packet_setpos,
sizeof(packet_setpos),0) < 0) {
puts("send failed");
}
}
}
return NULL;
}
开发者ID:yeongeun0325,项目名称:cygwin,代码行数:30,代码来源:ex8.game.c
示例3: main
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;
}
//.........这里部分代码省略.........
开发者ID:yeongeun0325,项目名称:cygwin,代码行数:101,代码来源:ex2.c
示例4: main
/*=======================================================*/
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;
}
开发者ID:chaem,项目名称:test,代码行数:94,代码来源:game.c
示例5: main
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++) {
//.........这里部分代码省略.........
开发者ID:tamjung00,项目名称:gittest,代码行数:101,代码来源:game_4.c
示例6: main
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;
}
开发者ID:tamjung00,项目名称:gittest,代码行数:90,代码来源:ex10.c
示例7: main
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;
}
}
//.........这里部分代码省略.........
开发者ID:dlawltjs,项目名称:gittest,代码行数:101,代码来源:ex3.c
示例8: main
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;
}
开发者ID:Honggisun,项目名称:Hong_gittest,代码行数:85,代码来源:ex4.c
示例9: main
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;
//.........这里部分代码省略.........
开发者ID:yeongeun0325,项目名称:cygwin,代码行数:101,代码来源:test.c
示例10: main
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) {
//.........这里部分代码省略.........
开发者ID:dldud,项目名称:gittest,代码行数:101,代码来源:game.c
示例11: main
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;
}
开发者ID:yeongeun0325,项目名称:cygwin,代码行数:68,代码来源:ex8.game.c
示例12: main
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);
//.........这里部分代码省略.........
开发者ID:Honggisun,项目名称:Hong_gittest,代码行数:101,代码来源:ex8.c
注:本文中的_S_Plane类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论