void start_vaccum(t_map *game) { int cycle; bool info; t_biscuit *nodedab; t_biscuit *noderobby; cycle = 0; nodedab = game->bisc; noderobby = game->bisc; info = false; while (info != true) { if (system("clear") < 0) exit(EXIT_FAILURE); clear_map(game->map); add_dab_robby(game); aff_map(game); usleep(80000); cycle++; if (gere_dab(game, nodedab) == 1) if (nodedab->life == true) nodedab = nodedab->next; if (gere_robby(game, noderobby, &info) == 1) noderobby = noderobby->next; } printf("Nombre de cycle = %d\n", cycle); }
void *display(void *arg) { pthread_t gere_key; t_window *window; t_philo *philo; philo = (t_philo *)arg; window = init_window(); if (pthread_create(&gere_key, NULL, my_pause, arg) != 0) return (NULL); aff_map(window, philo); return (0); }
void snakeclass::Play() { while (1) { if (collision()) { printw("Game over"); break ; } movesnake(); aff_map(); if (direction == 'q') break ; usleep(del); } }
int parse_struct2(t_struct *st) { char *file; st->width = 1300; st->height = 750; st->map_sel = 1; if (init_my_sdl(st) == -1 || (file = have_file(st)) == NULL) return (-1); st->map = my_getnbr(file); free(file); if (st->map <= 0 || st->map > 5) return (puterror("Error: The number of level-map is changed.\n")); aff_map(st); return (0); }
void getmap(char *fichier) { int fd; int taille; char *str; extern char **map; struct stat s; fd = open(fichier, O_RDONLY); fstat(fd, &s); str = malloc(sizeof(*str) * s.st_size); taille = read(fd, str, s.st_size); str[taille - 1] = '\0'; map = malloc(sizeof(*map) * get_height(str)); map = str_to_wordtab(str); close(fd); aff_map(map); }
void move(int key, t_map *imap, t_graph *graph) { void (*fp[4])(int, int, t_map*, t_graph *); key -= 273; fp[0] = move_up; fp[1] = move_down; fp[3] = move_left; fp[2] = move_right; if (key < 4 && key >= 0) fp[key](imap->j.x, imap->j.y, imap, graph); if (imap->map[imap->j.x][imap->j.y] == EKEY) { imap->map[imap->j.x][imap->j.y] = EBLANK; apply_fond(graph); aff_map(imap, graph); } }
void aff_text(t_data *data, t_bunny_picture *text) { int i; t_bunny_position pos; pos.x = data->player.x - 100; pos.y = data->player.y - 350; i = 0; while (i < 250) { aff_map(data); player_stop(data); (data->inv.open == 1 ? aff_inventory(data) : (void)0); bunny_blit(&data->win->buffer, text, &pos); bunny_display(data->win); my_sleep(200); i++; } }
int aff_all(Map *map) { SDL_Event event; Case *tab = get_tab(map->map); dijkstra(tab, map->pacman.pos.x/IMG, map->pacman.pos.y/IMG, map->enemy.pos.x/IMG, map->enemy.pos.y/IMG, map->map); while (1) { SDL_PollEvent(&event); if (Update(map, event)) return (1); player_Update(map); aff_map(map); aff_number(map, tab); aff_path(map, tab); aff_player(map); aff_ghost(map); SDL_Flip(map->ecran); } return (0); }
void launch_turtle_end(t_data *data) { int nbr; nbr = 0; data->cupa_end = 1; while (data->inv.turtle_pos.x != 1024) { data->inv.turtle_pos.x++; (data->map.pos_calq1.y > (322 - 272) ? data->map.pos_calq1.y-- : 0); (data->map.pos_calq2.y < (655 - 272) ? data->map.pos_calq2.y++ : 0); if (nbr == 0) { player_stop(data); aff_map(data); (data->inv.open == 1 ? aff_inventory(data) : (void)0); bunny_blit(wb, data->inv.item_min[0].item, &data->inv.turtle_pos); bunny_blit(wb, data->map.calq1, &data->map.pos_calq1); bunny_blit(wb, data->map.calq2, &data->map.pos_calq2); bunny_display(data->win); } (nbr == 2 ? nbr = 0 : nbr++); } }
int main(int argc, char **argv) { int key; t_map *g_map; t_game *snake; srand(time(NULL)); if (argc < 3) return (-1); snake = malloc(sizeof(t_game)); g_map = malloc(sizeof(t_map)); g_map->x_max = ft_atoi(argv[2]); g_map->y_max = ft_atoi(argv[1]); if (g_map->x_max < 3 || g_map->y_max < 3) return (-1); g_map->x_map = rand_a_b(3, g_map->x_max + 1); g_map->y_map = rand_a_b(3, g_map->y_max + 1); // ft_putnbr(g_map->x_map); // ft_putchar('\n'); // ft_putnbr(g_map->y_map); // ft_putchar('\n'); snake->x_s = 1; snake->y_s = 1; // ft_putnbr(snake->x_s); // ft_putchar('\n'); // ft_putnbr(snake->y_s); // ft_putchar('\n'); snake->pv_s = 13; g_map->map = map_create(g_map->x_map, g_map->y_map); ft_putendl("placement du heros"); g_map->map[snake->x_s][snake->y_s] = 's'; ft_putendl("affichage"); //free_all(snake, g_map); while (1) { key = 2; key = getarrowkey(); aff_map(g_map); aff_pv(snake); ft_putstr("POSITION:"); ft_putnbr(snake->x_s); ft_putchar(' '); ft_putnbr(snake->y_s); ft_putchar('\n'); ft_putstr("MAP"); ft_putnbr(g_map->x_map); ft_putchar(' '); ft_putnbr(g_map->x_map); if (key == 1) { if (go_left(snake, g_map)) { add_room(g_map); g_map = g_map->next; } } else if (key == 2) { if (go_up(snake, g_map)) { add_room(g_map); g_map = g_map->next; } } else if (key == 3) { if (go_down(snake, g_map)) { add_room(g_map); g_map = g_map->next; } } else if (key == 4) { if (go_right(snake, g_map)) { add_room(g_map); g_map = g_map->next; } } else if (key == 5) { free_all(snake, g_map); return (0); } usleep(100000); system("CLEAR"); } return (0); }