1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
Ball *ball;
void initObject()
{
int irad = 8;
int ix = 20;
int iy = 150;
float col[3];
col[0]=0;
col[1]=1;
col[2]=0;
cannonPower = 2;
angle = 0;
ball = new Ball(ix, iy, irad, col);
}
void display()
{
ball -> Show();
}
void update()
{
float distBetweenObjects;
float xDist;
float yDist;
target->tUpdate();
target ->tColDet(xTarget, yTarget);
ball ->update();
ball->bColDet(xBall, yBall);
//distance between objects
xDist = xBall - xTarget;
yDist = yBall - yTarget;
distBetweenObjects = sqrt(pow(xDist, 2) + pow(yDist, 2));
if( distBetweenObjects <= 40 ){
cout << "lolololololol";
}
}
int main(int argc, char** argv)
{
width=1200;
height=600;
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowSize(width, height);
glutInitWindowPosition(100, 100);
glutCreateWindow (argv[0]);
glClearColor(1.0, 0.0, 1.0, 1.0);
gluOrtho2D(0, width, 0, height);
glutSpecialFunc(special_keys);
glutKeyboardFunc(keyboard);
glutDisplayFunc(display);
glutTimerFunc(20, timer, 0);
initWall();
initTargObject();
bitmapInit();
initObject();
glutMainLoop();
delete background;
return 0;
}
|