Beispiel #1
0
/*
  time_handler

  basic timestep, updates and draws the world

  parameters: gui_world pointer
 */
static gboolean
time_handler(gpointer data) {

    gui_world *world = (gui_world *) data;
    //cpSpaceStep(world -> space, 1.0/50);

    if (!world->stop) {
        world_update(world -> physics);
        //graphics_space_iterate(world -> graphics);
        gtk_widget_queue_draw(world -> graphics -> window);

        if (world->delete_text) {
            delete_text(world);
        }

        if (world->physics->status == 1) {

            if (world->graphics->message != NULL) {
                free (world->graphics->message);
            }
            world->graphics->message = (char *)malloc(20 * sizeof(char));
            strcpy(world->graphics->message, "You Win!");
            world->level = world->level % 10 + 1;
            new_game (world);
            //gtk_main_quit();
        }

    }
    return 1;
}
Beispiel #2
0
/* Game logic */
int scene_logic_game(Uint32 delta)
{
  stage_process(delta);
  world_update(delta); /* <--------------------- */
  game_player_process(delta);
  game_item_process(delta);
  game_bullet_process(delta);
  game_enemy_process(delta);
  return 1;
}
Beispiel #3
0
int run(struct Game* game)
{
    while(game->running)
    {
        //get input from the player
        get_input(game);

        // update the player
        // update the world
        world_update(game->world);

        // Draw the shit to the screen
        draw_shit(game);

        // update the ncurses window
        refresh();
    }

    endwin();
    return 0;
}
Beispiel #4
0
/*
 * SDL_main
 */
int SDL_main(int argc, char* argv[])
{
	SDL_Event		event;
	SDL_Surface		*screen, *icon;

	putenv(strdup("SDL_VIDEO_CENTERED=1"));

    if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0)
	{
        printf("Unable to initialize SDL: %s\n", SDL_GetError());
        return EXIT_FAILURE;
    }

    icon = SDL_LoadBMP("gui/icon.bmp");
    SDL_WM_SetIcon(icon, NULL);

	SDL_WM_SetCaption("Convex Hull Testing", "Convex Hull Testing");
	SDL_ShowCursor(SDL_DISABLE);
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, etrue);

	//Initialize window
    // | SDL_FULLSCREEN
    screen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, 32, SDL_OPENGL | SDL_NOFRAME);
    if(!screen)
	{
		printf("Unable to set video mode: %s\n", SDL_GetError());
		return EXIT_FAILURE;
	}

    SDL_WarpMouse(512.0, 384.0);

    //gameState = STATE_MAINMENU;

    timer_init();
    renderer_init();
    world_init();
    //model_init();

	//Main loop
	while(!user_exit)
	{
		//Handle input
		while(SDL_PollEvent(&event))
		{
			switch(event.type)
			{
			case SDL_KEYDOWN:
				input_keyDown(event.key.keysym.sym);
				break;
			case SDL_KEYUP:
				input_keyUp(event.key.keysym.sym);
				break;
			case SDL_MOUSEMOTION:
				input_mouseMove(event.motion.x, event.motion.y);
				break;
			case SDL_QUIT:
				user_exit = etrue;
			}
		}

		timer_update();

		while(timer.accumulated >= TIMESTEP)
		{
			input_update();
			world_update();

			timer.accumulated -= TIMESTEP;
		}

		world_lerpPositions(timer.accumulated);
		renderer_drawFrame();
	}

    SDL_Quit();

    return EXIT_SUCCESS;
}
Beispiel #5
0
void update() {
	player_selfupdate(my_player, my_world, my_server);
	player_update(my_player, my_world);
	world_update(my_world, my_server);
	server_handle_updates(my_server, my_player, my_world);
}
Beispiel #6
0
int main(int argc, char *argv[])
{
    float tick;

    /* Server defaults */
    server.port = DEFAULT_PORT;
    server.fps = DEFAULT_FPS;
    server.max_clients = DEFAULT_MAXCLIENTS;
    server.clients = 0;
    server.exit_when_empty = 0;
    strncpy(server.name, "Chickens With Attitude", 32);

    /* Game defaults */
    game.changelevel = 0;
    game.fraglimit = 0;
    game.timelimit = 0;
    game.mode = HOLYWAR;
    game.objective = GAME_EXIT_LEVEL;
    strncpy(game.map_name, "unfinished_sympathy.map", NETMSG_STRLEN);

    /* Command line arguments */
    if( argc > 1 )
	handle_cl_args(argc, argv);

    calc_lookup_tables(DEGREES);
    entity_init();
    weapon_init();

    /* Initilaise networking. TRY to use server.port, but return the actual
       port we manage to get */
    if( (server.port = sv_net_init(server.port)) >= 0 )
	printf("Waiting for connections on port %d\n", server.port);
    else {
	printf("Unable to initialise network. Exiting.\n");
	return EXIT_FAILURE;
    }

    if( sv_map_changelevel(game.map_name, game.mode) < 0 ) {
	printf("Error, unable to load map\n");
	return EXIT_FAILURE;
    }

    tick = 1.0 / server.fps;
    server.quit = 0;

    /* Server main loop */
    while( !server.quit ) {
	/*
	  printf("Press to continue.....\n");
	  fflush(NULL);
	  getchar();
	*/

	server.now = gettime();
	sv_net_get_client_input();
	world_update( tick );
	game_update();
	sv_net_send_start_frames(); /* Begin each clients frames */
	sv_net_update_clients();
	cap_fps(server.fps);
    }

    return EXIT_SUCCESS;

}