Game-RaycastFOV
view release on metacpan or search on metacpan
lib/Game/RaycastFOV.xs view on Meta::CPAN
MODULE = Game::RaycastFOV PACKAGE = Game::RaycastFOV
PROTOTYPES: ENABLE
void
bypair (callback, ...)
SV *callback;
PREINIT:
int answer, i;
SV *x, *y;
PROTOTYPE: &@
PPCODE:
if (!(items & 1)) croak("uneven number of arguments");
dSP;
for (i = 1; i < items; i += 2) {
x = ST(i);
y = ST(i + 1);
CALLTWOUP;
PUSHs(x);
PUSHs(y);
PUTBACK;
call_sv(callback, G_SCALAR);
lib/Game/RaycastFOV.xs view on Meta::CPAN
if (answer == -1) break;
}
void
bypairall (callback, ...)
SV *callback;
PREINIT:
int i;
SV *x, *y;
PROTOTYPE: &@
PPCODE:
if (!(items & 1)) croak("uneven number of arguments");
dSP;
for (i = 1; i < items; i += 2) {
x = ST(i);
y = ST(i + 1);
CALLTWOUP;
PUSHs(x);
PUSHs(y);
PUTBACK;
call_sv(callback, G_DISCARD);
lib/Game/RaycastFOV.xs view on Meta::CPAN
void
circle (callback, int x0, int y0, int radius)
SV *callback;
PREINIT:
char *key;
int f, ddF_x, ddF_y, x, y;
HV* seen;
STRLEN len;
PROTOTYPE: &$$$
PPCODE:
dSP;
ENTER;
SAVETMPS;
sv_2mortal((SV *)(seen = newHV()));
f = 1 - radius;
ddF_x = 0;
ddF_y = -2 * radius;
x = 0;
y = radius;
CIRCLECB(x0, y0 + radius);
lib/Game/RaycastFOV.xs view on Meta::CPAN
}
FREETMPS;
LEAVE;
void
line (callback, int x0, int y0, int x1, int y1)
SV *callback;
PREINIT:
int answer, dx, dy, err, e2, sx, sy;
PROTOTYPE: &$$$$
PPCODE:
dSP;
dx = abs(x1 - x0);
dy = abs(y1 - y0);
sx = x0 < x1 ? 1 : -1;
sy = y0 < y1 ? 1 : -1;
err = (dx > dy ? dx : -dy) / 2;
while (1) {
CALLTWOUP;
mPUSHs(newSViv(x0));
mPUSHs(newSViv(y0));
lib/Game/RaycastFOV.xs view on Meta::CPAN
void
sub_circle (callback, long x0, long y0, unsigned long radius, double swing, double angle, double max_angle)
SV *callback;
PREINIT:
char *key;
long newx, newy;
HV* seen;
STRLEN len;
PROTOTYPE: &$$$$$$
PPCODE:
dSP;
sv_2mortal((SV *)(seen = newHV()));
while (angle < max_angle) {
newx = x0 + lrint(radius * cos(angle));
newy = y0 + lrint(radius * sin(angle));
key = Perl_form(aTHX_ "%ld,%ld", newx, newy);
len = strlen(key);
if(!hv_exists(seen, key, len)) {
hv_store(seen, key, len, &PL_sv_yes, 0);
CALLTWOUP;
( run in 1.157 second using v1.01-cache-2.11-cpan-5511b514fd6 )