Пример #1
0
void		broadcast(int npc)
{
	t_npc	*p;
	t_anim	*a;
	t_item	*item;
	t_list	**anims;

	p = g_env->npc + npc;
	a = new_anim(0, T_BROADCAST * FPS / g_env->time, anim_rock);
	item = new_item(g_env->lists[_init_talk], _mod_talk, a, display_any);
	anims = &g_env->sq[p->x + p->y * g_env->mapw].anims;
	*anims = new_link(*anims, item);
}
Пример #2
0
void		add_mob(int npc, int x, int y, enum e_dir direc)
{
	static GLfloat	dir[3] = {0.0, 0.0, 0.0};
	static GLfloat	vec[3] = {0.0, 0.0, 1.0};
	GLfloat			pos[3];
	t_move			*move;
	t_rot			*rot;
	t_anim			*anim;
	t_square		*sq;
	t_mob			*mob;

	set_vecf(pos, (float)x * 2, 0.0, (float)y * 2);
	anim = new_anim(rand() % 360, 360, anim_mob);
	move = new_move(0, 0, pos, dir);
	rot = new_rot(0, vec, 90 * direc, 0);
	mob = new_mob(anim, move, rot, npc);
	sq = g_env->sq + x + y * g_env->mapw;
	g_env->npc[npc].sq = sq;
	sq->mobs = new_link(sq->mobs, mob);
}
Пример #3
0
/**
 * Loads a set of frames from a file into a model. Returns true on success.
 */
bool load_animation(model *mdl, int frames, FILE *fp)
{
  int i;
  anim *anim;
  char buffer[BUFF_LEN];

  if(!mdl || frames <= 0 || !fp)
    return false;


  /* Find the first empty animation inside the model and create a new
   * animations, assigning the spare slot to it. */
  for(i = 0 ; i < mdl->n_anims; i++)
  {
    if(mdl->anims[i] == NULL)
    {
      printf("Creating new animation, %d frames, %d bones\n", frames,
          mdl->n_bones);
      anim = new_anim(frames, mdl->n_bones);
      mdl->anims[i] = anim;
      break;
    }
    /* If no slots are avaliable then return false. */
    else if(i == mdl->n_anims - 1)
      return false;
  }

  /* Continue reading in files until all the frames have been read in. */
  i = 0;
  while(fgets(buffer, BUFF_LEN - 1, fp) != NULL) 
    if(parse_frame(anim, buffer, mdl->n_bones))
      if(++i == frames)
        break;

  if(i != frames)
    return false;

  return true;
}