int tur_target_within_sight(turret_t *turret, int target_x, int target_y) { int x, y; int map_x, map_y; turret_t *tp; game_data_t *gd; fixed angle, dx, dy; float bx, by; int i; int px, py, pc; dx = itofix((turret->x * 32 + 16) - target_x); dy = itofix((turret->y * 32 + 16) - target_y); angle = fatan2(dy, dx) - itofix(64); x = turret->x * 32; y = turret->y * 32; bx = x + turret->bitmap->w/2; by = y + turret->bitmap->h/2; gd = get_game_data_pointer(); for (i = 0; i < turret->range / 15; i++) { float result; result = fixtof(fixcos(angle)); by -= result * 15; result = fixtof(fixsin(angle)); bx += result * 15; map_x = (int) bx / 32; map_y = (int) by / 32; if (map_x == target_x/32 && map_y == target_y/32) return 1; //putpixel(screen, bx, by, makecol(255,255,255)); tp = gd->turret; for (;;) { if (tp == NULL) break; if (tp != turret && (tp->x == map_x && tp->y == map_y)) { /* found a turret in this tile, check for pixel value */ px = (int)bx - (map_x * 32); py = (int)by - (map_y * 32); pc = getpixel(tp->bitmap, px, py); if (pc != makecol(255, 0, 255)) { return 0; } } tp = tp->next; } } return 1; }
void Splash(int32_t tx, int32_t ty, int32_t amt, C4Object *pByObj) { // Splash only if there is free space above if (GBackSemiSolid(tx, ty - 15)) return; // get back mat int32_t iMat = GBackMat(tx, ty); // check liquid if (MatValid(iMat)) if (DensityLiquid(Game.Material.Map[iMat].Density) && Game.Material.Map[iMat].Instable) { int32_t sy = ty; while (GBackLiquid(tx, sy) && sy > ty - 20 && sy >= 0) sy--; // Splash bubbles and liquid for (int32_t cnt = 0; cnt < amt; cnt++) { BubbleOut(tx + Random(16) - 8, ty + Random(16) - 6); if (GBackLiquid(tx, ty) && !GBackSemiSolid(tx, sy)) Game.PXS.Create(Game.Landscape.ExtractMaterial(tx, ty), itofix(tx), itofix(sy), FIXED100(Random(151) - 75), FIXED100(-Random(200))); } } // Splash sound if (amt >= 20) StartSoundEffect("Splash2", false, 100, pByObj); else if (amt > 1) StartSoundEffect("Splash1", false, 100, pByObj); }
/* draw_object just draws a single object at a fixed position, although this can easily be modified to allow for more objects. bmp = bitmap to draw to. obj = sprite for the object. angle, cx, cy define the camera position. */ void draw_object (BITMAP *bmp, BITMAP *obj, fixed angle, fixed cx, fixed cy, MODE_7_PARAMS params) { int width, height; int screen_y, screen_x; // The object in this case is at a fixed position of (160, 100). // Calculate the position relative to the camera. fixed obj_x = itofix(160) - cx; fixed obj_y = itofix(100) - cy; // use a rotation transformation to rotate the object by the camera // angle fixed space_x = fmul (obj_x, fcos (angle)) + fmul (obj_y, fsin (angle)); fixed space_y = -fmul (obj_x, fsin (angle)) + fmul (obj_y, fcos (angle)); // calculate the screen coordinates that go with these space coordinates // by dividing everything by space_x (the distance) screen_x = bmp->w/2 + fixtoi (fmul (fdiv (params.scale_x, space_x), space_y)); screen_y = fixtoi (fdiv (fmul (params.space_z, params.scale_y), space_x)) - params.horizon; // the size of the object has to be scaled according to the distance height = fixtoi (obj->h * fdiv(params.obj_scale_y, space_x)); width = fixtoi (obj->w * fdiv(params.obj_scale_x, space_x)); // draw the object stretch_sprite (bmp, obj, screen_x - width / 2, screen_y - height, width, height); }
bool ObjectComJump(C4Object *cObj) // by ObjectComUp, ExecCMDFMoveTo, FnJump { // Only if walking if (cObj->GetProcedure()!=DFA_WALK) return false; // Calculate direction & forces C4Real TXDir=Fix0; C4PropList *pActionWalk = cObj->GetAction(); C4Real iPhysicalWalk = C4REAL100(pActionWalk->GetPropertyInt(P_Speed)) * itofix(cObj->GetCon(), FullCon); C4Real iPhysicalJump = C4REAL100(cObj->GetPropertyInt(P_JumpSpeed)) * itofix(cObj->GetCon(), FullCon); if (cObj->Action.ComDir==COMD_Left || cObj->Action.ComDir==COMD_UpLeft) TXDir=-iPhysicalWalk; else if (cObj->Action.ComDir==COMD_Right || cObj->Action.ComDir==COMD_UpRight) TXDir=+iPhysicalWalk; C4Real x = cObj->fix_x, y = cObj->fix_y; // find bottom-most vertex, correct starting position for simulation int32_t iBtmVtx = cObj->Shape.GetBottomVertex(); if (iBtmVtx != -1) { x += cObj->Shape.GetVertexX(iBtmVtx); y += cObj->Shape.GetVertexY(iBtmVtx); } // Try dive if (cObj->Shape.ContactDensity > C4M_Liquid) if (SimFlightHitsLiquid(x,y,TXDir,-iPhysicalJump)) if (ObjectActionDive(cObj,TXDir,-iPhysicalJump)) return true; // Regular jump return ObjectActionJump(cObj,TXDir,-iPhysicalJump,true); }
static t_int *osc_perform(t_int *w) { t_osc *x = (t_osc *)(w[1]); t_sample *in = (t_sample *)(w[2]); t_sample *out = (t_sample *)(w[3]); int n = (int)(w[4]); t_sample *tab = cos_table; unsigned int phase = x->x_phase; int conv = x->x_conv; int off; int frac; while (n--) { phase+= mult(conv ,(*in++)); phase &= (itofix(1) -1); off = fixtoi((long long)phase<<ILOGCOSTABSIZE); #ifdef NO_INTERPOLATION *out = *(tab+off); #else // frac = phase & (itofix(1)-1); frac = phase & ((1<<ILOGCOSTABSIZE)-1); frac <<= (fix1-ILOGCOSTABSIZE); *out = mult(*(tab + off),(itofix(1) - frac)) + mult(*(tab + off + 1),frac); #endif out++; } x->x_phase = phase; return (w+5); }
void C4Object::Stabilize() { // def allows stabilization? if (Def->NoStabilize) return; // normalize angle C4Real nr = fix_r; while (nr < itofix(-180)) nr += 360; while (nr > itofix(180)) nr -= 360; if (nr != Fix0) if (Inside<C4Real>(nr,itofix(-StableRange),itofix(+StableRange))) { // Save step undos C4Real lcobjr=fix_r; C4Shape lshape=Shape; // Try rotation fix_r=Fix0; UpdateShape(); if (ContactCheck(GetX(),GetY())) { // Undo rotation Shape=lshape; fix_r=lcobjr; } else { // Stabilization okay UpdateFace(true); } } }
BOOL ObjectActionCornerScale(C4Object *cObj) { int32_t iRangeX,iRangeY; // Scaling: check range max to min if (cObj->GetProcedure()==DFA_SCALE) { if (!CheckCornerScale(cObj,iRangeX,iRangeY)) return FALSE; } // Swimming: check range min to max else { iRangeY=2; while (!CornerScaleOkay(cObj,iRangeY,iRangeY)) { iRangeY++; if (iRangeY>CornerRange) return FALSE; } iRangeX=iRangeY; } // Do corner scale if (!cObj->SetActionByName("KneelUp")) cObj->SetActionByName("Walk"); cObj->xdir=cObj->ydir=0; //if (cObj->Action.Dir==DIR_Left) cObj->Action.ComDir=COMD_Left; else cObj->Action.ComDir=COMD_Right; if (cObj->Action.Dir==DIR_Left) cObj->fix_x-=itofix(iRangeX); else cObj->fix_x+=itofix(iRangeX); cObj->fix_y-=itofix(iRangeY); cObj->x=fixtoi(cObj->fix_x); cObj->y=fixtoi(cObj->fix_y); return TRUE; }
static int grproc_xadvance( INSTANCE * my, int * params ) { int angle = params[0] ; LOCINT32( mod_grproc, my, COORDX ) += fixtoi( fmul( fcos( angle ), itofix( params[1] ) ) ) ; LOCINT32( mod_grproc, my, COORDY ) -= fixtoi( fmul( fsin( angle ), itofix( params[1] ) ) ) ; return 1 ; }
void IntroSequence::DrawZoomedLogoInCenter(int y1, int y2) { int logowidth = fixtoi(fixmul(itofix(al_get_bitmap_width(iLogo)), iZoom)); int logoheight = fixtoi(fixmul(itofix(al_get_bitmap_height(iLogo)), iZoom)); int targetwidth = width; int targetheight = y2 - y1; int xs, ys, ws, hs; int xd, yd, wd, hd; if (logowidth > targetwidth) { ws = fixtoi(fixdiv(itofix(targetwidth), iZoom)); xs = (al_get_bitmap_width(iLogo) - ws) / 2; xd = 0; wd = targetwidth; } else { xs = 0; ws = al_get_bitmap_width(iLogo); xd = (targetwidth - logowidth) / 2; wd = logowidth; } if (logoheight > targetheight) { hs = fixtoi(fixdiv(itofix(targetheight), iZoom)); ys = (al_get_bitmap_height(iLogo) - hs) / 2; yd = 0; hd = targetheight; } else { ys = 0; hs = al_get_bitmap_height(iLogo); yd = (targetheight - logoheight) / 2; hd = logoheight; } stretch_blit(iLogo, iDoublebuffer, xs, ys, ws, hs, xd, yd, wd, hd); }
void fuel_shield_calcul(int nbvaisseau, struct vaisseau_data *v, double dt) { while (nbvaisseau--) { v->refueling = false; if (v->fire_delay) v->fuel -= 3 * (dt / 0.025); if (!(v->landed || v->rebound) && (v->thrust != itofix(0)) && (v->fuel > 0)) v->fuel -= v->speed_fuel_down * (dt / 0.025); else if ((v->landed || v->rebound) && (v->thrust == itofix(0)) && (v->fuel < v->max_fuel)) { v->fuel += v->speed_fuel_up * (dt / 0.025); v->refueling = true; } if (v->fuel < 0) v->fuel = 0; if (v->fuel > v->max_fuel) v->fuel = v->max_fuel; if (v->shield && v->shield_force > 0) v->shield_force -= v->speed_shield_force_down * (dt / 0.025); else if (!v->shield && v->shield_force < v->max_shield_force) v->shield_force += v->speed_shield_force_up * (dt / 0.025); if (v->shield_force < 0) v->shield_force = 0; if (v->shield_force > v->max_shield_force) v->shield_force = v->max_shield_force; v++; } }
void Splash(int32_t tx, int32_t ty, int32_t amt, C4Object *pByObj) { // Splash only if there is free space above if (GBackSemiSolid(tx, ty - 15)) return; // get back mat int32_t iMat = GBackMat(tx, ty); // check liquid if (MatValid(iMat)) if (DensityLiquid(::MaterialMap.Map[iMat].Density) && ::MaterialMap.Map[iMat].Instable) { int32_t sy = ty; while (GBackLiquid(tx, sy) && sy > ty - 20 && sy >= 0) sy--; // Splash bubbles and liquid for (int32_t cnt=0; cnt<amt; cnt++) { int32_t bubble_x = tx+Random(16)-8; int32_t bubble_y = ty+Random(16)-6; BubbleOut(bubble_x,bubble_y); if (GBackLiquid(tx,ty) && !GBackSemiSolid(tx, sy)) { C4Real xdir = C4REAL100(Random(151)-75); C4Real ydir = C4REAL100(-Random(200)); ::PXS.Create(::Landscape.ExtractMaterial(tx,ty,false), itofix(tx),itofix(sy), xdir, ydir); } } } // Splash sound if (amt>=20) StartSoundEffect("Splash2",false,100,pByObj); else if (amt>1) StartSoundEffect("Splash1",false,100,pByObj); }
bool C4Object::Exit(int32_t iX, int32_t iY, int32_t iR, C4Real iXDir, C4Real iYDir, C4Real iRDir, bool fCalls) { // 1. Exit the current container. // 2. Update Contents of container object and set Contained to nullptr. // 3. Set offset position/motion if desired. // 4. Call Ejection for container and Departure for object. // Not contained C4Object *pContainer=Contained; if (!pContainer) return false; // Remove object from container pContainer->Contents.Remove(this); pContainer->UpdateMass(); pContainer->SetOCF(); // No container Contained=nullptr; // Position/motion fix_x=itofix(iX); fix_y=itofix(iY); fix_r=itofix(iR); BoundsCheck(fix_x, fix_y); xdir=iXDir; ydir=iYDir; rdir=iRDir; // Misc updates Mobile=true; InLiquid=false; CloseMenu(true); UpdateFace(true); SetOCF(); // Object list callback (before script callbacks, because script callbacks may enter again) ObjectListChangeListener.OnObjectContainerChanged(this, pContainer, nullptr); // Engine calls if (fCalls) pContainer->Call(PSF_Ejection,&C4AulParSet(this)); if (fCalls) Call(PSF_Departure,&C4AulParSet(pContainer)); // Success (if the obj wasn't "re-entered" by script) return !Contained; }
BOOL ObjectComJump(C4Object *cObj) // by ObjectComUp, ExecCMDFMoveTo, FnJump { // Only if walking if (cObj->GetProcedure()!=DFA_WALK) return FALSE; // Calculate direction & forces FIXED TXDir=Fix0; C4PhysicalInfo *pPhysical=cObj->GetPhysical(); FIXED iPhysicalWalk = ValByPhysical(280, pPhysical->Walk) * itofix(cObj->GetCon(), FullCon); FIXED iPhysicalJump = ValByPhysical(1000, pPhysical->Jump) * itofix(cObj->GetCon(), FullCon); if (cObj->Action.ComDir==COMD_Left || cObj->Action.ComDir==COMD_UpLeft) TXDir=-iPhysicalWalk; else if (cObj->Action.ComDir==COMD_Right || cObj->Action.ComDir==COMD_UpRight) TXDir=+iPhysicalWalk; else { if (cObj->Action.Dir==DIR_Left) TXDir=-iPhysicalWalk; if (cObj->Action.Dir==DIR_Right) TXDir=+iPhysicalWalk; } FIXED x = cObj->fix_x, y = cObj->fix_y; // find bottom-most vertex, correct starting position for simulation int32_t iBtmVtx = cObj->Shape.GetBottomVertex(); if(iBtmVtx != -1) { x += cObj->Shape.GetVertexX(iBtmVtx); y += cObj->Shape.GetVertexY(iBtmVtx); } // Try dive if(cObj->Shape.ContactDensity > C4M_Liquid) if (SimFlightHitsLiquid(x,y,TXDir,-iPhysicalJump)) if (ObjectActionDive(cObj,TXDir,-iPhysicalJump)) return TRUE; // Regular jump return ObjectActionJump(cObj,TXDir,-iPhysicalJump,true); }
/* calculates the distance between two curve_nodes */ fixed curve_node_dist(curve_node n1, curve_node n2) { #define SCALE 64 fixed dx = itofix(n1.x - n2.x) / SCALE; fixed dy = itofix(n1.y - n2.y) / SCALE; return fixsqrt(fixmul(dx, dx) + fixmul(dy, dy)) * SCALE; }
/* calculates the distance between two nodes */ fixed node_dist(NODE n1, NODE n2) { #define SCALE 64 fixed dx = itofix(n1.x - n2.x) / SCALE; fixed dy = itofix(n1.y - n2.y) / SCALE; return fixsqrt(fixmul(dx, dx) + fixmul(dy, dy)) * SCALE; }
void BulletArray::add(Fixed _x, Fixed _y, Fixed _dx, Fixed _dy, int imgID, bool _p, bool _h) { if(bulletCount < MAX_BULLET) { unsigned short *img = image_entries[imgID]; data[bulletCount].activate(_x - itofix(img[0] / 2), _y - itofix(img[1] / 2), _dx, _dy, imgID, _p, _h); bulletCount++; } }
C4MapScriptAlgoRotate::C4MapScriptAlgoRotate(const C4PropList *props) : C4MapScriptAlgoModifier(props,1,1) { // Get MAPALGO_Rotate properties int32_t r = props->GetPropertyInt(P_R); sr=fixtoi(Sin(itofix(r)), Precision); cr=fixtoi(Cos(itofix(r)), Precision); ox = props->GetPropertyInt(P_OffX); oy = props->GetPropertyInt(P_OffY); }
void ExpParticle::activate(Fixed _x, Fixed _y, Fixed _dx, Fixed _dy, Fixed _g) { x = itofix(_x); y = itofix(_y); dx = _dx; dy = _dy; gravity = _g; cIndex = 254; active = true; }
void Animation::drawRotatedFrame(BITMAP *dest, int frame, int x, int y, int angle, bool vflip) { BITMAP *src = getFrame(frame); if (vflip) { rotate_sprite_v_flip(dest, src, x, y, itofix(angle)); } else { rotate_sprite(dest, src, x, y, itofix(angle)); } }
bool C4ValueProviderAbsRDir::Execute() { // Object might have been removed if(!Object) return false; C4Real val = (Abs(Object->rdir) - MinRDir) / (MaxRDir - MinRDir); Value = Begin + (End - Begin) * Clamp<C4Real>(val, itofix(0), itofix(1)); return true; }
void draw_crusher(BITMAP *bmp) { static fixed angle = 0; int x, y, x1, y1, x2, y2; x = crusher.x+crusher.w/2-get_bitmap(BMP_CRUSHER)->w/2; y = crusher.y+crusher.h/2-get_bitmap(BMP_CRUSHER)->h/2+8; /* crusher body */ draw_sprite(bmp, get_bitmap(BMP_CRUSHER), x, y); /* crusher motor */ draw_sprite(bmp, get_bitmap(BMP_CRUSHER_MOTOR), x1 = x-get_bitmap(BMP_CRUSHER_MOTOR)->w+1+rand()%3-1, y1 = y+rand()%3-1); /* crusher pulley */ rotate_sprite(bmp, get_bitmap(BMP_CRUSHER_PULLEY), x2 = x+17-get_bitmap(BMP_CRUSHER_PULLEY)->w/2+rand()%3-1, y2 = y+13-get_bitmap(BMP_CRUSHER_PULLEY)->h/2+rand()%3-1, angle); /* strap */ do_line(bmp, x1+12, y1+8, x2+get_bitmap(BMP_CRUSHER_PULLEY)->w/2-1, y2, makecol(0, 0, 0), strap_proc); do_line(bmp, x1+12, y1+18, x2+get_bitmap(BMP_CRUSHER_PULLEY)->w/2-1, y2+get_bitmap(BMP_CRUSHER_PULLEY)->h-1, makecol(0, 0, 0), strap_proc); angle = fadd(angle, itofix(16)); if (angle > itofix(256)) angle = fsub(angle, itofix(256)); /* scorer */ draw_sprite(bmp, get_bitmap(BMP_SCORER), x+get_bitmap(BMP_CRUSHER)->w, y+get_bitmap(BMP_CRUSHER)->h-get_bitmap(BMP_SCORER)->h); /* alarm */ if (alarm_time_blue >= 0) { masked_blit(get_bitmap(BMP_SCORER_ALARM), bmp, 0, 0, x+get_bitmap(BMP_CRUSHER)->w+63, y+get_bitmap(BMP_CRUSHER)->h-get_bitmap(BMP_SCORER)->h+27, 8, 9); } if (alarm_time_red >= 0) { masked_blit(get_bitmap(BMP_SCORER_ALARM), bmp, get_bitmap(BMP_SCORER_ALARM)->w-8, 0, x+get_bitmap(BMP_CRUSHER)->w+75, y+get_bitmap(BMP_CRUSHER)->h-get_bitmap(BMP_SCORER)->h+27, 8, 9); } }
/* calc_spline: * Calculates a set of pixels for the bezier spline defined by the four * points specified in the points array. The required resolution * is specified by the npts parameter, which controls how many output * pixels will be stored in the x and y arrays. */ void calc_spline(int points[8], int npts, int *x, int *y) { int i; fixed denom; for (i=0; i<npts; i++) { denom = fdiv(itofix(i), itofix(npts-1)); x[i] = fixtoi(bezval(denom, points)); y[i] = fixtoi(bezval(denom, points+1)); } }
void C4Sky::Execute() { // surface exists? if (!Surface) return; // advance pos x+=xdir; y+=ydir; // clip by bounds if (x>=itofix(Width)) x-=itofix(Width); if (y>=itofix(Height)) y-=itofix(Height); // update speed if (ParallaxMode == C4SkyPM_Wind) xdir=C4REAL100(::Weather.Wind); }
/* calculates a set of node tangents */ void calc_tangents(void) { int i; nodes[0] = dummy_node(nodes[1], nodes[2]); nodes[node_count] = dummy_node(nodes[node_count-1], nodes[node_count-2]); node_count++; for (i=1; i<node_count-1; i++) nodes[i].tangent = fixatan2(itofix(nodes[i+1].y - nodes[i-1].y), itofix(nodes[i+1].x - nodes[i-1].x)); }
void alienrocket::fireRocket(int dx, int dy, int a){ angle = rand()% 360; targetX = itofix(dx); targetY = itofix(dy); fired = true; int r1; //randomly picks an x coorinate in the general direction of the target int r2; //randomly picks a y coordinate in the general direction of the target r1 = (dx - 100) + int(200.0 * rand()/(RAND_MAX+1.0)); r2 = (dy - 100)+ int(200.0 * rand()/(RAND_MAX+1.0)); angle = a; angle = fatan2(itofix(r2) - y, itofix(r1)- x); }
bool ObjectActionCornerScale(C4Object *cObj) { int32_t iRangeX = 1, iRangeY = 1; if (!CornerScaleOkay(cObj,iRangeX,iRangeY)) return false; // Do corner scale if (!cObj->SetActionByName("KneelUp")) cObj->SetActionByName("Walk"); cObj->xdir=cObj->ydir=0; if (cObj->Action.Dir==DIR_Left) cObj->fix_x-=itofix(iRangeX); else cObj->fix_x+=itofix(iRangeX); cObj->fix_y-=itofix(iRangeY); return true; }
static inline void tur_rotate(turret_t *turret) { fixed dx, dy; int i; int dir_n, dir_p; int x, y; int rotate_direction; x = turret->x * 32; y = turret->y * 32; rotate_direction = 0; /* rotate: get desired angle from target */ if (turret->target_monster != NULL) { dx = itofix((x + 16) - (int)(turret->target_monster->x + 16)); dy = itofix((y + 16) - (int)(turret->target_monster->y + 16)); turret->desired_angle = fatan2(dy, dx) - itofix(64); } else turret->desired_angle = itofix(-420); if (turret->target_monster != NULL) { if (fixtoi(turret->angle) != fixtoi(turret->desired_angle) && tur_target_within_range(turret,(int)turret->target_monster->x + 16,(int)turret->target_monster->y + 16)) { dir_n = 0; dir_p = 0; /* calculate travel distances */ i = fixtoi(turret->angle); for (;;) { i--; dir_n++; if (i < -192) i = 64; if (i > 64) i = -192; if (i == fixtoi(turret->desired_angle)) break; } i = fixtoi(turret->angle); for (;;) { i++; dir_p++; if (dir_p > dir_n) break; if (i < -192) i = 64; if (i > 64) i = -192; if (i == fixtoi(turret->desired_angle)) break; } /* rotate */ if (dir_n < dir_p) rotate_direction = 1; else rotate_direction = 2; if (rotate_direction == 1) turret->angle = itofix(fixtoi(turret->angle) - 1); if (rotate_direction == 2) turret->angle = itofix(fixtoi(turret->angle) + 1); if (fixtoi(turret->angle) > 64) turret->angle = itofix(-192); if (fixtoi(turret->angle) < -192) turret->angle = itofix(64); } } /* rotate */ }
void draw_donkeys(BITMAP *bmp) { int x1, y1, x2, y2; DONKEY *donkey; int i, x, y; /* draw normal donkeys */ for (donkey=donkey_list; donkey; donkey=donkey->next) { draw_a_donkey(bmp, (move_time) < ((FRAMES_PER_SECOND/2)*move_freq/1000)? get_bitmap(BMP_DONKEY): get_bitmap(BMP_DONKEY_WALK), donkey->x*BLOCK_WIDTH/2+BLOCK_WIDTH/2-get_bitmap(BMP_DONKEY)->w/2, donkey->y*BLOCK_HEIGHT/2+BLOCK_HEIGHT/2-get_bitmap(BMP_DONKEY)->h/2-4, donkey->color, donkey->flip, itofix(1), itofix(1)); } /* draw the death donkeys */ for (i=0; i<death_donkey_count; i++) { if (death_donkey[i].time < FRAMES_PER_SECOND/2) { x1 = death_donkey[i].x; y1 = death_donkey[i].y; x2 = death_donkey[i].x; y2 = death_donkey[i].y+BLOCK_HEIGHT; x = x1 + (x2-x1) * (death_donkey[i].time) / (FRAMES_PER_SECOND/2); y = y1 + (y2-y1) * (death_donkey[i].time) / (FRAMES_PER_SECOND/2); } else { x1 = death_donkey[i].x; y1 = death_donkey[i].y+BLOCK_HEIGHT; x2 = crusher.x+crusher.w/2-get_bitmap(BMP_DONKEY_DEATH)->w/2; y2 = crusher.y+crusher.h/2-get_bitmap(BMP_DONKEY_DEATH)->h/2;//+BLOCK_HEIGHT; x = x1 + (x2-x1) * (death_donkey[i].time-(FRAMES_PER_SECOND/2)) / (FRAMES_PER_SECOND/2); y = y1 + (y2-y1) * (death_donkey[i].time-(FRAMES_PER_SECOND/2)) / (FRAMES_PER_SECOND/2); } draw_a_donkey(bmp, get_bitmap(BMP_DONKEY_DEATH), x+rand()%3-1, y+rand()%3-1, death_donkey[i].color, death_donkey[i].flip, (death_donkey[i].time < FRAMES_PER_SECOND/2)? 0: (itofix(256) * (death_donkey[i].time-(FRAMES_PER_SECOND/2)) / (FRAMES_PER_SECOND/2)) * ((death_donkey[i].clockwise)? 1: -1), itofix(1)); } }
NPCBlack1::NPCBlack1(int x, int y, int HP, std::string bullet_path, BITMAP* sprite) { this->pos_x = itofix(x); this->pos_y = itofix(y); this->speed_vector = itofix(1); this->angle = itofix(0); this->HP = HP; this->fire = false; this->moviendo = false; this->ship = sprite; this->bullet = new Proyectil(pos_x,pos_y, bullet_path); //std::cout << x << ", " << y << std::endl; }
/* update shape positions */ void move_shape() { int c; shape.z += shape.dz; if ((shape.z > itofix(1024)) || (shape.z < itofix(192))) shape.dz = -shape.dz; shape.drx = 0; shape.dry = 0; shape.drz = 0; if (key[KEY_UP]) shape.drx = itofix(1); if (key[KEY_DOWN]) shape.drx = itofix(-1); if (key[KEY_LEFT]) shape.dry = itofix(1); if (key[KEY_RIGHT]) shape.dry = itofix(-1); if (key[KEY_COMMA]) shape.drz = itofix(1); if (key[KEY_STOP]) shape.drz = itofix(-1); shape.rx += shape.drx; shape.ry += shape.dry; shape.rz += shape.drz; }