void get_in_range (struct anim *k0, struct anim *k1, int r, bool only_k1, bool k1_dominant) { struct anim *kd, *ks, *kl, *kr; kd = k1_dominant ? k1 : k0; ks = k1_dominant ? k0 : k1; kl = (kd->f.dir == LEFT) ? kd : ks; kr = (kd->f.dir == RIGHT) ? kd : ks; int i = 0; while (! is_in_range (k0, k1, r) && i <= (only_k1 ? 2 : 1) * r) { bool cl = kl == k0 && only_k1; bool cr = kr == k0 && only_k1; if (cl && cr) break; if (i++ % 2 && ! cl) { kl->fo.dx = -1; uncollide_front_fight (kl); next_frame (&kl->f, &kl->f, &kl->fo); kl->fo.dx = 0; } else if (! cr) { kr->fo.dx = -1; uncollide_front_fight (kr); next_frame (&kr->f, &kr->f, &kr->fo); } } }
static gboolean wp_button_press_cb (GtkWidget *widget, GdkEventButton *event, AppearanceData *data) { GtkCellRenderer *cell; GdkEventButton *button_event = (GdkEventButton *) event; if (event->type != GDK_BUTTON_PRESS) return FALSE; if (gtk_icon_view_get_item_at_pos (GTK_ICON_VIEW (widget), button_event->x, button_event->y, NULL, &cell)) { if (g_object_get_data (G_OBJECT (cell), "buttons")) { gint w, h; GtkCellRenderer *cell2 = NULL; gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h); if (gtk_icon_view_get_item_at_pos (GTK_ICON_VIEW (widget), button_event->x + w, button_event->y, NULL, &cell2) && cell == cell2) next_frame (data, cell, -1); else next_frame (data, cell, 1); return TRUE; } } return FALSE; }
inline struct Frame lf_snapshot_file::get_frame(std::size_t frame_nb) { if (frame_locations.empty() || frame_nb > frame_locations.size()-1) { struct Frame frame; do { frame = next_frame(); } while (frame_nb > frame_locations.size()-1 && !frame.meta_data.empty()); return frame; } else { f.seekg(frame_locations[frame_nb]); return next_frame(); } }
int BIKPlayer::doPlay() { int done = 0; //bink is always truecolor g_truecolor = 1; frame_wait = 0; timer_last_sec = 0; video_frameskip = 0; if (sound_init( core->GetAudioDrv()->CanPlay())) { //sound couldn't be initialized return 1; } //last parameter is to enable YUV overlay outputwidth = (int) header.width; outputheight= (int) header.height; video->InitMovieScreen(outputwidth,outputheight, true); if (video_init(outputwidth,outputheight)) { return 2; } while (!done && next_frame()) { done = video->PollMovieEvents(); } return 0; }
evidence_t reasoner::operator() ( rule* goal, int max_steps, cases_t& cases ) { trace("dict: "<<dict.tostr()<<endl); deque<frame*> queue; queue.emplace_back ( &frames[nframes++].init ( this, goal ) ); uint step = 0; evidence_t evidence; cout << "goal: " << *goal << endl << "cases:" << endl << cases << endl; while ( !queue.empty() && ++step ) { frame& current_frame = *queue.front(); queue.pop_front(); ground_t g = current_frame.ground; trace ( current_frame << endl ); if ( max_steps != -1 && ( int ) step >= max_steps ) return evidence_t(); if ( current_frame.ind >= current_frame.rul->body.size() ) { if ( !current_frame.parent ) evidence_found ( current_frame, evidence ); else queue.push_back ( next_frame ( current_frame, g ) ); } else { predicate* t = current_frame.rul->body[current_frame.ind]; int b = builtin ( t ); // ( t, c ); if ( b == 1 ) { g.emplace_back ( &rules[nrules++].init ( evaluate ( *t, current_frame.substitution ) ), subst() ); frame& r = frames[nframes++].init ( this, current_frame ); r.ground = g; r.ind++; queue.push_back ( &r ); } else if ( !b ) continue; // if ( frame* f = match_cases ( current_frame, *t, cases, queue ); // ) ) queue.push_front ( f ); } } return evidence; }
void mouse_normal (struct anim *m) { m->oaction = m->action; m->action = mouse_normal; m->f.flip = (m->f.dir == LEFT) ? 0 : ALLEGRO_FLIP_HORIZONTAL; if (m->oaction != mouse_normal) m->i = 0; if (m->i == 12) { m->f.dir = (m->f.dir == LEFT) ? RIGHT : LEFT; mouse_run (m); return; } m->fo.b = mouse_normal_00; m->fo.dx = m->fo.dy = +0; if (m->oaction == mouse_run) m->fo.dy = +2; next_frame (&m->f, &m->f, &m->fo); update_depressible_floor (m, -2, -5); m->i++; }
static bool physics_in (struct anim *k) { struct pos pbb, pmbo, pbf; struct frame nf; /* inertia */ if (k->i >= 8 && k->i <= 10) k->inertia = 5; else k->inertia = 0; /* collision */ if (is_colliding (&k->f, &k->fo, +0, false, &k->ci)) { if (k->i < 7 || k->i > 10) kid_stabilize_collision (k); else kid_couch_collision (k); return false; } /* fall */ next_frame (&k->f, &nf, &k->fo); survey (_bb, pos, &nf, NULL, &pbb, NULL); survey (_mbo, pos, &nf, NULL, &pmbo, NULL); survey (_bf, pos, &nf, NULL, &pbf, NULL); if ((is_strictly_traversable (&pbb) && is_strictly_traversable (&pmbo) && k->i < 7) || (k->i >= 10 && k->i < 13 && is_strictly_traversable (&pbf) && is_strictly_traversable (&pmbo)) || (k->i >= 13 && is_strictly_traversable (&pmbo))) { kid_fall (k); return false; } return true; }
void mouse_run (struct anim *m) { m->oaction = m->action; m->action = mouse_run; m->f.flip = (m->f.dir == LEFT) ? 0 : ALLEGRO_FLIP_HORIZONTAL; m->dc = dist_collision (&m->f, false, &m->ci) + 4; m->df = dist_fall (&m->f, false); m->dl = dist_con (&m->f, _bf, pos, -4, false, LOOSE_FLOOR); if (is_colliding (&m->f, &m->fo, m->dc, false, &m->ci) && m->ci.t == DOOR) m->dc = PLACE_WIDTH + 1; if (! cutscene && (m->dc < 12 || m->df < 12 || m->dl < 12)) { mouse_normal (m); return; } if (m->oaction != mouse_run) m->i = -1; if (m->i == 1) m->i = 0; else m->i++; select_frame (m, run_frameset, m->i); if (m->oaction == mouse_normal) m->fo.dy = -2; next_frame (&m->f, &m->f, &m->fo); if (m->i == 0) update_depressible_floor (m, -1, -9); else if (m->i == 1) update_depressible_floor (m, -2, -11); }
void integrate_psd() { /* Copy lines until Mot: line */ while (!gzeof(infile)) { next_line(line,MAX_LINE); if (output == ICP) fputs(line,outfile); if (strncmp(line," Mot:",5) == 0) break; } /* Copy column header line */ next_line(line,MAX_LINE); if (output == ICP) fputs(line,outfile); /* Process data */ next_line(line,MAX_LINE); if (!gzeof(infile)) { points++; if (output == ICP) fputs(line,outfile); while (!gzeof(infile)) { /* process really ugly 2-D repr */ next_frame(); accumulate_bins(); write_frame(); if (line[0] != '\0') { points++; if (output == ICP) fputs(line,outfile); } } } }
static void do_action(struct Player *pp, Action ac) { Action pre_action; pre_action = previous_action(pp); int pre_frame = pre_action.frame; int nframe; if (equal_action(pre_action, ac)) { nframe = next_frame(pp, ac, pre_frame); set_frame(pp, nframe); complete_action(pp); } else if (pre_frame != 0) // previous action unfinished { if (action_interruptable(pre_action)) { set_action(pp, ac); complete_action(pp); //pp->spd = spd; } else do_action(pp, pre_action); } else // previous action finished, set new action { set_action(pp, ac); complete_action(pp); } }
void jaffar_turn_walk (struct anim *jaffar) { jaffar->oaction = jaffar->action; jaffar->action = jaffar_turn_walk; if (jaffar->oaction != jaffar_turn_walk) { jaffar->f.dir = (jaffar->f.dir == RIGHT) ? LEFT : RIGHT; jaffar->i = -1; } jaffar->f.flip = (jaffar->f.dir == RIGHT) ? 0 : ALLEGRO_FLIP_HORIZONTAL; if (jaffar->i < 9) jaffar->i++; else { jaffar_walk (jaffar); return; } select_frame (jaffar, turn_walk_frameset, jaffar->i); next_frame_inv = true; next_frame (&jaffar->f, &jaffar->f, &jaffar->fo); next_frame_inv = false; }
void jaffar_walk (struct anim *jaffar) { jaffar->oaction = jaffar->action; jaffar->action = jaffar_walk; jaffar->f.flip = (jaffar->f.dir == RIGHT) ? ALLEGRO_FLIP_HORIZONTAL : 0; if (jaffar->oaction != jaffar_walk) jaffar->i = -1; if (jaffar->i < 5) jaffar->i++; else if (jaffar->repeat > 0) jaffar->i = 0, jaffar->repeat--; else if (jaffar->i < 7) jaffar->i++; else { jaffar_normal (jaffar); return; } select_frame (jaffar, walk_frameset, jaffar->i); if (jaffar->f.b == jaffar_normal_00) jaffar->fo.dx = -4; if (jaffar->f.b == turn_walk_frameset[9].frame) jaffar->fo.dx = +17, jaffar->fo.dy = -1, next_frame_inv = true; next_frame (&jaffar->f, &jaffar->f, &jaffar->fo); if (next_frame_inv) next_frame_inv = false; }
void animation::RepeatableAnimation::update() { if (is_frame_ended()) { next_frame(); if (not is_last_frame()) { _timer.restart(); } } }
/* * @brief preload/cache the anim frames * @note useful for preloading without having to load the apng into bmpman slots */ void apng_ani::preload() { _reading = false; _cache = true; // implied, otherwise preload is almost pointless while (current_frame < nframes) { next_frame(); } goto_start(); }
void put_at_attack_frame (struct anim *k) { k->enemy_defended_my_attack = 2; k->enemy_counter_attacked_myself = k->enemy_counter_attacked_myself ? 2 : 0; k->i_counter_defended = k->i_counter_defended ? 2 : 0; switch (k->type) { case NO_ANIM: default: break; case KID: if (k->i == 3) return; k->f = k->of; select_frame (k, kid_sword_attack_frameset, 0); next_frame (&k->f, &k->f, &k->fo); select_frame (k, kid_sword_attack_frameset, 1); next_frame (&k->f, &k->f, &k->fo); select_frame (k, kid_sword_attack_frameset, 2); k->fo.b = kid_sword_attack_defended; select_xframe (&k->xf, sword_frameset, 17); k->xf.dx = -21; k->xf.dy = +11; uncollide_back_fight (k); next_frame (&k->f, &k->f, &k->fo); break; case GUARD: case FAT_GUARD: case VIZIER: case SKELETON: case SHADOW: k->fo.b = get_guard_attack_defended_bitmap (k->type); k->fo.dx = +1; k->fo.dy = 0; select_xframe (&k->xf, sword_frameset, 8); k->xf.dx = -13; k->xf.dy = -14; uncollide_back_fight (k); next_frame (&k->f, &k->f, &k->fo); break; } }
void SeismicVideo::on_process() { tbb::task_scheduler_init Init(threadsHigh); do { if( initIsParallel ) u_.ParallelUpdateUniverse(); else u_.SerialUpdateUniverse(); if( numberOfFrames_ > 0 ) --numberOfFrames_; } while(next_frame() && numberOfFrames_); }
void put_at_defense_frame (struct anim *k) { struct frameset *frameset; play_audio (&sword_defense_audio, NULL, k->id); switch (k->type) { case NO_ANIM: default: break; case KID: select_frame (k, kid_sword_defense_frameset, 0); next_frame (&k->f, &k->f, &k->fo); select_frame (k, kid_sword_defense_frameset, 1); struct anim *ke = get_anim_by_id (k->enemy_id); if (ke->type == KID) { select_xframe (&k->xf, sword_frameset, 11); k->xf.dx = -13; k->xf.dy = +5; } else select_xframe (&k->xf, sword_frameset, 14); k->action = kid_sword_defense; uncollide_back_fight (k); next_frame (&k->f, &k->f, &k->fo); break; case GUARD: case FAT_GUARD: case VIZIER: case SKELETON: case SHADOW: frameset = get_guard_defense_frameset (k->type); select_frame (k, frameset, 0); select_xframe (&k->xf, sword_frameset, 11); k->action = guard_defense; uncollide_back_fight (k); next_frame (&k->f, &k->f, &k->fo); break; } /* if (k->id == 0) */ /* printf ("%s: k->i = %i, k->fo.dx = %i\n", */ /* __func__, k->i, k->fo.dx); */ }
void process_events() { int mx, my; mx = game->get_input()->mouse_position.x; my = game->get_input()->mouse_position.y; this->set_position(mx, my); if (this->collides(OBJ_COOKIEMONSTER)) { next_frame(); } }
void guard_normal (struct anim *g) { g->oaction = g->action; g->action = guard_normal; g->f.flip = (g->f.dir == RIGHT) ? ALLEGRO_FLIP_HORIZONTAL : 0; if (! flow (g)) return; if (! physics_in (g)) return; next_frame (&g->f, &g->f, &g->fo); physics_out (g); }
void kid_unclimb (struct anim *k) { k->oaction = k->action; k->action = kid_unclimb; k->f.flip = (k->f.dir == RIGHT) ? ALLEGRO_FLIP_HORIZONTAL : 0; if (! flow (k)) return; if (! physics_in (k)) return; next_frame (&k->f, &k->f, &k->fo); physics_out (k); }
void kid_stabilize (struct anim *k) { k->oaction = k->action; k->action = kid_stabilize; k->f.flip = (k->f.dir == RIGHT) ? ALLEGRO_FLIP_HORIZONTAL : 0; if (! flow (k)) return; if (! cutscene && ! physics_in (k)) return; next_frame (&k->f, &k->f, &k->fo); physics_out (k); }
static void do_ia64_backtrace(struct unw_frame_info *info, void *vdata) { ia64_backtrace_t *bt = vdata; struct switch_stack *sw; int count = 0; u_long pc, sp; sw = (struct switch_stack *)(info+1); /* padding from unw_init_running */ sw = (struct switch_stack *)(((unsigned long)sw + 15) & ~15); unw_init_frame_info(&bt->frame, current, sw); /* skip over interrupt frame and oprofile calls */ do { unw_get_sp(&bt->frame, &sp); if (sp >= (u_long)bt->regs) break; if (!next_frame(bt)) return; } while (count++ < 200); /* finally, grab the actual sample */ while (bt->depth-- && next_frame(bt)) { unw_get_ip(&bt->frame, &pc); oprofile_add_trace(pc); if (unw_is_intr_frame(&bt->frame)) { /* * Interrupt received on kernel stack; this can * happen when timer interrupt fires while processing * a softirq from the tail end of a hardware interrupt * which interrupted a system call. Don't laugh, it * happens! Splice the backtrace into two parts to * avoid spurious cycles in the gprof output. */ /* TODO: split rather than drop the 2nd half */ break; } } }
void CinematicWin(PLAYERNAME winner,PLAYERNAME looser) { char * Playernames[]= {"Mokhtar","Haitham","Brahim","Salah","Wassim"}; char buffer[500]; float w,h=102,x=-10,i=0; IMAGE *winImage,*loseImage; sprintf(buffer,"Resources/Images/%s/win.png",Playernames[winner]); winImage=load_image(buffer); sprintf(buffer,"Resources/Images/%s/lose.png",Playernames[looser]); loseImage=load_image(buffer); if(looser!=HAITHAM) { w=(100/((float)loseImage->h/(float)loseImage->w))/AspectRatio; x=50-w/2; } if(winner==HAITHAM) { h=120; } sprintf(buffer,"You must go on without me.\nBut you can't do it alone.\nYou must take my powers in \norder to continue your\njourney... See you in\nthe real world..."); while(!IsKeyPressed(3,ENTER) && !IsKeyPressed(3,RETURN) && i<(FPS*10)) { draw_image_ex(loseImage,x,0,0,100,NONE,i-FPS); draw_image_ex(winImage,0,0,0,h,NONE,i-(float)FPS*2); draw_text(SFTransRobotics,buffer,5,80,75,CENTER,i-(float)FPS*4); next_frame(); i++; } draw_image_ex(loseImage,x,0,0,100,NONE,i-FPS); draw_image_ex(winImage,0,0,0,h,NONE,i-(float)FPS*2); draw_text(SFTransRobotics,buffer,5,80,75,CENTER,i-(float)FPS*4); PrintScreen(1); for(i=100; i>=0; i-=0.8) { draw_image_ex(screenimage,0,0,100,100,NONE,i); next_frame(); } }
static void do_ia64_backtrace(struct unw_frame_info *info, void *vdata) { ia64_backtrace_t *bt = vdata; struct switch_stack *sw; int count = 0; u_long pc, sp; sw = (struct switch_stack *)(info+1); /* */ sw = (struct switch_stack *)(((unsigned long)sw + 15) & ~15); unw_init_frame_info(&bt->frame, current, sw); /* */ do { unw_get_sp(&bt->frame, &sp); if (sp >= (u_long)bt->regs) break; if (!next_frame(bt)) return; } while (count++ < 200); /* */ while (bt->depth-- && next_frame(bt)) { unw_get_ip(&bt->frame, &pc); oprofile_add_trace(pc); if (unw_is_intr_frame(&bt->frame)) { /* */ /* */ break; } } }
int ffmpegWrap::run_once(bool retry) { if (!ic_) { if (open_url() < 0) { return RC_FAILURE; } } int rc = next_frame(); if (rc < 0 && retry) { avformat_close_input(&ic_); ic_ = 0; if (open_url() < 0) { return RC_FAILURE; } return next_frame(); } else { return rc; } }
int extract_image(void* user_struct) { struct stream_state stream; struct blob_list blist; struct blob* blob_now = NULL; struct blob* blob_prev = NULL; if (init_pixel_stream(user_struct, &stream)) {printf("init malloc error!\n"); return 1;} if (stream.row == NULL) {printf("row malloc error!\n"); return 1;} blist.length = stream.w + 5; if (malloc_blobs(&blist)) {printf("blob malloc error!\n"); return 1;} while (!next_frame(user_struct, &stream)) { init_blobs(&blist); while (!next_row(user_struct, &stream)) { blob_prev = blist.head->next; while (!stream.wrap) { blob_now = empty_blob(&blist); if (scan_segment(&stream, blob_now)) {blob_reap(&blist, blob_now); continue;} blob_update(blob_now, blob_now->x1, blob_now->x2, stream.y); // update structure sib_find(blist.head->next, blob_now); blob_insert(blob_prev, blob_now); flush_incremental(user_struct, &blist, blob_now); blob_prev = blob_now; } flush_old_blobs(user_struct, &blist, stream.y); //show_status(blist.head, &stream); //show_dead_sibs(blist.head); //show_blobs(blist.head); //printf("----------\n"); } flush_old_blobs(user_struct, &blist, stream.h - 1); } close_pixel_stream(user_struct, &stream); free(blist.head); free(blist.empties); blist.head = NULL; blist.empties = NULL; return 0; }
void kid_stairs (struct anim *k) { k->oaction = k->action; k->action = kid_stairs; k->f.dir = RIGHT; k->f.flip = 0; if (! flow (k)) return; if (! physics_in (k)) return; next_frame_inv = true; next_frame (&k->f, &k->f, &k->fo); next_frame_inv = false; physics_out (k); }
void jaffar_normal (struct anim *jaffar) { jaffar->oaction = jaffar->action; jaffar->action = jaffar_normal; jaffar->f.flip = (jaffar->f.dir == RIGHT) ? ALLEGRO_FLIP_HORIZONTAL : 0; jaffar->fo.b = jaffar_normal_00; jaffar->fo.dx = jaffar->fo.dy = +0; if (jaffar->f.b == lower_arms_frameset[5].frame) jaffar->fo.dx = -2, jaffar->fo.dy = +0; next_frame (&jaffar->f, &jaffar->f, &jaffar->fo); }
void jaffar_raise_arms (struct anim *jaffar) { jaffar->oaction = jaffar->action; jaffar->action = jaffar_raise_arms; jaffar->f.flip = (jaffar->f.dir == RIGHT) ? ALLEGRO_FLIP_HORIZONTAL : 0; if (jaffar->oaction != jaffar_raise_arms) jaffar->i = -1; if (jaffar->i < 10) jaffar->i++; select_frame (jaffar, raise_arms_frameset, jaffar->i); next_frame (&jaffar->f, &jaffar->f, &jaffar->fo); }
int GameOver(int player) { //MOKHTAR,HAITHAM,BRAHIM,SALAH,WASSIM int FallIndexes[5]= {29,23,47,29,26},selection=0, button_pressed=0;; IMAGE **Pics; IMAGE*cadre=load_image("Resources/Images/ingame_bar.png"); switch(player) { case 0: Pics=MokhtarPics; break; case 1: Pics=HaithamPics; break; case 2: Pics=BrahimPics; break; case 3: Pics=SalahPics; break; case 4: Pics=WassimPics; break; } while(!IsKeyPressed(1,ENTER)) { button_pressed++; if((IsKeyPressed(1,LEFT) || IsKeyPressed(1,RIGHT)) && button_pressed>10) { selection=!selection; button_pressed=0; } draw_text(SharpCurve,"Game Over",20,50,5,CENTER_X,100); draw_text(Arista,"Continue?",8,50,30,CENTER_X,100); draw_text(Arista,"YES",8,25,50,CENTER_X,100); draw_text(Arista,"NO",8,75,50,CENTER_X,100); draw_image_ex(Pics[FallIndexes[player]],25,30,50,0,NONE,100); draw_image_ex(cadre,18+selection*50,40,15,30,NONE,100); next_frame(); } while(IsKeyPressed(1,ENTER)) rest(1); return !selection; }