/** @brief Main in-game rendering routine. * * @param b Board configuration to render. */ void draw_scene(board_t *b, GLuint fb, int reflections) { char temp[80]; int clock_seconds = 0; int clock_minutes = 0; glBindFramebuffer(GL_FRAMEBUFFER, fb); transition_update(); gg_dialog_cleanup(); glDisable(GL_BLEND); glDepthFunc(GL_ALWAYS); draw_backdrop(); glEnable(GL_BLEND); glDepthFunc(GL_LEQUAL); go_3d(get_screen_width(), get_screen_height()); render_scene_3d(b, fb, reflections); mouse_square = find_square(get_true_mouse_x(), get_true_mouse_y()); glBindFramebuffer(GL_FRAMEBUFFER, fb); resize_window(get_screen_width(), get_screen_height()); glPushMatrix(); draw_ui_elements(); // draw_move_list(get_col(COL_WHITE), get_col(COL_YELLOW)); // draw_capture_list(get_col(COL_WHITE)); clock_minutes = (((SDL_GetTicks() - get_turn_counter()) / 1000) / 60); clock_seconds = ((SDL_GetTicks() - get_turn_counter()) / 1000) - (clock_minutes * 60); snprintf(temp, sizeof(temp), "%i:%02i", clock_minutes, clock_seconds); /*text_draw_string( 303, 440, temp, 1, &col_black);*/ glPopMatrix(); /*if ( get_white_in_check() == TRUE ) text_draw_string_bouncy( 180, 420, "White is in check!", 1, get_col(COL_WHITE)); else if ( get_black_in_check() == TRUE ) text_draw_string_bouncy( 180, 420, "Black is in check!", 1, get_col(COL_WHITE));*/ gg_dialog_render_all(); if (get_fading_out()) { if (!draw_fade(FADE_OUT)) set_switch_to_menu(TRUE); } else { if (get_show_egg()) draw_sonic_fade(FADE_IN); else draw_fade(FADE_IN); } /* Draw mouse cursor.. */ draw_texture(get_mouse_cursor(), get_mouse_x(), (479 - get_mouse_y() - 32), 32, 32, 1.0f, get_col(COL_WHITE)); }
void algo(char **map, int nb_lines, int nb_cols) { struct s_bsq *bsq; int square; bsq = init_s_bsq(map, nb_cols, nb_lines); while (bsq->y < bsq->nb_lines) { bsq->x = 0; while (bsq->x < bsq->nb_cols) { square = 0; while (find_square(bsq, square)) square++; if (square > bsq->nb_squares) { bsq->nb_squares = square; bsq->square_pos.x = bsq->x; bsq->square_pos.y = bsq->y; } bsq->x++; } bsq->y++; } fill_biggest_square(bsq); }
void c_fermat_fact(int n, int* f1, int* f2) { /* Exit with factors of 0 is negative or 0 number to be factored */ if (n <= 0) { *f1 = 0; *f2 = 0; return; } /* Number is even; simple /2 calculation */ if (n % 2 == 0) { *f1 = 2; *f2 = n/2; return; } /* n is now guaranteed to be positive and odd Begin Fermat factorization algorithm */ int x = ceil(sqrt(n)); int y = 0; int y2 = x * x - n; while (find_square(y2, &y) == 0) { x = x + 1; y2 = x * x - n; /* If overflow, break */ if (y2 < 0) { break; } } *f1 = x + y; *f2 = x - y; /* Overflow = likely prime #. Thus, factors = 1 and itself. Not necessarily true, will still fail if one of the factors are too large to find (ex: 8388607 = 178481 * 47) but better than a guaranteed wrong answer. Sacrifices speed for correctness; at least 1 and itself are always factors :) */ if (y2 < 0) { *f1 = n; *f2 = 1; } }
int main(int argc, char **argv) { t_map *s_map; t_square *s_square; if (argc == 2) { if ((s_map = read_map(argv[1]))) { if (!(s_square = find_square(s_map))) return (-1); print_map(s_map, s_square); } else return (-1); free(s_map->map); free(s_map); free(s_square); } else my_putstr("usage: ./bsq map\n"); return (0); }
int modeSelect(int *testMode, int *hlineMode, int *vlineMode, int *squareMode, FILE *soubor, int *radky, int *sloupce) //funkce ktera vybere prislusny mod. { int x1 = -1; int y1 = -1; int x2 = -1; int y2 = -1; if(*testMode == 1) { Bitmap b; alokujMatici2D(&b, radky, sloupce); testMatice(soubor, &b); dealokujMatici2D(&b); } else if(*hlineMode == 1) { Bitmap b; alokujMatici2D(&b, radky, sloupce); if ( nactiMaticiZeSouboru(soubor, &b) == 1) { return 3; } if (find_hline(&b, &x1, &y1, &x2, &y2) == 1) { printf("%d %d %d %d\n", x1, y1, x2, y2); } else { fprintf(stderr, "Nenalezeno nic."); } dealokujMatici2D(&b); } else if(*vlineMode == 1) { Bitmap b; alokujMatici2D(&b, radky, sloupce); if ( nactiMaticiZeSouboru(soubor, &b) == 1) { return 3; } if (find_vline(&b, &x1, &y1, &x2, &y2) == 1) { printf("%d %d %d %d\n", x1, y1, x2, y2); } else { fprintf(stderr, "Nenalezeno nic.\n"); } dealokujMatici2D(&b); } else if(*squareMode == 1) { Bitmap b; alokujMatici2D(&b, radky, sloupce); if ( nactiMaticiZeSouboru(soubor, &b) == 1) { return 3; } if (find_square(&b, &x1, &y1, &x2, &y2) == 1) { printf("%d %d %d %d\n", x1, y1, x2, y2); } else { fprintf(stderr, "Nenalezeno nic.\n"); } dealokujMatici2D(&b); } else { fprintf(stderr,"Spatne zadane parametry, zadejte parametr --help pro napovedu\n"); } return 0; }