Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void c_sprite::draw_world_offset(int x, int y, int z, Block * b, int tileoffset, bool chop)
- {
- if(defaultsheet == 0) defaultsheet = IMGObjectSheet;
- //sprites can be offset by a random amount, both animationwise, and just variationwise.
- //the base offset is set here.
- int rando = randomCube[x%RANDOM_CUBE][y%RANDOM_CUBE][z%RANDOM_CUBE];
- //and the random offset of the animation frame is set here, provided the sprite iis set to use random animation frames.
- int offsetAnimFrame = ((randomanimation?rando:0) + currentAnimationFrame) % MAX_ANIMFRAME;
- //the following stuff is only bothered with if the animation frames say it should be drawn. this can be over-ridden
- // by setting animate to 0
- if ((animframes & (1 << offsetAnimFrame)) || !animate)
- {
- //if set by the xml file, a random offset between 0 and 'variations' is added to the sprite.
- int randoffset = 0;
- if(variations)
- randoffset = rando%variations;
- if(!b)
- return;
- //if the xml says that this is a blood sprite, and offset is set here for proper pooling. this over-rides the random offset.
- if(bloodsprite)
- randoffset = getBloodOffset(b);
- if((water_direction < 0) || (water_direction == get_relative_water_direction(b)))
- {
- if(( //these are all border conditions. this first section is a list of positive conditions. if at least one of the border conditions is met, the tile can be shown.
- (openborders & b->openborders) ||
- (upstairborders & b->upstairborders) ||
- (downstairborders & b->downstairborders) ||
- (rampborders & b->rampborders) ||
- (wallborders & b->wallborders) ||
- (floorborders & b->floorborders) ||
- (lightborders & b->lightborders)
- ) && !( //This second block consists of negative conditions. if /any/ of these border conditions are met, the tile will not be drawn
- (notopenborders & b->openborders) ||
- (notupstairborders & b->upstairborders) ||
- (notdownstairborders & b->downstairborders) ||
- (notrampborders & b->rampborders) ||
- (notwallborders & b->wallborders) ||
- (notfloorborders & b->floorborders) ||
- (darkborders & b->lightborders)
- ))
- {
- if(
- (snowmin <= b->snowlevel &&
- (snowmax == -1 || snowmax >= b->snowlevel)) &&
- (bloodmin <= b->bloodlevel && (bloodmax == -1 || bloodmax >= b->bloodlevel)) &&
- (mudmin <= b->mudlevel && (mudmax == -1 || mudmax >= b->mudlevel)) &&
- (grassmin <= b->grasslevel && (grassmax == -1 || grassmax >= b->grasslevel)) &&
- ((light==LIGHTANY) || ((light==LIGHTYES) && b->designation.bits.skyview) || ((light==LIGHTNO) && !(b->designation.bits.skyview))) &&//only bother with this tile if it's in the light, or not.
- ((grasstype == -1) || (grasstype == b->grassmat))
- )
- {
- int32_t drawx = x;
- int32_t drawy = y;
- int32_t drawz = z; //- ownerSegment->sizez + 1;
- correctBlockForSegmetOffset( drawx, drawy, drawz);
- correctBlockForRotation( drawx, drawy, drawz, b->ownerSegment->rotation);
- int32_t viewx = drawx;
- int32_t viewy = drawy;
- int32_t viewz = drawz;
- pointToScreen((int*)&drawx, (int*)&drawy, drawz);
- drawx -= TILEWIDTH>>1;
- int sheetx, sheety;
- if(tilelayout == BLOCKTILE)
- {
- sheetx = ((sheetindex+tileoffset+randoffset) % SHEET_OBJECTSWIDE) * spritewidth;
- sheety = ((sheetindex+tileoffset+randoffset) / SHEET_OBJECTSWIDE) * spriteheight;
- }
- else if(tilelayout == RAMPBOTTOMTILE)
- {
- sheetx = sheetx = SPRITEWIDTH * b->ramp.index;
- sheety = sheety = ((TILEHEIGHT + FLOORHEIGHT + SPRITEHEIGHT) * (sheetindex+tileoffset+randoffset))+(TILEHEIGHT + FLOORHEIGHT);
- }
- else if(tilelayout == RAMPTOPTILE)
- {
- sheetx = sheetx = SPRITEWIDTH * b->ramp.index;
- sheety = sheety = (TILEHEIGHT + FLOORHEIGHT + SPRITEHEIGHT) * (sheetindex+tileoffset+randoffset);
- }
- else
- {
- sheetx = ((sheetindex+tileoffset+randoffset) % SHEET_OBJECTSWIDE) * spritewidth;
- sheety = ((sheetindex+tileoffset+randoffset) / SHEET_OBJECTSWIDE) * spriteheight;
- }
- if(chop && ( halftile == HALFTILECHOP))
- {
- if(fileindex < 0)
- al_draw_tinted_bitmap_region(defaultsheet, get_color(b), sheetx, sheety+WALL_CUTOFF_HEIGHT, spritewidth, spriteheight-WALL_CUTOFF_HEIGHT, drawx + offset_x + offset_user_x, drawy + offset_user_y + (offset_y - WALLHEIGHT)+WALL_CUTOFF_HEIGHT, 0);
- else
- al_draw_tinted_bitmap_region(getImgFile(fileindex), get_color(b), sheetx, (sheety)+WALL_CUTOFF_HEIGHT, spritewidth, spriteheight-WALL_CUTOFF_HEIGHT, drawx + offset_x + offset_user_x, drawy + offset_user_y + (offset_y - WALLHEIGHT)+WALL_CUTOFF_HEIGHT, 0);
- //draw cut-off floor thing
- al_draw_bitmap_region(IMGObjectSheet,
- TILEWIDTH * SPRITEFLOOR_CUTOFF, 0,
- SPRITEWIDTH, SPRITEWIDTH,
- drawx+offset_x, drawy+offset_y-((SPRITEHEIGHT-WALL_CUTOFF_HEIGHT)/2), 0);
- }
- else if ((chop && (halftile == HALFTILEYES)) || (!chop && (halftile == HALFTILENO)) || (!chop && (halftile == HALFTILECHOP)) || (halftile == HALFTILEBOTH))
- {
- if((isoutline == OUTLINENONE) || ((isoutline == OUTLINERIGHT) && (b->depthBorderNorth)) || ((isoutline == OUTLINELEFT) && (b->depthBorderWest)) || ((isoutline == OUTLINEBOTTOM) && (b->depthBorderDown)))
- {
- if(fileindex < 0)
- al_draw_tinted_bitmap_region(defaultsheet, get_color(b), sheetx, sheety, spritewidth, spriteheight, drawx + offset_x + offset_user_x, drawy + offset_user_y + (offset_y - WALLHEIGHT), 0);
- else
- al_draw_tinted_bitmap_region(getImgFile(fileindex), get_color(b), sheetx, sheety, spritewidth, spriteheight, drawx + offset_x + offset_user_x, drawy + offset_user_y + (offset_y - WALLHEIGHT), 0);
- }
- if(needoutline)
- {
- //drawy -= (WALLHEIGHT);
- //Northern border
- if(b->depthBorderNorth)
- DrawSpriteFromSheet(281, IMGObjectSheet, al_map_rgb(255,255,255), drawx + offset_x, drawy + offset_y );
- //Western border
- if(b->depthBorderWest)
- DrawSpriteFromSheet(280, IMGObjectSheet, al_map_rgb(255,255,255), drawx + offset_x, drawy + offset_y );
- //drawy += (WALLHEIGHT);
- }
- }
- //draw_textf_border(font, al_map_rgb(255,255,255), drawx, drawy, 0, "%d,%d", fileindex, sheetindex);
- }
- }
- }
- }
- if(!subsprites.empty())
- {
- for(int i = 0; i < subsprites.size(); i++)
- {
- subsprites.at(i).draw_world_offset(x, y, z, b, tileoffset, chop);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement