//###################################################################################################################### void* monitorOPENGL(void* argv) //thread for display { class scenario * start = init_new_game(); //here all the game characteristics are initialised and assigned to the start_scenario object start_scenario = (*start); glutInit( & ( ( (struct thread_data *) argv) -> arg), ((struct thread_data *) argv) -> args); glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB); glutInitWindowSize(I_W_W,I_W_H); glutCreateWindow("Multiplayer Carom"); glutDisplayFunc(display); glutTimerFunc(TRIGGER,trigger,UNIT); glutReshapeFunc(reshape); glutKeyboardFunc(keyboard); glutMainLoop(); }
void table_add_player(table *t, player *p) { if (t->num_players == 3) { logging_critical("Can't add player %s to table %s because limit has been reached.", p->name, t->name); return; } *(t->players + t->num_players) = p; t->num_players++; send_str(p->socket, "Welcome to the table. Please wait for others to join.\n"); send_str(p->socket, "(you can talk to other users in the room whilst you wait)\n"); logging_debug("\nNow %i players on table %s. Waiting for %d more.\n", t->num_players, t->name, (3 - t->num_players) ); table_broadcast(t, "Player %s has joined %s.\n", p->name, t->name); if (t->num_players == 3) init_new_game(t); }
/** * TBD * * @param argc TBD * @param argv TBD * @return TBD */ int main( int argc, char *argv[] ) { // Initialize the GTK library gtk_init( &argc, &argv ); if ( !load_config( ) ) scan_fonts( ); create_layout( ); init_new_game( TRUE, TRUE ); gtk_main( ); return ( 0 ); } // main
int main(void) { unsigned char i; /* a counter */ init_new_game(); /* initialize dots ... */ while (true) /* do forever... the following */ { start_one_vectrex_round(); /* start vectrex round */ intensity(MAX_BRIGHTNESS); /* set intensity of vector beam... */ for (i=0; i < SHOTS; i++) /* and process all dots */ { do_shot(¤t_shots[i]); /* with this function ... */ } } }
//Dictates Where the game is at and which function is relevant for option choices //such as changing locations void gameloop(player_data &loaded){ if(loaded.TH.week == 0){ init_new_game(loaded); } bool endgame = false; while(endgame != true){ //Prints the Current Game Character Data print_game_screen(loaded); cout << "OPTIONS" << endl; if(loaded.location == 0){ gl_ingame_menu(loaded); }else if(loaded.location == 1){ gl_map(loaded); }else if(loaded.location == 2){ gl_outside(loaded); }else if(loaded.location == 3){ gl_inside(loaded); }else if(loaded.location == 4){ gl_dorm(loaded); }else if(loaded.location == 5){ gl_pda(loaded); }else{ cout << "BAD INPUT " << endl; } } }
/** * If we come here, then the user has selected a row in the list. * * @param clist TBD * @param row TBD * @param column TBD * @param event TBD * @param data TBD */ static void hist_list_selected( GtkWidget *clist, gint row, gint column, GdkEventButton *event, gpointer data ) { gchar *text; unsigned char player, enemy; GList *list; int cnt; int x, y; PCELL ptr1, ptr2, p; CELL possib[256]; int nb_poss, nb_took; int k; int valid_move; int pass; /* * Get the text that is stored in the selected row and column * which was * clicked in. We will receive it as a pointer in the * argument text. */ gtk_clist_get_text( GTK_CLIST( clist ), row, column, &text ); /*--- Reset the game ---*/ init_new_game( FALSE, FALSE ); /*--- Bring the game to this point ---*/ player = CODE_BLACK; enemy = CODE_WHITE; list = GTK_CLIST( hist_list )->selection; for ( cnt = 0; cnt <= row; cnt++ ) { /*--- Get the position ---*/ gtk_clist_get_text( GTK_CLIST( hist_list ), cnt, 0, &text ); y = text[11] - '@'; x = text[12] - '0'; /*--- Generate all the possible move ---*/ ptr1 = ptr2 = &possib[0]; if ( ( nb_poss = do_build_possib( &ptr2, player, enemy ) ) == 0 ) { player = ( CODE_BLACK + CODE_WHITE ) - player; enemy = ( CODE_BLACK + CODE_WHITE ) - enemy; ptr1 = ptr2 = &possib[0]; if ( ( nb_poss = do_build_possib( &ptr2, player, enemy ) ) == 0 ) return; } // if /*--- Is-it a valid move ? ---*/ for ( valid_move = FALSE, p = ptr1, p++; p != ptr2; ) { if ( *p++ == &board[XY( x, y )] ) { valid_move = TRUE; break; } nb_took = ( int ) *p++; p += nb_took; } // for (p) if ( !valid_move ) return; /*--- Play this new move ---*/ board[XY( x, y )] = player; nb_took = ( int ) *p++; for ( k = 0; k < nb_took; k++ ) *( unsigned char * ) *p++ = player; /*--- Next player ---*/ player = ( CODE_BLACK + CODE_WHITE ) - player; enemy = ( CODE_BLACK + CODE_WHITE ) - enemy; } // for (cnt) /*--- Refresh the display ---*/ redraw_board( ); compute_nb_pawns( TRUE ); /*--- Which player next, if any ? ---*/ pass = FALSE; ptr1 = ptr2 = &possib[0]; if ( ( nb_poss = do_build_possib( &ptr2, player, enemy ) ) == 0 ) { ptr2 = &possib[0]; if ( ( nb_poss = do_build_possib( &ptr2, enemy, player ) ) == 0 ) return; pass = TRUE; if ( player == code_human ) player_infos_msg( "Sorry, no possibility left, you pass next turn!" ); else computer_infos_msg( "No possibility left, computer pass next turn!" ); player = ( CODE_BLACK + CODE_WHITE ) - player; } // if /*--- Next player ---*/ if ( player == code_computer ) { nb_poss = show_poss_play_cursor( code_computer, code_human ); computer_infos_msg( "%d possibilit%s. Press <SPACE> to play Computer", nb_poss, ( nb_poss == 1 ) ? "y" : "ies" ); install_key_press_handler( TRUE ); if ( !pass ) player_infos_msg( " " ); } else { nb_poss = show_poss_play_cursor( code_human, code_computer ); player_infos_msg( "%d possibilit%s. Choose a position and click to play", nb_poss, ( nb_poss == 1 ) ? "y" : "ies" ); install_key_press_handler( FALSE ); if ( !pass ) computer_infos_msg( " " ); } color_to_play = player; return; } // hist_list_selected