示例#1
0
文件: hw1.cpp 项目: gaararose/hw1
int main(void)
{
	int done = 0;
	srand(time(NULL));
	initXWindows();
	init_opengl();
	//declare game object
	Game game;
	game.n = 0;

	//declare a box shape
	//game.box.width = 100;
	//game.box.height = 10;
	//game.box.center.x = 120 + 5*65;
	//game.box.center.y = 500 - 5*60;

	//start animation
	while (!done) {
		while (XPending(dpy)) {
			XEvent e;
			XNextEvent(dpy, &e);
			check_mouse(&e, &game);
			done = check_keys(&e);
		}
		movement(&game);
		render(&game);
		bubbles(&game);
		glXSwapBuffers(dpy, win);
	}
	cleanupXWindows();
	return 0;
}
示例#2
0
int main(void)
{

    int done=0;
    srand(time(NULL));
    initXWindows();
    init_opengl();
    //declare game object
    Game game;
    //start animation
    while(!done) {
        while(XPending(dpy)) {
            XEvent e;
            XNextEvent(dpy, &e);
            check_mouse(&e, &game);
            done = check_keys(&e, &game);
        }
        movement(&game);
        render(&game);
        glXSwapBuffers(dpy, win);
    }
    cleanupXWindows();
    cleanup_fonts();
    return 0;
}
示例#3
0
int main(void)
{
	logOpen();
	initXWindows();
	init_opengl();
	Game game;
	init(&game);
	srand(time(NULL));
	clock_gettime(CLOCK_REALTIME, &timePause);
	clock_gettime(CLOCK_REALTIME, &timeStart);
	int done=0;
	while (!done) {
		while (XPending(dpy)) {
			XEvent e;
			XNextEvent(dpy, &e);
			check_resize(&e);
			check_mouse(&e);
			done = check_keys(&e);
		}
		clock_gettime(CLOCK_REALTIME, &timeCurrent);
		timeSpan = timeDiff(&timeStart, &timeCurrent);
		timeCopy(&timeStart, &timeCurrent);
		physicsCountdown += timeSpan;
		while (physicsCountdown >= physicsRate) {
			physics(&game);
			physicsCountdown -= physicsRate;
		}
		render(&game);
		glXSwapBuffers(dpy, win);
	}
	cleanupXWindows();
	cleanup_fonts();
	logClose();
	return 0;
}
示例#4
0
int main(void)
{
	logOpen();
	initXWindows();
	init_opengl();
	init();
	init_sounds();
	clock_gettime(CLOCK_REALTIME, &timePause);
	clock_gettime(CLOCK_REALTIME, &timeStart);
	while(!done) {
		while(XPending(dpy)) {
			XEvent e;
			XNextEvent(dpy, &e);
			check_resize(&e);
			check_mouse(&e);
			check_keys(&e);
		}
		//
		//Below is a process to apply physics at a consistent rate.
		//1. Get the time right now.
		clock_gettime(CLOCK_REALTIME, &timeCurrent);
		//2. How long since we were here last?
		timeSpan = timeDiff(&timeStart, &timeCurrent);
		//3. Save the current time as our new starting time.
		timeCopy(&timeStart, &timeCurrent);
		//4. Add time-span to our countdown amount.
		physicsCountdown += timeSpan;
		//5. Has countdown gone beyond our physics rate? 
		//       if yes,
		//           In a loop...
		//              Apply physics
		//              Reducing countdown by physics-rate.
		//              Break when countdown < physics-rate.
		//       if no,
		//           Apply no physics this frame.
		while(physicsCountdown >= physicsRate) {
			//6. Apply physics
			physics();
			//7. Reduce the countdown by our physics-rate
			physicsCountdown -= physicsRate;
		}
		//Always render every frame.
		render();
		glXSwapBuffers(dpy, win);
	}
	cleanupXWindows();
	cleanup_fonts();
	#ifdef USE_SOUND
	fmod_cleanup();
	#endif //USE_SOUND
	logClose();
	return 0;
}
示例#5
0
文件: hw1.cpp 项目: rfrapwell/hw1
int main(void)
{
        int done=0;
        srand(time(NULL));
        initXWindows();
        init_opengl();
        //declare game object
        Game game;
        game.n=0;
	
	clock_gettime(CLOCK_REALTIME, &timePause);
	clock_gettime(CLOCK_REALTIME, &timeStart);

        //declare a box shape
	for(int i = 0; i<5; i++)
	{
        	game.box[i].width = 100;
        	game.box[i].height = 15;
       		
		game.box[i].center.x = 120 + (60*i);
       		game.box[i].center.y = 500 - (100*i);
	}

	game.circle.radius = .5;
        game.circle.center.x = 60 + 9*65;
        game.circle.center.y = 450- 8*60;


        //start animation
        while(!done) {
                while(XPending(dpy)) {
                        XEvent e;
                        XNextEvent(dpy, &e);
                        check_mouse(&e, &game);
                        done = check_keys(&e, &game);
		}

		clock_gettime(CLOCK_REALTIME, &timeCurrent);
		timeSpan = timeDiff(&timeStart, &timeCurrent);
		timeCopy(&timeStart, &timeCurrent);
		physicsCountdown += timeSpan;
		
		while(physicsCountdown >= physicsRate) {
			physics(&game);
			physicsCountdown -= physicsRate;
		}
                movement(&game);
                render(&game);
                glXSwapBuffers(dpy, win);
        }
        cleanupXWindows();
        return 0;
}
示例#6
0
文件: lab1.cpp 项目: Akhan123/Lab-1
int main(void)
{
	int done=0;
	srand(time(NULL));
	initXWindows();
	init_opengl();
	//declare game object
	Game game;
	game.n=0;
	game.bubble = 0;

	//declare a box shape
	game.box[0].width = 100;
	game.box[0].height = 15;
	game.box[0].center.x = 150;
	game.box[0].center.y = 500;
	game.box[1].width = 100;
	game.box[1].height = 15;
	game.box[1].center.x = 250;
	game.box[1].center.y = 425;
	game.box[2].width = 100;
	game.box[2].height = 15;
	game.box[2].center.x = 350;
	game.box[2].center.y = 350;
	game.box[3].width = 100;
	game.box[3].height = 15;
	game.box[3].center.x = 450;
	game.box[3].center.y = 275;
	game.box[4].width = 100;
	game.box[4].height = 15;
	game.box[4].center.x = 550;
	game.box[4].center.y = 200;
	game.circle.center.x = 700;
	game.circle.center.y = 50;
	game.circle.radius = 125;
	

	//start animation
	while(!done) {
		while(XPending(dpy)) {
			XEvent e;
			XNextEvent(dpy, &e);
			check_mouse(&e, &game);
			done = check_keys(&e, &game);
		}
		movement(&game);
		render(&game);
		glXSwapBuffers(dpy, win);
	}
	cleanupXWindows();
	return 0;
}
示例#7
0
int main(void)
{
	int done=0;
	srand(time(NULL));
	initXWindows();
	init_opengl();
	//declare game object
	Game game;
	game.n=0;

	//declare a box shape
	game.box[0].width = 100;
	game.box[0].height = 10;
	game.box[0].center.x = 270 + 5*65;
	game.box[0].center.y = 500 - 5*60;
    game.box[1].width = 100;
    game.box[1].height = 10;
    game.box[1].center.x = 270 + 5*65 - 75;
    game.box[1].center.y = 500 - 5*60 + 45;
    game.box[2].width = 100;
    game.box[2].height = 10;
    game.box[2].center.x = 270 + 5*65 - 150;
    game.box[2].center.y = 500 - 5*60 + 90;
    game.box[3].width = 100;
    game.box[3].height = 10;
    game.box[3].center.x = 270 + 5*65 - 225;
    game.box[3].center.y = 500 - 5*60 + 135;
    game.box[4].width = 100;
    game.box[4].height = 10;
    game.box[4].center.x = 270 + 5*65 - 300;
    game.box[4].center.y = 500 - 5*60 + 180;
	game.circle.center.x = 760;
	game.circle.center.y = -25;
	game.circle.radius = 100;

	//start animation
	while(!done) {
		while(XPending(dpy)) {
			XEvent e;
			XNextEvent(dpy, &e);
			check_mouse(&e, &game);
			done = check_keys(&e, &game);
		}
		movement(&game);
		render(&game);
		glXSwapBuffers(dpy, win);
	}
	cleanupXWindows();
	cleanup_fonts();
	return 0;
}
示例#8
0
int main(void)
{
    int done=0;
    srand(time(NULL));
    initXWindows();
    init_opengl();
    init_sounds();

    clock_gettime(CLOCK_REALTIME, &timePause);
    clock_gettime(CLOCK_REALTIME, &timeStart);
    //declare game object
    Game game;

    fmod_playsound(1);
    //start animation
    while(!done) {
	while(XPending(dpy)) {
	    XEvent e;
	    XNextEvent(dpy, &e);
	    check_resize(&e);
	    check_mouse(&e, &game);
	    done = check_keys(&e, &game);
	}
	clock_gettime(CLOCK_REALTIME, &timeCurrent);
	timeSpan = timeDiff(&timeStart, &timeCurrent);
	timeCopy(&timeStart, &timeCurrent);
	movementCountdown += timeSpan;
	while(movementCountdown >= movementRate)
	{
	    movement(&game);
	    movementCountdown -= movementRate;
	}
	render(&game);
	glXSwapBuffers(dpy, win);
    }
    cleanupXWindows();
    cleanup_fonts();
#ifdef USE_SOUND
    fmod_cleanup();
#endif //USE_SOUND
    return 0;
}
示例#9
0
int main(void)
{
    int done=0;
    srand(time(NULL));
    initXWindows();
    init_opengl();


    //declare game object
    Game game;
    game.n=0;

    // used to check if jumped, already in the air
    game.space = false; // deny jumping til collision on floor


    //declare a box shape
    game.box.width = BOX_WIDTH;
    game.box.height = BOX_HEIGHT;
    game.box.center.x = 20;//120 + 5*65;
    game.box.center.y = 10;//500 - 5*60;
    game.box.velocity.y = 0;
    game.box.velocity.x = 0;
    //start animation
    while(!done) {
        while(XPending(dpy)) {
            XEvent e;
            XNextEvent(dpy, &e);
            check_mouse(&e, &game);
            check_resize(&e);
            done = check_keys(&e, &game);
        }

        movement(&game);
        render(&game);
        glXSwapBuffers(dpy, win);
    }


    cleanupXWindows();
    return 0;
}
示例#10
0
文件: hw1.cpp 项目: mhernandez94/hw1
int main(void)
{
	int done=0;
	srand(time(NULL));
	initXWindows();
	init_opengl();
	//declare game object
	Game game;
	game.n=0;

	//set bubbler to false
	game.bubbler = false;

	// circle coordinates
	game.circle.radius = RADIUS;
	game.circle.center.x = 460.0;
	game.circle.center.y = 1.0;

	//declare boxes
	for(int x = 0; x < 5; ++x)
	{
		game.box[x].width = BOX_WIDTH;
		game.box[x].height = BOX_HEIGHT;
		game.box[x].center.x = 100 + 50*x;
		game.box[x].center.y = 600 - 5*60 - 50*x;
	}

	//start animation
	while(!done) {
		while(XPending(dpy)) {
			XEvent e;
			XNextEvent(dpy, &e);
			check_mouse(&e, &game);
			done = check_keys(&e, &game);
		}
		movement(&game);
		render(&game);
		glXSwapBuffers(dpy, win);
	}
	cleanupXWindows();
	return 0;
}
示例#11
0
int main(void)
{
    logOpen();
    initXWindows();
    init_opengl();
    init();
    //buttonsInit();------------------------------------------------------------------
    init_sounds();
    clock_gettime(CLOCK_REALTIME, &timePause);
    clock_gettime(CLOCK_REALTIME, &timeStart);
    while(!done) {
        while(XPending(dpy)) {
            XEvent e;
            XNextEvent(dpy, &e);
            check_resize(&e);
            check_mouse(&e);
            GOcheck_mouse(&e);
            check_keys(&e);

        }
        clock_gettime(CLOCK_REALTIME, &timeCurrent);
        timeSpan = timeDiff(&timeStart, &timeCurrent);
        timeCopy(&timeStart, &timeCurrent);
        physicsCountdown += timeSpan;
        while(physicsCountdown >= physicsRate) {
            physics();
            physicsCountdown -= physicsRate;
        }
        render();
        glXSwapBuffers(dpy, win);
    }
    cleanupXWindows();
    cleanup_fonts();
#ifdef USE_SOUND
    fmod_cleanup();
#endif //USE_SOUND
    logClose();
    return 0;
}
示例#12
0
int main(void)
{
    int done=0;
    srand(time(NULL));
    initXWindows();
    Game game;
    DefineRagdoll(&game);
    init_opengl(&game);
    create_sounds();
    play();
    //declare game object
    init_keys();
    clock_gettime(CLOCK_REALTIME, &timePause);
    clock_gettime(CLOCK_REALTIME, &timeStart);

    //start animation
    while(!done) {
	while(XPending(dpy)) {
	    XEvent e;
	    XNextEvent(dpy, &e);
	    check_mouse(&e, &game);
	    check_resize(&game, &e);
	    done = check_keys(&e);
	}
	clock_gettime(CLOCK_REALTIME, &timeCurrent);
	timeSpan = timeDiff(&timeStart, &timeCurrent);
	timeCopy(&timeStart, &timeCurrent);
	physicsCountdown += timeSpan;
	while(physicsCountdown >= physicsRate) {
	    movement(&game);
	    physicsCountdown -= physicsRate;
	}
	render(&game);
	glXSwapBuffers(dpy, win);
    }
    cleanupXWindows();
    cleanup_fonts();
    return 0;
}
示例#13
0
文件: hw1.cpp 项目: bmurraybruce/hw1
int main(void)
{
    int done=0;
    srand(time(NULL));
    initXWindows();
    init_opengl();
    //declare game object
    Game game;
    game.n=0;

    //declare a box shape

    for (int i = 0; i < 5; i++) {
	game.box[i].width = 70 + i*5;
	game.box[i].height = 10;
	game.box[i].center.x = 120 + (i*80);
	game.box[i].center.y = 500 - (i*70);
    }

    game.circle.center.x = 700;
    game.circle.center.y = 0;
    game.circle.radius = 200;

    //start animation
    while(!done) {
	while(XPending(dpy)) {
	    XEvent e;
	    XNextEvent(dpy, &e);
	    //check_mouse(&e, &game);
	    done = check_keys(&e, &game);
	}
	makeParticle(&game,35,550);
	movement(&game);
	render(&game);
	glXSwapBuffers(dpy, win);
    }
    cleanupXWindows();
    return 0;
}
示例#14
0
int main(void)
{
	initXWindows();
    srand(time(NULL));
    clock_gettime(CLOCK_REALTIME, &timePause);
    clock_gettime(CLOCK_REALTIME, &timeStart);
    init_opengl();
    init_ship();
	//Do this to allow fonts
	glEnable(GL_TEXTURE_2D);
	initialize_fonts();
	init_textures();
	while(!done) {
		while(XPending(dpy)) {
			XEvent e;
			XNextEvent(dpy, &e);
			check_resize(&e);
			check_mouse(&e);
			check_keys(&e);
		}
        clock_gettime(CLOCK_REALTIME, &timeCurrent);
        timeSpan = timeDiff(&timeStart, &timeCurrent);
        timeCopy(&timeStart, &timeCurrent);
        physicsCountdown += timeSpan;
        while (physicsCountdown >= physicsRate) {
            physics();
            physicsCountdown -= physicsRate;
            render();
        }
		//physics();
		//render();
		glXSwapBuffers(dpy, win);
	}
	cleanupXWindows();
	cleanup_fonts();
	return 0;
}
示例#15
0
文件: hw1.cpp 项目: dirizarryher/hw1
int main(void)
{
    int done=0;
    srand(time(NULL));
    initXWindows(); 
    init_opengl();
    //declare game object
    Game game;
    game.n=0;
    game.bubbler = false;

    for (int i = 0; i < 5; i++) {
        game.box[i].width = 100;
        game.box[i].height = 15;
        game.box[i].center.x = 130 + (i*85);
        game.box[i].center.y = 475 - (i*75);
    }
    game.circle.radius = 140.0;
    game.circle.center.x = 400 + (5*65);
    game.circle.center.y = 300 - (5*60);

    //this big loop is called "the controller"
    //start animation "event loop"
    while(!done) {
        while(XPending(dpy)) {
            XEvent e;
            XNextEvent(dpy, &e);
            check_mouse(&e, &game);
            done = check_keys(&e, &game);
        }
        movement(&game);//checks if anything moves
        render(&game);//renders images to the screen
        glXSwapBuffers(dpy, win);//swaps buffers
    }
    cleanupXWindows();
    return 0;
}
示例#16
0
文件: hw1.cpp 项目: jcadena3/hw1
int main(int argc, char **argv)
{
	//Initialize GLUT
	glutInit(&argc, argv);

	int done=0;
	srand(time(NULL));
	initXWindows();
	init_opengl();

	//declare game object
	Game game;
	game.n=MAX_PARTICLES;

	//declare a box shape
	game.box.width = 100;
	game.box.height = 10;
	game.box.radius = 100;
	game.box.center.x = 120 + 5*65;
	game.box.center.y = 500 - 5*60;

	//start animation
	while (!done) {
		while (XPending(dpy)) {
			XEvent e;
			XNextEvent(dpy, &e);
			check_mouse(&e, &game);
			done = check_keys(&e, &game);
		}
		movement(&game);
		render(&game);
		glXSwapBuffers(dpy, win);
	}
	cleanupXWindows();
	return 0;
}
示例#17
0
int main(void)
{
    int done=0;
    srand(time(NULL));
    initXWindows();
    init_opengl();
    //declare game object
    Game game;
    game.n=0;

    //declare a box shape

    //First
    game.box[0].width = 100;
    game.box[0].height = 11;
    game.box[0].center.x = 65;
    game.box[0].center.y = 456;
    //Second
    game.box[1].width = 100;
    game.box[1].height = 11;
    game.box[1].center.x = 175;
    game.box[1].center.y = 385;
    //Third
    game.box[2].width = 100;
    game.box[2].height = 11;
    game.box[2].center.x = 285;
    game.box[2].center.y = 305;
    //Fourth
    game.box[3].width = 100;
    game.box[3].height = 11;
    game.box[3].center.x = 385;
    game.box[3].center.y = 215;
    //Fifth
    game.box[4].width = 100;
    game.box[4].height = 11;
    game.box[4].center.x = 485;
    game.box[4].center.y = 155;
    //Source  (Sixth)
    game.box[5].width = 75;
    game.box[5].height = 15;
    game.box[5].center.x = 0;
    game.box[5].center.y = 600;
    //Source 2 (Seventh)
    game.box[6].width = 70;
    game.box[6].height = 60;
    game.box[6].center.x = 5;
    game.box[6].center.y = 515;
    //LS-Glasses (Eighth)
    game.box[7].width = 40;
    game.box[7].height = 20;
    game.box[7].center.x = 650;
    game.box[7].center.y = 554;
    //Mid-Glasses (Ninth)
    game.box[8].width = 50;
    game.box[8].height = 8;
    game.box[8].center.x = 740;
    game.box[8].center.y = 554;
    //RS-Glasses (Tenth)
    game.box[9].width = 40;
    game.box[9].height = 20;
    game.box[9].center.x = 755;
    game.box[9].center.y = 554;
    //LS-Glasses Edge (Eleventh)
    game.box[10].width = 18;
    game.box[10].height = 8;
    game.box[10].center.x = 593;
    game.box[10].center.y = 565;
    //RS-Glasses Edge (Twelfth)
    game.box[11].width = 18;
    game.box[11].height = 8;
    game.box[11].center.x = 760;
    game.box[11].center.y = 565;






    game.circle.center.x = 720;
    game.circle.center.y = 546;
    game.circle.radius = 142;

    //SET WATER AT (1,580)

    //game.circle[1].center.x = ;
    //game.circle[1].center.y = ;
    //game.corcle[1].radius = 90;


    //start animation
    while(!done) {
        while(XPending(dpy)) {
            XEvent e;
            XNextEvent(dpy, &e);
            check_mouse(&e, &game);
            done = check_keys(&e, &game);

        }
        movement(&game);
        render(&game);
        glXSwapBuffers(dpy, win);
    }
    cleanupXWindows();
    cleanup_fonts();
    return 0;
}
示例#18
0
int main(int argc, char *argv[])
{
	if(argc > 1) {
		if(argv[1] != NULL) {
			beginTesting();
		}
		return 0;
	}

	logOpen();
	initXWindows();
	init_opengl();
	Game game;
	init(&game);
	srand(time(NULL));
	clock_gettime(CLOCK_REALTIME, &timePause);
	clock_gettime(CLOCK_REALTIME, &timeStart);	

	hud = new Hud(xres ,yres);
	if (TEST_Hud){
		hud->testHUDAll();
		return 0;
	}
	//DEFUALT IS LEVEL 1 SELECTED:
	selected_screen = LEFT;    
	level =1;
	//--------------
	is_gameover = false;
	high_score = 0;
	gameStarted = false;
	lastPaddleHit = 'N';//'N' means no paddle hit

	bombBegin = time(NULL);
	bombRandom = random(7);

	beginSmallLeftPaddle = time(NULL);
	smallLeftPaddleTime = 7;
	beginSmallRightPaddle = time(NULL);
	smallRightPaddleTime = 7;
	hud->setAI(false);//DEFAULT: player2 is human	
	ball_saved_X_velocity = 8.0f * cos(30);
	ball_saved_Y_velocity = 8.0f * sin(90);    
	obstacle_saved_Y_velocity = -5.0;

	int min;
	if (xres<yres){
		min=xres;
	}
	else{
		min=yres;
	}
	bomb_radius = ((int)(3*min)/10);

	//MAIN MENU LOOP 
	while(intro != 0) {
		while (XPending(dpy)) {
			XEvent e;
			XNextEvent(dpy, &e);
			check_resize(&e);
			intro = check_keys(&e, &game);
		}
		render(&game);
		glXSwapBuffers(dpy, win);
	}


	//BEGIN MAIN GAME LOOP
	int done=0;
	while (!done) {        
		while (XPending(dpy)) {
			XEvent e;
			XNextEvent(dpy, &e);
			check_resize(&e);
			done = check_keys(&e, &game);
		}
		clock_gettime(CLOCK_REALTIME, &timeCurrent);
		timeSpan = timeDiff(&timeStart, &timeCurrent);
		timeCopy(&timeStart, &timeCurrent);
		physicsCountdown += timeSpan;
		while (physicsCountdown >= physicsRate) {
			physics(&game);
			physicsCountdown -= physicsRate;
		}        
		render(&game);
		glXSwapBuffers(dpy, win);
	}
	cleanupXWindows();
	cleanup_fonts();
	logClose();

	return 0;
}
int main(void)
{
    int done=0;
    srand(time(NULL));
    initXWindows();
    init_opengl();
    //declare game object
    Game game;

    game.numberDefenseMissiles=0;
    
    //JG
    game.nparticles=MAX_PARTICLES;
    game.numberDefenseMissiles=0;

    // JBC 5/19/16
    // added globally accesible defMissileSpeed so that we can 
    // change it dynamically
    game.defMissileSpeed = 10;

    initStruc(&game);
    //Structures sh;

    //Changed call for function prototype 5-17-16 -DT
    createEMissiles(&game, 0, 0);
    initRadar(&game);
    initUFO(&game);
    initHighScores(&game);
    //JR - Menu Object Shapes and Locations
    drawMenu(&game);
    drawSettings(&game);
    game.sounds.loadAudio();
    //start animation
    while (!done) {
        int state = gameState(&game);
        while (XPending(dpy)) {
            XEvent e;
            XNextEvent(dpy, &e);
            check_mouse(&e, &game);
            done = check_keys(&e, &game);
        }
        if (state == 1) {
            render_menu(&game);
        } else if (state == 2) {        	
    		drawSettings(&game);
            render_settings(&game);
        } else if (state == 3) {
            render_newgame(&game);
        } else if (state == 0 || state == 5) {
            if (lvlState(&game) < 0) {
                movement(&game);
                render(&game);
            } 
            if (lvlState(&game) == 1) {
                levelEnd(&game);
            }
        } else {
            render_gameover(&game);
        }
        glXSwapBuffers(dpy, win);
    }
    cleanupXWindows();
    return 0;
}
示例#20
0
文件: hw1.cpp 项目: kboberg/hw1
int main(void)
{
    int done=0;
    srand(time(NULL));
    initXWindows();
    init_opengl();
    //declare game object
    Game game;
    game.n=0;
//for (int i=0; i<10; i++) {
    //declare a box shape
    game.box[0].width = 100;
    game.box[0].height = 10;
    game.box[0].center.x = 120 + 5*65;
    game.box[0].center.y = 500 - 5*60;
    //i++;
    game.box[1].width = 100;
    game.box[1].height = 10;
    game.box[1].center.x = 120 + 5*65 + 50;
    game.box[1].center.y = 500 - 5*60 - 30;
//}

    game.box[0].width = 100;
    game.box[0].height = 10;
    game.box[0].center.x = 120 + 5*65;
    game.box[0].center.y = 500 - 5*60;
    game.box[1].width = 100;
    game.box[1].height = 10;
    game.box[1].center.x = 120 + 5*65 + 50;
    game.box[1].center.y = 500 - 5*60 - 30;
    //game.circle.center.x = 600;

    game.box[0].width = 100;
    game.box[0].height = 10;
    game.box[0].center.x = 120 + 5*65;
    game.box[0].center.y = 500 - 5*60;
    game.box[3].width = 100;
    game.box[3].height = 10;
    game.box[3].center.x = 120 + 5*65 + 50;
    game.box[3].center.y = 500 - 5*60 - 30;

    game.box[0].width = 100;
    game.box[0].height = 10;
    game.box[0].center.x = 120 + 5*65;
    game.box[0].center.y = 500 - 5*60;
    game.box[4].width = 100;
    game.box[4].height = 10;
    game.box[4].center.x = 120 + 5*65 + 50;
    game.box[4].center.y = 500 - 5*60 - 30;
 //   game.circle.center.x = 600;
  //  game.circle.center.x = 600;
    game.circle.center.x = 600;
    game.circle.center.y = 50;
    game.circle.radius = 100;

    //start animation
    while(!done) {
        while(XPending(dpy)) {
            XEvent e;
            XNextEvent(dpy, &e);
            check_mouse(&e, &game);
            done = check_keys(&e, &game);
        }
        movement(&game);
        render(&game);
        glXSwapBuffers(dpy, win);
    }
    cleanupXWindows();
    return 0;
}
示例#21
0
int main(void)
{
    int done=0;
    srand(time(NULL));
    initXWindows();
    init_opengl();
    // game objected declaration
    Game game;
    game.n=0;

    int xOrigin = 100;
    int yOrigin = 250;
    int width = 80;
    int height = 10;

    // box shape declaration
    game.box[0].width = width;
    game.box[0].height = height;
    game.box[0].center.x = xOrigin;
    game.box[0].center.y = yOrigin;

    game.box[1].width = width;
    game.box[1].height = height;
    game.box[1].center.x = xOrigin + 50;
    game.box[1].center.y = yOrigin - 30;

    game.box[2].width = width;
    game.box[2].height = height;
    game.box[2].center.x = xOrigin + 100;
    game.box[2].center.y = yOrigin - 60;

    game.box[3].width = width;
    game.box[3].height = height;
    game.box[3].center.x = xOrigin + 150;
    game.box[3].center.y = yOrigin - 90;

    game.box[4].width = width;
    game.box[4].height = height;
    game.box[4].center.x = xOrigin + 200;
    game.box[4].center.y = yOrigin - 120;

    game.circle.center.x = 400;
    game.circle.center.y = -20;
    game.circle.radius = 100;



    //starting animation
    while(!done) {
        while(XPending(dpy)) {
            XEvent e;
            XNextEvent(dpy, &e);
            check_mouse(&e, &game);
            done = check_keys(&e, &game);
        }
        movement(&game);
        render(&game);
        glXSwapBuffers(dpy, win);
    }
    cleanupXWindows();
    return 0;
}
示例#22
0
文件: lab1.cpp 项目: kharryman/CS335
int main(void)
{
    bool b_done=false;
    bool done=false;
    srand(time(NULL));
    initXWindows();
    init_opengl();
    //declare game object
    Game game;
    game.n=0;

    //declare a box shape
    game.box[0].width = BOX_WIDTH;
    game.box[0].height = BOX_HEIGHT;
    game.box[0].center.x = WINDOW_WIDTH/7;
    game.box[0].center.y = WINDOW_HEIGHT - WINDOW_HEIGHT/7;

    game.box[1].width = BOX_WIDTH;
    game.box[1].height = BOX_HEIGHT;
    game.box[1].center.x = 2*WINDOW_WIDTH/7;
    game.box[1].center.y = WINDOW_HEIGHT - 2*(WINDOW_HEIGHT/7);

    game.box[2].width = BOX_WIDTH;
    game.box[2].height = BOX_HEIGHT;
    game.box[2].center.x = 3*WINDOW_WIDTH/7;
    game.box[2].center.y = WINDOW_HEIGHT - 3*(WINDOW_HEIGHT/7);

    game.box[3].width = BOX_WIDTH;
    game.box[3].height = BOX_HEIGHT;
    game.box[3].center.x = 4*WINDOW_WIDTH/7;
    game.box[3].center.y = WINDOW_HEIGHT - 4*(WINDOW_HEIGHT/7);

    game.box[4].width = BOX_WIDTH;
    game.box[4].height = BOX_HEIGHT;
    game.box[4].center.x = 5*WINDOW_WIDTH/7;
    game.box[4].center.y = WINDOW_HEIGHT - 5*(WINDOW_HEIGHT/7);

    game.circle.radius = CIRCLE_RADIUS;
    game.circle.center.x = WINDOW_WIDTH;
    game.circle.center.y = -80;

    while(XPending(dpy)) {
       XEvent e;
       XNextEvent(dpy, &e);
       b_done = check_b(&e);
          if (b_done){
              break;
          }
    }
    //start animation
    while(!done) {
        while(XPending(dpy)) {
           XEvent e;
           XNextEvent(dpy, &e);
           done = check_escape(&e);
        }
        doMakeParticles(&game);
        movement(&game);
        render(&game);
        glXSwapBuffers(dpy, win);    
    }
    cleanupXWindows();
    return 0;
}