static void DrawFloor(DrawBuffer *b, Vec2i offset) { int x, y; Vec2i pos; Tile *tile = &b->tiles[0][0]; for (y = 0, pos.y = b->dy + offset.y; y < Y_TILES; y++, pos.y += TILE_HEIGHT) { for (x = 0, pos.x = b->dx + offset.x; x < b->Size.x; x++, tile++, pos.x += TILE_WIDTH) { if (tile->pic != NULL && PicIsNotNone(tile->pic) && !(tile->flags & MAPTILE_IS_WALL)) { BlitMasked( &gGraphicsDevice, tile->pic, pos, GetTileLOSMask(tile), 0); } } tile += X_TILES - b->Size.x; } }
static void DrawObjectiveHighlight( TTileItem *ti, Tile *tile, DrawBuffer *b, Vec2i offset) { if (!(ti->flags & TILEITEM_OBJECTIVE)) { return; } int objective = ObjectiveFromTileItem(ti->flags); MissionObjective *mo = CArrayGet(&gMission.missionData->Objectives, objective); if (mo->Flags & OBJECTIVE_HIDDEN) { return; } if (!(mo->Flags & OBJECTIVE_POSKNOWN) && (tile->flags & MAPTILE_OUT_OF_SIGHT)) { return; } Vec2i pos = Vec2iNew( ti->x - b->xTop + offset.x, ti->y - b->yTop + offset.y); struct Objective *o = CArrayGet(&gMission.Objectives, objective); color_t color = o->color; int pulsePeriod = FPS_FRAMELIMIT; int alphaUnscaled = (gMission.time % pulsePeriod) * 255 / (pulsePeriod / 2); if (alphaUnscaled > 255) { alphaUnscaled = 255 * 2 - alphaUnscaled; } color.a = (Uint8)alphaUnscaled; if (ti->getPicFunc != NULL) { Vec2i picOffset; const Pic *pic = ti->getPicFunc(ti->id, &picOffset); BlitPicHighlight( &gGraphicsDevice, pic, Vec2iAdd(pos, picOffset), color); } else if (ti->getActorPicsFunc != NULL) { ActorPics pics = ti->getActorPicsFunc(ti->id); // Do not highlight dead, dying or transparent characters if (!pics.IsDead && !pics.IsTransparent) { for (int i = 0; i < 3; i++) { if (PicIsNotNone(&pics.Pics[i])) { BlitPicHighlight( &gGraphicsDevice, &pics.Pics[i], pos, color); } } } } }
void PicManagerTerminate(PicManager *pm) { for (int i = 0; i < PIC_MAX; i++) { if (pm->oldPics[i] != NULL) { CFREE(pm->oldPics[i]); } if (PicIsNotNone(&pm->picsFromOld[i])) { PicFree(&pm->picsFromOld[i]); } } PicManagerClear(&pm->pics, &pm->sprites); CArrayTerminate(&pm->pics); CArrayTerminate(&pm->sprites); PicManagerClear(&pm->customPics, &pm->customSprites); CArrayTerminate(&pm->customPics); CArrayTerminate(&pm->customSprites); IMG_Quit(); }
void PicManagerGenerateOldPics(PicManager *pm, GraphicsDevice *g) { int i; // Convert old pics into new format ones // TODO: this is wasteful; better to eliminate old pics altogether // Note: always need to reload in editor since colours could change, // requiring an updating of palettes for (i = 0; i < PIC_MAX; i++) { PicPaletted *oldPic = PicManagerGetOldPic(pm, i); if (PicIsNotNone(&pm->picsFromOld[i])) { PicFree(&pm->picsFromOld[i]); } if (oldPic == NULL) { memcpy(&pm->picsFromOld[i], &picNone, sizeof picNone); } else { PicFromPicPaletted(g, &pm->picsFromOld[i], oldPic); } } }