本文整理汇总了C++中Obstacle::isCollision方法的典型用法代码示例。如果您正苦于以下问题:C++ Obstacle::isCollision方法的具体用法?C++ Obstacle::isCollision怎么用?C++ Obstacle::isCollision使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Obstacle
的用法示例。
在下文中一共展示了Obstacle::isCollision方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: display
//.........这里部分代码省略.........
sx=0;sy=0;angle=0;tx=0;ty=0;//reset the values
}
segmentupdater(tx,ty,sx,sy,angle);
segmentparser();
}
else if(mode==2){//hege mode
displayparser();
int i,j;
print_thick_sentence(100,100,"INSTRUCTIONS",10,10,1,1,1);
for(i=0;i<225;i++)
linedda(370,250+i,955,250+i,0.05+i*0.004,0,0);
for(i=0;i<225;i++)
linedda(370,475+i,955,475+i,0.95-i*0.004,0.0,0.0);
print_thick_sentence(402,640,"THE RATE OF DECREASE OF FUEL FROM PLAYER1 IS ",2,3,1,1,1);
print_thick_sentence(402,610,"PROPORTIONAL TO THE AREA OF THE CREATED ",2,3,1,1,1);
print_thick_sentence(402,580,"OBSTACLE",2,3,1,1,1);
print_thick_sentence(402,540,"THE RATE OF DECREASE OF FUEL FROM PLAYER2 IS",2,3,1,1,1);
print_thick_sentence(402,510,"PROPORTIONAL TO THE NUMBER OF JUMPS MADE",2,3,1,1,1);
print_thick_sentence(402,470,"PLAYER1 CONTROLS .......",2,3,0,0,1);
print_thick_sentence(402,430," PRESS LEFT MOUSE BUTTON AND CREATE OBSTACLES",2,3,1,1,1);
print_thick_sentence(402,390, " PRESS RIGHT MOUSE BUTTON TO CLEAR THE BOARD",2,3,1,1,1);
print_thick_sentence(402,350,"PLAYER2 CONTROLS",2,3,0,0,1);
print_thick_sentence(402,310," PRESS SPACE TO JUMP",2,3,1,1,1);
print_thick_sentence(402,270," PRESS X TO SHOOT AT OBSTACLES",2,3,1,1,1);
}
else if(mode==3){//about mode
displayparser();
int i,j;
print_thick_sentence(100,100,"ABOUT",10,10,1,1,1);
for(i=0;i<225;i++)
linedda(380,250+i,945,250+i,0.05+i*0.004,0,0);
for(i=0;i<225;i++)
linedda(380,475+i,945,475+i,0.95-i*0.004,0.0,0.0);
print_thick_sentence(402,640,"THIS GAME IS DEVELOPED BY ALSE PRP AND ABHAY",2,3,1,1,1);
print_thick_sentence(402,600,"GLUTLE IS A 2 PLAYER GAME IN WHICH .....",2,3,1,1,1);
print_thick_sentence(402,560,"PLAYER1 - CREATES OBSTACLES",2,3,1,1,1);
print_thick_sentence(402,520,"PLAYER2 - EVADES THE CREATED OBSTACLES",2,3,1,1,1);
print_thick_sentence(402,480,"OBJECTIVE",3,5,0.0,0.0,1.0);
print_thick_sentence(402,440,"THE GAME IS BASICALLY A RACE AGAINST FUEL",2,3,1,1,1);
print_thick_sentence(402,400,"EACH PLAYER HAS TO USE HIS FUEL WISELY",2,3,1,1,1);
print_thick_sentence(402,360,"PLAYER1 ASO WINS IF THE HEALTH OF PLAYER2",2,3,1,1,1);
print_thick_sentence(402,330,"GOES BELOW ZERO",2,3,1,1,1);
}
else if(mode==4){//aadu mode
if(normalObj.health<=0||normalObj.fuel1<=0||normalObj.fuel2<=0)//check for health,fuel
mode=0;
vector<int>::iterator itr=OBSTACLE.end();
vector<int>::iterator itr1=BACKGROUND.end(); //iterator for bg
normalObj.grassField(150);
normalObj.ground(115);
normalObj.healthPoints();
background(mov1,200,*itr1);
if(mov1>width+300){//if bg goes out of the boundary
BACKGROUND.pop_back();
mov1=0;
}
if(itr1==BACKGROUND.begin())//reinitiate bg
initBg();
mov+=25+0.01*(++movinc);//obstacle speed
mov1+=5;//bg speed
board.x=width/10;board.y=300+face_y%9,board.h=300;board.w=width/3;//set board dimensions
board.draw();//draw board
//to control onmouseover of drawing board
board.onMouseOver();//control onmouseover features
normalObj.Face();//draw and control face
obstaclE.drawObstacle(mov,-obstaclE.minY+100,1);//draw obstacle in the real world
if(obstaclE.isCollision(mov,-obstaclE.minY+100)){//check for collision
if(normalObj.shieldEnable)//if shield is on?
normalObj.shieldEnable=0;
else{//hit
system("mplayer ~/.glutrix/hit.wav&");
normalObj.health-=10;
normalObj.healthColor.red+=0.08;
normalObj.healthColor.green-=0.02;
}
}
//chekpoint
normalObj.checkpoint();
//for missile collision
if((normalObj.missileEnableY>0)&&(normalObj.missileEnableX>0))
if((obstaclE.maxY-obstaclE.minY>=normalObj.missileEnableY)&&(obstaclE.maxX+mov>normalObj.missileEnableX)){//check for collision
obstaclE.clear();
normalObj.missileEnableX=0;
normalObj.missileEnableY=0;
}
if(mov>width){//when obstacle goes beyond the width
obstaclE=obstacleBuffer;//Buffer->real obstacle
normalObj.fuel2-=obstaclE.CUSTOM_OBSTACLE.size()*4;//reduce fuel2
board.distortEnable=0;//reset drawing mode to normal mode
obstacleBuffer.clear();//clear buffer
mov=0;//restart mov
}
if(itr==OBSTACLE.begin())
initialize();
obstacleBuffer.drawObstacle(0,0,0);//draw on board from buffer
}
glutSwapBuffers();
}