Exemplo n.º 1
0
void
close_door (struct level *l, int e)
{
  struct pos *p;

  struct door *d;
  struct level_door *ld;

  do {
    p = &l->event[e].p;
    switch (con (p)->fg) {
    case DOOR:
      d = door_at_pos (p);
      if (! d) continue;
      d->action = ABRUPTLY_CLOSE_DOOR;
      break;
    case LEVEL_DOOR:
      ld = level_door_at_pos (p);
      if (! ld) continue;
      ld->action = CLOSE_LEVEL_DOOR;
      break;
    default:
      break;
    }
  } while (l->event[e++].next);
}
Exemplo n.º 2
0
void
open_door (struct level *l, int e)
{
  struct pos *p;

  struct door *d;
  struct level_door *ld;

  do {
    p = &l->event[e].p;
    switch (con (p)->fg) {
    case DOOR:
      d = door_at_pos (p);
      if (! d) continue;
      d->action = OPEN_DOOR;
      d->wait = DOOR_WAIT;
      break;
    case LEVEL_DOOR:
      ld = level_door_at_pos (p);
      if (! ld) continue;
      ld->action = OPEN_LEVEL_DOOR;
      break;
    default:
      break;
    }
  } while (l->event[e++].next);
}
Exemplo n.º 3
0
static bool
flow (struct anim *k)
{
  struct pos pbf, pmt;
  survey (_bf, pos, &k->f, NULL, &pbf, NULL);

  k->collision = false;
  k->hit_by_loose_floor = false;

  bool turn = ((k->f.dir == RIGHT) && k->key.left)
    || ((k->f.dir == LEFT) && k->key.right);
  bool walk = ((k->f.dir == RIGHT) && k->key.right && k->key.shift)
    || ((k->f.dir == LEFT) && k->key.left && k->key.shift);
  bool run = (((k->f.dir == RIGHT) && k->key.right)
              || ((k->f.dir == LEFT) && k->key.left)) && ! walk;
  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;
  bool vjump = k->key.up;
  bool drink = is_potion (&pbf) && k->key.shift;
  bool raise_sword = is_sword (&pbf) && k->key.shift;
  bool take_sword = k->key.enter && k->has_sword;

  survey (_mt, pos, &k->f, NULL, &pmt, NULL);
  bool stairs = k->key.up && ! k->key.left && ! k->key.right
    && fg (&pmt) == LEVEL_DOOR
    && level_door_at_pos (&pmt)->i == 0
    && k == get_anim_by_id (0);

  if (k->oaction == kid_normal
      && k->current_lives <= 0) {
    survey (_mt, pos, &k->f, NULL, &pmt, NULL);
    k->p = pmt;
    kid_die (k);
    return false;
  }

  if (k->oaction == kid_normal) {
    if (stairs) {
      k->p = pmt;
      kid_stairs (k);
      return false;
    }

    if (couch) {
      kid_couch (k);
      return false;
    }

    if (jump) {
      kid_jump (k);
      return false;
    }

    if (turn) {
      kid_turn (k);
      return false;
    }

    if (vjump) {
      kid_vjump (k);
      return false;
    }
    if (walk) {
      kid_walk (k);
      return false;
    }

    if (run) {
      if (dist_collision (&k->f, _bf, -4, -4, &k->ci) < 29)
        kid_walk (k);
      else kid_start_run (k);
      return false;
    }

    if (drink) {
      k->item_pos = pbf;
      place_frame (&k->f, &k->f, kid_couch_frameset[0].frame,
                   &k->item_pos, (k->f.dir == LEFT)
                   ? PLACE_WIDTH + 3 : +9, +27);
      kid_couch (k);
      return false;
    }

    if (raise_sword) {
      k->item_pos = pbf;
      kid_couch (k);
      return false;
    }

    if (take_sword) {
      kid_take_sword (k);
      return false;
    }
  }

  k->fo.b = kid_normal_00;
  k->fo.dx = k->fo.dy = +0;

  if (k->f.b == kid_stabilize_frameset[3].frame) k->fo.dx = +2;
  if (k->f.b == kid_walk_frameset[11].frame) k->fo.dx = -1;
  if (k->f.b == kid_jump_frameset[17].frame) k->fo.dx = -2;
  if (k->f.b == kid_couch_frameset[12].frame) k->fo.dx = -2;
  if (k->f.b == kid_vjump_frameset[17].frame) k->fo.dx = +2;
  if (k->f.b == kid_drink_frameset[7].frame) k->fo.dx = +0;
  if (k->f.b == kid_keep_sword_frameset[9].frame) k->fo.dx = +2;

  k->xf.b = NULL;

  return true;
}