本文整理汇总了C++中_S_Plane::pfApply方法的典型用法代码示例。如果您正苦于以下问题:C++ _S_Plane::pfApply方法的具体用法?C++ _S_Plane::pfApply怎么用?C++ _S_Plane::pfApply使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类_S_Plane
的用法示例。
在下文中一共展示了_S_Plane::pfApply方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
//.........这里部分代码省略.........
示例3: 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;
}
示例4: main
//.........这里部分代码省略.........
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);
}
//충돌-에일리언총알에 비행기가 맞을때
示例5: 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;
}
}
//.........这里部分代码省略.........
示例6: 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;
}
示例7: main
//.........这里部分代码省略.........
_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;
示例8: 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) {
//.........这里部分代码省略.........
示例9: 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);
//.........这里部分代码省略.........