예제 #1
0
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);
}
예제 #2
0
파일: fight.c 프로젝트: oitofelix/mininim
bool
is_safe_to_walkb (struct anim *k)
{
  int df = dist_fall (&k->f, true);
  int dc = dist_collision (&k->f, _bb, +0, +0, &k->ci);
  return df > PLACE_WIDTH && dc > 4;
}
예제 #3
0
static bool
flow (struct anim *k)
{
  if (k->oaction != kid_turn)
    k->i = -1, k->misstep = k->hang = false;

  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->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;

  if (k->i == 3) {
    int dc = dist_collision (&k->f, false, &k->ci);
    int df = dist_fall (&k->f, false);

    if (k->hang) kid_hang (k);
    else if (k->turn) {
      k->i = -1; k->turn = false;
      k->action = kid_normal;
      kid_turn (k);
    }
    else if (couch) kid_couch (k);
    else if (jump) kid_jump (k);
    else if (run && dc > PLACE_WIDTH && df > PLACE_WIDTH)
      kid_start_run (k);
    else kid_stabilize (k);

    return false;
  }

  if (k->f.b == kid_keep_sword_frameset[9].frame) k->i = 2;

  /* hang */
  if (k->oaction == kid_fall
      || k->oaction == kid_jump
      || k->oaction == kid_run_jump
      || k->oaction == kid_hang_free
      || k->oaction == kid_hang_wall) {
    k->i = 2, k->hang = true;
    place_frame (&k->f, &k->f, kid_turn_frameset[2].frame,
                 &k->hang_pos, (k->f.dir == LEFT)
                 ? 7 : PLACE_WIDTH, +4);
  }

  select_frame (k, kid_turn_frameset, k->i + 1);

  if (k->f.b == kid_stabilize_frameset[0].frame) k->fo.dx = +6;
  if (k->f.b == kid_stabilize_frameset[1].frame) k->fo.dx = +10;
  if (k->f.b == kid_stabilize_frameset[2].frame) k->fo.dx = +8;
  if (k->f.b == kid_stabilize_frameset[3].frame) k->fo.dx = +4;
  if (k->f.b == kid_turn_frameset[3].frame) k->fo.dx = +3;
  if (k->f.b == kid_keep_sword_frameset[9].frame) k->fo.dx = -2;

  return true;
}
예제 #4
0
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;
}
예제 #5
0
파일: fight.c 프로젝트: oitofelix/mininim
bool
is_safe_to_turn (struct anim *k)
{
  int df = dist_fall (&k->f, false);
  return (df > PLACE_WIDTH);
}
예제 #6
0
파일: fight.c 프로젝트: oitofelix/mininim
bool
is_safe_to_attack (struct anim *k)
{
  int df = dist_fall (&k->f, false);
  return df > PLACE_WIDTH;
}