static bool flow (struct anim *k) { struct coord nc; struct pos np, pm, ptf; if (k->oaction != kid_jump) k->i = -1, k->misstep = k->hang = false; bool hang_front = ((k->f.dir == LEFT) ? k->key.left : k->key.right) && ! k->key.up && k->key.shift; bool hang_back = ((k->f.dir == LEFT) ? k->key.right : k->key.left) && ! k->key.up && k->key.shift; int back_dir = (k->f.dir == LEFT) ? RIGHT : LEFT; /* hang front */ survey (_m, pos, &k->f, &nc, &pm, &np); survey (_tf, pos, &k->f, &nc, &ptf, &np); if (k->i >= 8 && k->i <= 10 && hang_front && (is_hangable_pos (&pm, k->f.dir) || is_hangable_pos (&ptf, k->f.dir))) { if (is_hangable_pos (&pm, k->f.dir)) k->hang_pos = pm; else if (is_hangable_pos (&ptf, k->f.dir)) k->hang_pos = ptf; pos2room (&k->hang_pos, k->f.c.room, &k->hang_pos); k->hang = true; play_sample (hang_on_fall_sample, k->f.c.room); kid_hang (k); return false; } /* hang back */ survey (_tf, pos, &k->f, &nc, &ptf, &np); if (k->i >= 8 && k->i <= 10 && hang_back && is_hangable_pos (&ptf, back_dir)) { k->hang_pos = ptf; pos2room (&k->hang_pos, k->f.c.room, &k->hang_pos); k->hang = true; play_sample (hang_on_fall_sample, k->f.c.room); kid_turn (k); return false; } if (k->i == 17) { kid_normal (k); return false; } select_frame (k, kid_jump_frameset, k->i + 1); if (k->f.b == kid_stabilize_frameset[0].frame) k->fo.dx = +2; if (k->f.b == kid_stabilize_frameset[1].frame) k->fo.dx = +6; if (k->f.b == kid_stabilize_frameset[2].frame) k->fo.dx = +4; if (k->f.b == kid_stabilize_frameset[3].frame) k->fo.dx = +0; return true; }
static bool flow (struct anim *k) { if (k->oaction != kid_stabilize) { k->i = -1, k->misstep = false; if (k->oaction == kid_stabilize_collision) { k->i = 0; k->collision = true; } else k->collision = false; if (k->oaction == kid_turn) k->collision = true; } if (! k->turn) k->turn = ((k->f.dir == RIGHT) && k->key.left) || ((k->f.dir == LEFT) && k->key.right); bool run = (((k->f.dir == RIGHT) && k->key.right) || ((k->f.dir == LEFT) && k->key.left)) && ! k->key.shift; bool jump = ((k->f.dir == RIGHT) && k->key.right && k->key.up) || ((k->f.dir == LEFT) && k->key.left && k->key.up); bool couch = k->key.down; int dc = dist_collision (&k->f, false, &k->ci); int df = dist_fall (&k->f, false); if (k->i >= 0 && ! k->collision) { if (couch) { kid_couch (k); return false; } else if (jump) { kid_jump (k); return false; } else if (k->turn) { kid_turn (k); k->turn = false; return false; } else if (run && dc > PLACE_WIDTH && df > PLACE_WIDTH) { kid_start_run (k); return false; } } if (k->i == 3) { kid_normal (k); k->turn = false; return false; } select_frame (k, kid_stabilize_frameset, k->i + 1); if (k->f.b == kid_stop_run_frameset[3].frame) k->fo.dx = -5; return true; }
static bool flow (struct anim *k) { if (k->oaction != kid_misstep) k->i = -1, k->misstep = true; if (k->i == 10) { place_frame (&k->f, &k->f, kid_normal_00, &k->p, (k->f.dir == LEFT) ? +11 : PLACE_WIDTH + 7, 15); kid_normal (k); return false; } select_frame (k, kid_misstep_frameset, k->i + 1); return true; }
static bool flow (struct anim *k) { if (k->oaction != kid_keep_sword) k->i = -1, k->wait = 1; if (k->i < 8) k->i++; else if (k->i == 8 && k->wait > 0) k->wait--; else if (k->i == 8 && k->wait == 0) k->i++, k->wait = 2; else if (k->i == 9 && k->wait > 0) k->wait--; else { if (k->keep_sword_fast) { kid_normal (k); k->keep_sword_fast = false; return false; } else { /* kid turn will invert kid's direction */ k->f.dir = (k->f.dir == RIGHT) ? LEFT : RIGHT; kid_turn (k); return false; } } if (k->keep_sword_fast && k->i % 2 == 0) k->i++, k->wait = 0; k->j = 24 + k->i; select_frame (k, kid_keep_sword_frameset, k->i); if (k->i < 4) select_xframe (&k->xf, sword_frameset, k->j); if (k->i == 8 && k->wait < 1) k->fo.dx = 0; if (k->i == 9 && k->wait < 2) k->fo.dx = 0; if (k->keep_sword_fast && k->i % 2) k->fo.dx += kid_keep_sword_frameset[k->i - 1].dx; if (k->f.b == kid_sword_normal_00) k->fo.dx = +8; return true; }
static bool flow (struct anim *k) { struct pos p; if (k->oaction != kid_drink) k->i = -1, k->wait = 4, k->reverse = false; if (k->i < 14 && ! k->reverse) k->i++; else if (k->wait > 0) k->wait--; else if (k->i == 14 && k->wait == 0) k->reverse = true, k->i = 10; else if (k->i == 10 && k->reverse) k->i = 7; else { kid_normal (k); invalid_pos (&k->item_pos); return false; } if (k->i == 14 && k->wait == 1) switch (k->item) { case EMPTY_POTION: break; case SMALL_LIFE_POTION: increase_kid_current_lives (k); break; case BIG_LIFE_POTION: increase_kid_total_lives (k); break; case SMALL_POISON_POTION: if (k->immortal || k->poison_immune) break; k->current_lives--; k->splash = true; if (k->current_lives == 0) k->death_reason = POTION_DEATH; play_sample (harm_sample, NULL, k->id); if (k->id == current_kid_id) { mr.flicker = 2; mr.color = get_flicker_blood_color (); } break; case BIG_POISON_POTION: if (k->immortal || k->poison_immune) break; k->current_lives = 0; k->splash = true; k->death_reason = POTION_DEATH; play_sample (harm_sample, NULL, k->id); if (k->id == current_kid_id) { mr.flicker = 2; mr.color = get_flicker_blood_color (); } break; case FLOAT_POTION: float_kid (k); break; case FLIP_POTION: if (screen_flags) screen_flags = 0; else { switch (prandom_pos (&k->item_pos, 2)) { case 0: screen_flags ^= ALLEGRO_FLIP_VERTICAL; break; case 1: screen_flags ^= ALLEGRO_FLIP_HORIZONTAL; break; case 2: screen_flags ^= ALLEGRO_FLIP_VERTICAL | ALLEGRO_FLIP_HORIZONTAL; break; } } break; case ACTIVATION_POTION: p.room = 8, p.floor = p.place = 0; activate_con (&p); break; default: break; } select_frame (k, kid_drink_frameset, k->i); if (k->i == 14 && k->wait < 4) k->fo.dx = 0; if (k->i == 10 && k->reverse) k->fo.dx = -2, k->fo.dy = +1; if (k->i == 7 && k->reverse) k->fo.dx = +1; return true; }
static bool flow (struct anim *k) { struct coord nc; struct pos np, ptf, pbf; enum confg ctf; if (k->oaction != kid_couch) { k->i = -1; k->fall = k->collision = k->misstep = false; k->wait = 0; } if (k->uncouch_slowly) { k->wait = 36; k->uncouch_slowly = false; } if (k->oaction == kid_climb) k->i = 10; if (k->oaction == kid_couch_collision) k->collision = true, k->inertia = k->cinertia = 0; if (k->oaction == kid_fall) { k->fall = true; k->inertia = k->cinertia = 0; } /* if (k->i > 2 && k->hit_by_loose_floor) */ /* k->i = -1; */ /* unclimb */ int dir = (k->f.dir == LEFT) ? +1 : -1; ctf = survey (_tf, pos, &k->f, &nc, &ptf, &np)->fg; survey (_bf, pos, &k->f, &nc, &pbf, &np); struct pos ph; prel (&pbf, &ph, +1, dir); if (k->i == -1 && ! k->collision && ! k->fall && ! k->hit_by_loose_floor && k->item_pos.room == -1 && is_hangable_pos (&ph, k->f.dir) && dist_next_place (&k->f, _tf, pos, 0, true) <= 27 && ! (ctf == DOOR && k->f.dir == LEFT && door_at_pos (&ptf)->i > DOOR_CLIMB_LIMIT)) { pos2room (&ph, k->f.c.room, &k->hang_pos); kid_unclimb (k); return false; } if (k->i == 12) { k->hit_by_loose_floor = false; kid_normal (k); return false; } if (k->i == 2 && k->item_pos.room != -1 && ! k->collision && ! k->fall) { if (is_potion (&k->item_pos)) kid_drink (k); else if (is_sword (&k->item_pos)) kid_raise_sword (k); else { k->item_pos.room = -1; goto no_item; } return false; } no_item: if (k->i == 2 && k->key.down && k->cinertia == 0 && k->wait-- <= 0 && ((k->f.dir == LEFT && k->key.left) || (k->f.dir == RIGHT && k->key.right))) { k->i = 0; select_frame (k, kid_couch_frameset, 0); return true; } if (k->i != 2 || (! k->key.down && k->wait-- <= 0)) k->i++; if (k->i == 1 && k->wait > 0 && ((k->fall == true && k->hurt) || k->hit_by_loose_floor)) k->i = 2; select_frame (k, kid_couch_frameset, k->i); if (k->oaction == kid_climb) k->fo.dx += 7; if (k->i > 0 && k->i < 3) k->fo.dx -= k->cinertia; if (k->cinertia > 0) k->cinertia--; return true; }