A new code to simulate three-dimensional plasmas in complex toroidal geometries is presented. It solves drift-kinetic equations for the one-particle distribution function f based on their projection onto a functional basis consisting of an arbitrary number of Legendre-Laguerre polynomials. In this paper, these theoretical aspects of the code are exposed together with their relation with the standard formalism. Comparisons with neoclassical theory for the large aspect ratio case and first calculations in the geometry of the TJ-II Heliac are also presented.