Game-Xomb
view release on metacpan or search on metacpan
lib/Game/Xomb.xs view on Meta::CPAN
MODULE = Game::Xomb PACKAGE = Game::Xomb
PROTOTYPES: DISABLE
void
bypair (callback, ...)
SV *callback;
PREINIT:
int i;
SV *x, *y;
PPCODE:
if (!(items & 1)) croak("uneven number of arguments");
dSP;
for (i = 1; i < items; i += 2) {
x = ST(i);
y = ST(i + 1);
ENTER;
SAVETMPS;
PUSHMARK(SP);
EXTEND(SP, 2);
PUSHs(x);
lib/Game/Xomb.xs view on Meta::CPAN
}
SvREFCNT_inc(dunno);
RETVAL = dunno;
OUTPUT:
RETVAL
# init_jsf - setup the RNG (see src/jsf.*)
void
init_jsf (seed)
UV seed
PPCODE:
raninit(seed);
UV
irand (uint32_t max)
CODE:
RETVAL = ranval() % max;
OUTPUT:
RETVAL
# linecb - Bresenham with some features to keep it from going off of
# the map and to skip the first point and abort should the callback
# return -1
void
linecb (callback, int x0, int y0, int x1, int y1)
SV *callback;
PREINIT:
int answer, dx, dy, err, e2, sx, sy, online, iters;
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;
iters = 0;
online = 0;
while (1) {
if (x0 < 0 || x0 >= MAP_COLS || y0 < 0 || y0 >= MAP_ROWS) break;
lib/Game/Xomb.xs view on Meta::CPAN
OUTPUT:
RETVAL
# walkcb - linecb, but does not stop at x1,y1. used by Trolls to find
# what gets busted, which may or may not be the player
void
walkcb (callback, int x0, int y0, int x1, int y1)
SV *callback;
PREINIT:
int answer, dx, dy, err, e2, sx, sy, online, iters;
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;
iters = 0;
online = 0;
while (1) {
if (x0 < 0 || x0 >= MAP_COLS || y0 < 0 || y0 >= MAP_ROWS) break;
( run in 1.220 second using v1.01-cache-2.11-cpan-5511b514fd6 )