void update_movement(GameState * state) { register int i; if (((state->wave.spawn_counter % 10 == 0 && !state->wave.completed) || (state->wave.cool_down_counter % 10 == 0 && state->wave.cool_down_counter != 0)) && state->mana != MANA_MAX) { if (state->mana + MANA_UPDATE < MANA_MAX) { state->mana += MANA_UPDATE; } else { state->mana += MANA_MAX - state->mana; } } //als frost wave actief is is er geen movement if (!state->spells.frost_wave_active) { //pad moet herberekend worden if (state->refresh_paths) { for (i = 0; i < state->enemies_length; i++) { if (state->enemies[i].enemy.alive) { refresh_path(&state->enemies[i].enemy.path, &state->world); } } state->refresh_paths = 0; } move_enemies(state); } move_projectiles(state); }
int main(int argc, char *argv[]) { char *buff; int ch; int i; initscr(); cbreak(); noecho(); nonl(); curs_set(0); // nodelay(stdscr, TRUE); intrflush(stdscr, FALSE); keypad(stdscr, TRUE); if((color = has_colors())) { start_color(); init_pair(1, COLOR_WHITE, COLOR_BLUE); init_pair(2, COLOR_CYAN, COLOR_BLUE); } signal(SIGINT, cleanup); init_windows(); init_bass(); create_playlist(&playlist_h, &playlist_t); if(argc>1) { if(strncmp("/", argv[1], 1) != 0) { error("argument must be an absolute path", FALSE); } if(dirname(opendir(argv[1]))) { // is a dir if(add(&playlist_h, argv[1], &playlist_t)) { p_p++; c_p_p++; nsongs++; active_win = PLAYLIST_WIN; bass_loop = BASS_MUSIC_LOOP; play(argv[1], PLAYING_PLAYLIST); } current_path = strdup((char*)dirname(argv[1])); } else { error("argument not valid", FALSE); } } else { current_path = (char*)malloc(sizeof(char)*PATH_MAX); current_path = (char*)getcwd(current_path, PATH_MAX); } entries = refresh_browser(current_path, 0); mvprintw(0, 0, "%s", current_path); repaint_windows(); while((ch = getch()) != 'q') { switch(ch) { case 'a': // add song to playlist if(active_win == BROWSER_WIN) { if(!is_dir(current_path, entries[p_b])) { buff = mystrcat(current_path,entries[p_b],1); if(add(&playlist_h, buff, &playlist_t)) { if(p_p == -1) p_p++; nsongs++; repaint_windows(); } free(buff); } } break; case 'e': // add all songs in current dir if(active_win == BROWSER_WIN) { for(i=0; i<nfiles; i++) { if(!is_dir(current_path, entries[i])) { buff = mystrcat(current_path,entries[i],1); if(add(&playlist_h, buff, &playlist_t)) { if(p_p == -1) p_p++; nsongs++; } free(buff); } } } repaint_windows(); break; case 'c': // recursive add if(active_win == BROWSER_WIN) { //printw("---%s+++", current_path); add_recursive(current_path, entries, nfiles); repaint_windows(); //printw("---%s", current_path); } break; case 'd': // remove one song from playlist if(active_win == PLAYLIST_WIN) { if(del(&playlist_h, p_p, &playlist_t)) { nsongs--; if(p_p > nsongs - 1) { p_p = nsongs - 1; } if(p_p < c_p_p) { c_p_p--; } //stop(); repaint_windows(); } } break; case 'r': // remove all songs from playlist if(del_all(&playlist_h, &playlist_t)) { p_p = -1; c_p_p = -1; nsongs = 0; repaint_windows(); } break; case ' ': // start playback or browse filesystem case 13: //enter key if(active_win == BROWSER_WIN) { if(strcmp(entries[p_b], "..\0") == 0) { current_path = dirname(current_path); p_b = 0; entries = refresh_browser(current_path, 0); } else { if(is_dir(current_path, entries[p_b])) { current_path = dir_up(current_path, entries[p_b]); p_b = 0; entries = refresh_browser(current_path, 0); } else { buff = mystrcat(current_path,entries[p_b],1); play(buff, PLAYING_BROWSER); free(buff); c_p_p = -1; if(p_b < nfiles-1) { p_b++; } } } refresh_path(); } else { // PLAYLIST_WIN if(nsongs != 0) { play(get(&playlist_h, p_p, &playlist_t)->file, PLAYING_PLAYLIST); c_p_p = p_p; if(p_p < nsongs - 1) { p_p++; } } } repaint_windows(); break; case 's': // stop playback stop(); c_p_p = -1; repaint_windows(); clear_statusbar(NULL); break; case 'n': // next song next(); break; case 'p': // prev song prev(); break; case 'g': // go to current song p_p = c_p_p; repaint_windows(); break; case 'l': // toggle loop loop(); stop(); c_p_p = -1; repaint_windows(); break; case 'z': // toggle random random_mode(); break; case '.': // seek forward seek(1); break; case ',': // seek backward seek(-1); break; case '+': volume_up(); break; case '-': volume_down(); break; case '>': amplify_up(); break; case '<': amplify_down(); break; case KEY_UP: if(active_win == BROWSER_WIN) { if(p_b > 0) { p_b--; } } else { if(p_p > 0) { p_p--; } } repaint_windows(); break; case KEY_DOWN: if(active_win == BROWSER_WIN) { if(p_b < nfiles-1) { p_b++; } } else { if(p_p < nsongs - 1) { p_p++; } } repaint_windows(); break; case KEY_LEFT: case KEY_RIGHT: switch_activewindow(); repaint_windows(); break; case KEY_HOME: if(active_win == BROWSER_WIN) { p_b = 0; } else { if(p_p != -1) p_p = 0; } repaint_windows(); break; case KEY_END: if(active_win == BROWSER_WIN) { p_b = nfiles-1; } else { if(p_p != -1) p_p = nsongs - 1; } repaint_windows(); break; case KEY_NPAGE: if(active_win == BROWSER_WIN) { if((p_b + (browser_win->_maxy - 2)) < nfiles-1 ) { p_b += browser_win->_maxy - 1; } else { p_b = nfiles-1; } } else { if((p_p + (playlist_win->_maxy - 2)) < nsongs) { p_p += playlist_win->_maxy - 1; } else { p_p = nsongs - 1; } } repaint_windows(); break; case KEY_PPAGE: if(active_win == BROWSER_WIN) { if((p_b - (browser_win->_maxy - 2)) > 0) { p_b -= browser_win->_maxy - 1; } else { p_b = 0; } } else { if((p_p - (playlist_win->_maxy - 2)) > 0) { p_p -= playlist_win->_maxy - 1; } else { if(p_p != -1) p_p = 0; } } repaint_windows(); break; } //usleep(10); //update_status(); } cleanup(); return 0; }