コード例 #1
0
ファイル: kid-stabilize.c プロジェクト: jolfzverb/mininim
static bool
physics_in (struct anim *k)
{
  struct coord nc; struct pos np, pmbo, pbb;

  /* inertia */
  k->inertia = k->cinertia = 0;

  /* fall */
  survey (_mbo, pos, &k->f, &nc, &pmbo, &np);
  survey (_bb, pos, &k->f, &nc, &pbb, &np);
  if (is_strictly_traversable (&pmbo)
      && is_strictly_traversable (&pbb)) {
    kid_fall (k);
    return false;
  }

  /* collision */
  /* if (is_colliding (&k->f, &k->fo, +0, false, &k->ci) */
  /*     && ! k->collision) { */
  /*   kid_stabilize_collision (k); */
  /*   return false; */
  /* } */

  return true;
}
コード例 #2
0
ファイル: kid-jump.c プロジェクト: allisson128/mininim
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;
}
コード例 #3
0
ファイル: door.c プロジェクト: allisson128/mininim
bool
should_draw_door_grid (struct pos *p, struct frame *f)
{
  struct pos pl, pa, pmt, ptb;

  struct anim *a = (struct anim *) f->id;

  struct pos *hang_pos = &a->hang_pos;

  survey (_mt, pos, f, NULL, &pmt, NULL);
  survey (_tb, pos, f, NULL, &ptb, NULL);

  prel (p, &pl, +0, -1);
  prel (p, &pa, -1, +0);

  return
    (((peq (&ptb, p) || peq (&ptb, &pl)
       || peq (&ptb, &pa))
      && (peq (&pmt, p) || peq (&pmt, &pl)
          || peq (&pmt, &pa)))
     || is_kid_successfully_climbing_at_pos
     (f, hang_pos, p)
     || (is_kid_turn_run (f)
         && f->dir == LEFT))
    && ! is_kid_successfully_climbing_at_pos
    (f, hang_pos, &pa);
}
コード例 #4
0
ファイル: kid-sword-walkb.c プロジェクト: jolfzverb/mininim
static bool
physics_in (struct anim *k)
{
  struct coord nc; struct pos np, pbf, pmbo, pbb;

  /* collision */
  if (is_colliding (&k->f, &k->fo, +12, true, &k->ci)
      && k->i == 0) {
    kid_sword_normal (k);
    return false;
  }

  /* fall */
  survey (_bf, pos, &k->f, &nc, &pbf, &np);
  survey (_mbo, pos, &k->f, &nc, &pmbo, &np);
  survey (_bb, pos, &k->f, &nc, &pbb, &np);
  if ((is_strictly_traversable (&pbf)
       || is_strictly_traversable (&pmbo)
       || is_strictly_traversable (&pbb))) {
    k->xf.b = NULL;
    kid_fall (k);
    return false;
  }

  return true;
}
コード例 #5
0
ファイル: kid-jump.c プロジェクト: jolfzverb/mininim
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;
}
コード例 #6
0
ファイル: fight.c プロジェクト: oitofelix/mininim
bool
is_in_range (struct anim *k0, struct anim *k1, int r)
{
  struct coord m0, m1; struct pos p0, p1;
  survey (_m, pos, &k0->f, &m0, &p0, NULL);
  survey (_m, pos, &k1->f, &m1, &p1, NULL);
  coord2room (&m1, m0.room, &m1);
  pos2room (&p1, p0.room, &p1);

  return m1.room == m0.room
    && p1.floor == p0.floor
    && abs (m1.x - m0.x) < r;
}
コード例 #7
0
ファイル: fight.c プロジェクト: oitofelix/mininim
bool
is_near (struct anim *k0, struct anim *k1)
{
  struct coord m0, m1; struct pos p0, p1;
  survey (_m, pos, &k0->f, &m0, &p0, NULL);
  survey (_m, pos, &k1->f, &m1, &p1, NULL);

  _m (&k0->f, &m0);
  _m (&k1->f, &m1);
  coord2room (&m1, m0.room, &m1);

  return m1.room == m0.room && p1.floor == p0.floor
    && abs (m1.x - m0.x) < PLACE_WIDTH
    && abs (m1.y - m0.y) < PLACE_HEIGHT;
}
コード例 #8
0
ファイル: guard-fall.c プロジェクト: jolfzverb/mininim
static void
place_in_initial_fall (struct anim *g)
{
  struct coord nc;
  struct pos np, pmt, pmtf, pmtb;
  struct pos fall_pos;

  int dirf = (g->f.dir == LEFT) ? -1 : +1;
  int dirb = (g->f.dir == LEFT) ? +1 : -1;
  survey (_mt, pos, &g->f, &nc, &pmt, &np);
  prel (&pmt, &pmtf, +0, dirf);
  prel (&pmt, &pmtb, +0, dirb);

  fall_pos.room = -1;

  if (is_strictly_traversable (&pmt)) fall_pos = pmt;
  else if (is_strictly_traversable (&pmtf)) fall_pos = pmtf;
  else if (is_strictly_traversable (&pmtb)) fall_pos = pmtb;

  struct frameset *frameset = get_guard_fall_frameset (g->type);

  if (fall_pos.room != - 1)
    place_frame (&g->f, &g->f, frameset[0].frame,
                 &fall_pos,
                 (g->f.dir == LEFT) ? PLACE_WIDTH - 12 : +6,
                 (g->f.dir == LEFT) ? 23 : 27);
}
コード例 #9
0
ファイル: kid-start-run.c プロジェクト: oitofelix/mininim
static bool
physics_in (struct anim *k)
{
  struct pos pmbo, ptf;

  /* inertia */
  k->inertia = 0;
  k->cinertia = 4;

  /* collision */
  if (uncollide (&k->f, &k->fo, _bf, -4, -4, NULL, &k->ci)) {
    kid_stabilize_collision (k);
    return false;
  }

  /* fall */
  survey (_mbo, pos, &k->f, NULL, &pmbo, NULL);
  surveyo (_tf, -4, +0, pos, &k->f, NULL, &ptf, NULL);
  if (is_strictly_traversable (&pmbo)
      || is_strictly_traversable (&ptf)) {
    kid_fall (k);
    return false;
  }

  return true;
}
コード例 #10
0
ファイル: guard-normal.c プロジェクト: allisson128/mininim
static bool
flow (struct anim *g)
{
  struct pos pmt;

  bool vigilant = g->key.enter;

  if (g->oaction == guard_normal
      && g->current_lives <= 0
      && anim_cycle > 0) {
    survey (_mt, pos, &g->f, NULL, &pmt, NULL);
    g->p = pmt;
    guard_die (g);
    return false;
  }

  if (g->oaction == guard_normal
      && vigilant
      && anim_cycle > 0) {
    guard_vigilant (g);
    return false;
  }

  g->fo.b = get_guard_normal_bitmap (g->type);
  g->fo.dx = g->fo.dy = +0;

  select_xframe (&g->xf, sword_frameset, 30);

  if (g->type == VIZIER) g->xf.dy += +4;
  if (g->type == SKELETON) g->xf.dx += -5, g->xf.dy += -6;

  return true;
}
コード例 #11
0
ファイル: pos.c プロジェクト: oitofelix/mininim
struct coord *
place_on_the_ground (struct frame *f, struct coord *c)
{
  struct coord mbo; struct pos pmbo;
  *c = f->c;
  survey (_mbo, pos, f, &mbo, &pmbo, NULL);
  f->c.y += (PLACE_HEIGHT * pmbo.floor + 55) - mbo.y;
  return c;
}
コード例 #12
0
ファイル: fight.c プロジェクト: oitofelix/mininim
enum confg
fight_crel (struct anim *k, int floor, int place)
{
  struct pos pm;
  survey (_m, pos, &k->f, NULL, &pm, NULL);

  /* place sign indicates direction in relation to k orientation */
  int dir = (k->f.dir == LEFT) ? -1 : +1;
  return fg_rel (&pm, floor, dir * place);
}
コード例 #13
0
ファイル: guard-normal.c プロジェクト: allisson128/mininim
static bool
physics_in (struct anim *g)
{
  struct pos pmbo, pbb;

  /* inertia */
  g->inertia = g->cinertia = 0;

  /* fall */
  survey (_mbo, pos, &g->f, NULL, &pmbo, NULL);
  survey (_bb, pos, &g->f, NULL, &pbb, NULL);
  if (is_strictly_traversable (&pmbo)
      && is_strictly_traversable (&pbb)) {
    guard_fall (g);
    return false;
  }

  return true;
}
コード例 #14
0
ファイル: fight.c プロジェクト: oitofelix/mininim
void
fight_turn_controllable (struct anim *k)
{
  int d = INT_MAX;
  int t; /* threshold */
  struct anim *ke = NULL;
  struct anim *ke0 = get_anim_by_id (k->enemy_id);

  /* make the kid target the nearest enemy targeting him */
  int i;
  for (i = 0; i < anima_nmemb; i++) {
    struct anim *a = &anima[i];
    if (a->enemy_id != k->id || ! is_fightable_anim (a))
      continue;
    int de = dist_enemy (a);
    if (de < d) {
      d = de;
      ke = a;
    }
  }

  if (ke && ke0 && ke->f.dir != ke0->f.dir) t = 20;
  else t = -1;

  if (ke && abs (dist_enemy (k) - d) > t)
    consider_enemy (k, ke);

  ke = get_anim_by_id (k->enemy_id);
  if (ke) {
    struct pos p, pe;
    survey (_m, pos, &k->f, NULL, &p, NULL);
    survey (_m, pos, &ke->f, NULL, &pe, NULL);
    pos2room (&pe, p.room, &pe);
    if (is_on_back (k, ke)
        && ! is_in_range (k, ke, INVERSION_RANGE)
        && is_in_fight_mode (k)
        && is_in_fight_mode (ke)
        && p.room == pe.room
        && p.floor == pe.floor)
      fight_turn (k);
  }
}
コード例 #15
0
ファイル: kid-couch.c プロジェクト: NoSuchProcess/mininim
void
kid_couch_suddenly (struct anim *k)
{
  k->action = kid_couch_suddenly;
  struct coord nc; struct pos np, pmt;
  survey (_mt, pos, &k->f, &nc, &pmt, &np);
  place_frame (&k->f, &k->f, kid_couch_frameset[0].frame,
               &pmt, (k->f.dir == LEFT)
               ? 24 : 18, +27);
  kid_couch (k);
}
コード例 #16
0
ファイル: fight.c プロジェクト: oitofelix/mininim
bool
is_hearing (struct anim *k0, struct anim *k1)
{
  struct pos p0, p1;
  survey (_m, pos, &k0->f, NULL, &p0, NULL);
  survey ((k0->f.dir == LEFT) ? _mr : _ml,
          pos, &k1->f, NULL, &p1, NULL);

  pos2room (&p1, p0.room, &p1);

  return p1.room == p0.room
    && (is_kid_run (&k1->f)
        || is_kid_stop_run (&k1->f)
        || is_kid_jump_landing (&k1->f)
        || is_kid_run_jump_running (&k1->f)
        || is_kid_run_jump_landing (&k1->f)
        || (is_kid_couch (&k1->f)
            && k1->fall)
        || k1->action == kid_take_sword);
}
コード例 #17
0
ファイル: kid-turn.c プロジェクト: jolfzverb/mininim
static bool
physics_in (struct anim *k)
{
  struct coord nc; struct pos np, pbf, pbb;

  /* collision */
  if (kid_door_split_collision (k)) return false;

  /* fall */
  survey (_bf, pos, &k->f, &nc, &pbf, &np);
  survey (_bb, pos, &k->f, &nc, &pbb, &np);
  if (! k->hang
      && is_strictly_traversable (&pbf)
      && is_strictly_traversable (&pbb)) {
    kid_fall (k);
    return false;
  }

  return true;
}
コード例 #18
0
ファイル: spikes-floor.c プロジェクト: allisson128/mininim
bool
should_spikes_raise (struct pos *p)
{
  int i;
  struct pos pmf, pm, pmba;

  for (i = 0; i < anima_nmemb; i++) {
    struct anim *a = &anima[i];
    if (is_anim_dead (&a->f)) continue;
    survey (_mf, pos, &a->f, NULL, &pmf, NULL);
    survey (_m, pos, &a->f, NULL, &pm, NULL);
    survey (_mba, pos, &a->f, NULL, &pmba, NULL);

    if (should_spikes_raise_for_pos (p, &pmf)
        || should_spikes_raise_for_pos (p, &pm)
        || should_spikes_raise_for_pos (p, &pmba))
      return true;
  }

  return false;
}
コード例 #19
0
ファイル: fight.c プロジェクト: oitofelix/mininim
bool
is_pos_on_back (struct anim *k, struct pos *p)
{
  struct pos pm, pv;
  survey (_m, pos, &k->f, NULL, &pm, NULL);

  pos2room (p, pm.room, &pv);

  return pm.room == pv.room
    && ((k->f.dir == LEFT && pv.place > pm.place)
        || (k->f.dir == RIGHT && pv.place < pm.place));
}
コード例 #20
0
ファイル: guard-die.c プロジェクト: allisson128/mininim
void
guard_die_suddenly (struct anim *g)
{
  if (con (&g->p)->fg == SPIKES_FLOOR
      || con (&g->p)->fg == CHOPPER) {
    guard_die_properly (g);
    return;
  }

  g->oaction = g->action;
  g->action = guard_die_suddenly;
  g->f.flip = (g->f.dir == RIGHT) ? ALLEGRO_FLIP_HORIZONTAL : 0;

  struct frameset *frameset = get_guard_die_frameset (g->type);

  int dy = (g->type == SKELETON) ? +44 : +47;

  place_frame (&g->f, &g->f, frameset[5].frame,
               &g->p, (g->f.dir == LEFT)
               ? +9 : +4, dy);

  if (g->oaction != guard_die_suddenly) {
    struct anim *ke = get_anim_by_id (g->enemy_id);
    if (! ke) ke = get_anim_by_id (g->oenemy_id);
    if (ke && ke->id == current_kid_id
        && ! g->glory_sample
        && g->death_reason != SHADOW_FIGHT_DEATH) {
      play_sample (glory_sample, NULL, ke->id);
      g->glory_sample = true;
    }

    g->oenemy_id = -1;

    if (ke) upgrade_skill (&ke->skill, &g->skill);
  }

  g->current_lives = 0;
  g->xf.b = NULL;

  g->hit_by_loose_floor = false;

  /* fall */
  struct pos pm;
  survey (_m, pos, &g->f, NULL, &pm, NULL);
  if (is_strictly_traversable (&pm)) {
    guard_fall (g);
    return;
  }

  /* depressible floors */
  update_depressible_floor (g, -12, -28);
}
コード例 #21
0
ファイル: kid-normal.c プロジェクト: oitofelix/mininim
static bool
physics_in (struct anim *k)
{
  struct pos pmbo, pbb;

  /* inertia */
  k->inertia = k->cinertia = 0;

  /* collision */
  uncollide_static_kid_normal (k);

  /* fall */
  survey (_mbo, pos, &k->f, NULL, &pmbo, NULL);
  survey (_bb, pos, &k->f, NULL, &pbb, NULL);
  if (is_strictly_traversable (&pmbo)
      && is_strictly_traversable (&pbb)) {
    kid_fall (k);
    return false;
  }

  return true;
}
コード例 #22
0
ファイル: guard-die.c プロジェクト: allisson128/mininim
static bool
physics_in (struct anim *g)
{
  /* fall */
  struct pos pm;
  survey (_m, pos, &g->f, NULL, &pm, NULL);
  if (is_strictly_traversable (&pm)) {
    guard_fall (g);
    return false;
  }

  return true;
}
コード例 #23
0
ファイル: guard-die.c プロジェクト: allisson128/mininim
void
guard_resurrect (struct anim *g)
{
  struct pos pm;
  survey (_m, pos, &g->f, NULL, &pm, NULL);
  g->current_lives = g->total_lives;
  g->death_reason = NO_DEATH;
  g->action = guard_normal;
  place_frame (&g->f, &g->f, get_guard_normal_bitmap (g->type),
               &pm, g->f.dir == LEFT ? +16 : +22, +14);
  place_on_the_ground (&g->f, &g->f.c);
  reset_murder_spikes_floor (g->id);
}
コード例 #24
0
static bool
physics_in (struct anim *k)
{
  struct coord nc; struct pos np, pbf, pmbo, pbb;

  /* collision */
  uncollide (&k->f, &k->fo, &k->fo, +4, false, &k->ci);

  /* fall */
  survey (_bf, pos, &k->f, &nc, &pbf, &np);
  survey (_mbo, pos, &k->f, &nc, &pmbo, &np);
  survey (_bb, pos, &k->f, &nc, &pbb, &np);
  if (is_strictly_traversable (&pbf)
      || is_strictly_traversable (&pmbo)
      || is_strictly_traversable (&pbb)) {
    k->xf.b = NULL;
    kid_fall (k);
    return false;
  }

  return true;
}
コード例 #25
0
ファイル: loose-floor.c プロジェクト: jolfzverb/mininim
void
draw_falling_loose_floor (ALLEGRO_BITMAP *bitmap, struct pos *p,
                          enum em em, enum vm vm)
{
  struct loose_floor *l = loose_floor_at_pos (p);
  if (! l) return;

  if (l->action == FALL_LOOSE_FLOOR) {
    struct coord tr, br;
    struct pos fptr, nfptr, fpbr, nfpbr;
    frame2room (&l->f, room_view, &l->f.c);
    survey (_tr, posf, &l->f, &tr, &fptr, &nfptr);
    survey (_br, posf, &l->f, &br, &fpbr, &nfpbr);
    l->f.b = get_correct_falling_loose_floor_bitmap (l->f.b);
    struct frame f = l->f;
    if (hgc) f.b = apply_palette (f.b, hgc_palette);
    draw_frame (bitmap, &f);
    draw_confg_base (bitmap, &fptr, em, vm);
    draw_confg_left (bitmap, &fptr, em, vm, true);
    draw_confg_base (bitmap, &fpbr, em, vm);
    draw_confg_left (bitmap, &fpbr, em, vm, true);
  } else return;
}
コード例 #26
0
ファイル: guard-walkb.c プロジェクト: allisson128/mininim
static bool
physics_in (struct anim *g)
{
  struct pos pbf, pmbo, pbb;

  /* collision */
  uncollide (&g->f, &g->fo, &g->fo, +0, true, &g->ci);

  /* fall */
  survey (_bf, pos, &g->f, NULL, &pbf, NULL);
  survey (_mbo, pos, &g->f, NULL, &pmbo, NULL);
  survey (_bb, pos, &g->f, NULL, &pbb, NULL);
  if ((is_strictly_traversable (&pbf)
       || is_strictly_traversable (&pmbo)
       /* || is_strictly_traversable (&pbb) */
       )) {
    g->xf.b = NULL;
    guard_fall (g);
    return false;
  }

  return true;
}
コード例 #27
0
ファイル: kid-unclimb.c プロジェクト: NoSuchProcess/mininim
static bool
physics_in (struct anim *k)
{
  struct coord nc; struct pos np, ptf;

  /* fall */
  survey (_tf, pos, &k->f, &nc, &ptf, &np);
  if (is_strictly_traversable (&ptf)) {
    kid_fall (k);
    return false;
  }

  return true;
}
コード例 #28
0
ファイル: kid-unclimb.c プロジェクト: allisson128/mininim
static bool
physics_in (struct anim *k)
{
  struct pos ptf;

  /* fall */
  survey (_tf, pos, &k->f, NULL, &ptf, NULL);
  if (is_strictly_traversable (&ptf)) {
    kid_fall (k);
    return false;
  }

  return true;
}
コード例 #29
0
static bool
physics_in (struct anim *k)
{
  struct pos pbf, pmbo, pbb;

  /* collision */
  uncollide (&k->f, &k->fo, &k->fo, +0, true, &k->ci);
  if (fight_door_split_collision (k)) return false;

  /* fall */
  survey (_bf, pos, &k->f, NULL, &pbf, NULL);
  survey (_mbo, pos, &k->f, NULL, &pmbo, NULL);
  survey (_bb, pos, &k->f, NULL, &pbb, NULL);
  if (is_strictly_traversable (&pbf)
      || is_strictly_traversable (&pmbo)
      /* || is_strictly_traversable (&pbb) */
      ) {
    k->xf.b = NULL;
    kid_fall (k);
    return false;
  }

  return true;
}
コード例 #30
0
ファイル: kid-misstep.c プロジェクト: oitofelix/mininim
static void
physics_out (struct anim *k)
{
  struct pos pmbo;

  /* depressible floors */
  keep_depressible_floor (k);

  /* loose floor shaking */
  survey (_mbo, pos, &k->f, NULL, &pmbo, NULL);
  if (k->i == 8) shake_loose_floor_row (&pmbo);

  /* sound */
  if (k->i == 7) play_audio (&step_audio, NULL, k->id);
}