// the asteroids-ish game inside of the automap #include "DoomDef.h" #include "AM_map.h" #include "AM_oids.h" fixed_t ff_x, ff_y, ff_w, ff_h; amo_bullet_t amo_bullets[AMO_MAXBULLETS]; boolean AM_oInRock(amo_rock_t *rock, fixed_t x, fixed_t y) { fixed_t dx2, dy2; boolean rc = false; dx2 = FixedMul(x-rock->x, x-rock->x); dy2 = FixedMul(y-rock->y, y-rock->y); if (dx2+dy2 <= rock->r2) rc = true; return rc; } void AM_oUpdateBullets(void) { int i; amo_bullet_t *a; for (a=amo_bullets;ax != -1) { // move bullet a->x += a->vx; a->y += a->vy; // destroy bullet if it left the screen if (a->x < ff_x || a->x >= ff_x + ff_w || a->y < ff_y || a->y >= ff_y + ff_h) { a->x = -1; continue; } // check for collision with any rock for (r=amo_rocks;rx != -1 && AM_oInRock(r, a->x, a->y)) { a->x = r->x = -1; // if collision, destroy bullet and rock break; } } } } } void AM_oTicker(void) { AM_oUpdateBullets(); AM_oUpdateShip(); AM_oUpdateRocks(); AM_oUpdateShrapnel(); } void AM_oDrawer(void) { } void AM_oInitData(void) { int i; for (i=0;i