Example #1
0
int			monster_time(t_player *player, t_map *map, t_npc *npc)
{
  if (npc->move)
    {
      while (npc)
	{
	  if ((map->map[npc->y][npc->x + npc->vx] != WALL_CHAR ||
	       map->map[npc->y][npc->x + npc->vx] == LADDER_CHAR) &&
	      (map->map[npc->y + 1][npc->x + npc->vx] == WALL_CHAR ||
	       map->map[npc->y + 1][npc->x + npc->vx] == LADDER_CHAR) &&
	      map->map[npc->y][npc->x + npc->vx] != ENTER_CHAR)
	    if (player->banane.pos.y == npc->y &&
		(player->banane.pos.x == npc->x ||
		 (player->banane.pos.x + player->banane.dir == npc->x &&
		  player->banane.move)))
	      monster_die(npc, map, player);
	    else
	      npc->x += npc->vx;
	  else
	    npc->vx *= -1;
	  npc->move--;
	  if (!npc->move)
	    player->move = 5;
	  npc = npc->next;
	}
    }
  return (1);
}
static int monster_move_aux(struct monster* monster, struct map* map, int x, int y) {

	if (!map_is_inside(map, x, y)){
		return 0;
	}

	switch (map_get_cell_type(map, x, y)) {

	case CELL_SCENERY:
			return 0;
			break;

		case CELL_CASE:
			return 0;
			break;

		case CELL_BONUS:
			break;

		case CELL_GOAL:
			return 0;
			break;

		case CELL_MONSTER:
			return 0;
			break;

		case CELL_PLAYER:
			return 0;
			break;

		case CELL_BOMB:

			monster_die(monster);
			map_set_cell_type(map,x,y,CELL_EMPTY);
			return 0;
			break;


		default:
			break;
	}

	// Monster has moved
	return 1;
}