Skip to content

Commit

Permalink
Merge pull request #160 from NicksWorld/feat/bloodsprites
Browse files Browse the repository at this point in the history
Implement new blood sprites
  • Loading branch information
myk002 authored Jan 25, 2025
2 parents 441524d + e22c94b commit 7efb2d4
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 96 deletions.
55 changes: 1 addition & 54 deletions SpriteObjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,59 +225,6 @@ unsigned char get_relative_water_direction( Tile *b, uint8_t rotation)
return dir;
}

int getBloodOffset ( Tile *b )
{
int offset = 0;
int x = b->x, y = b->y, z = b->z;

if( b->designation.bits.flow_size < 1 && (b->bloodlevel)) {

// Spatter (should be blood, not blood2) swapped for testing
if( b->bloodlevel < stonesenseState.ssConfig.poolcutoff ) {
offset = 7;
}

// Smear (should be blood2, not blood) swapped for testing
else {
// if there's no tile in the respective direction it's false. if there's no blood in that direction it's false too. should also check to see if there's a ramp below, but since blood doesn't flow, that'd look wrong anyway.
auto& ssConfig = stonesenseState.ssConfig;
bool _N = ( b->ownerSegment->getTileRelativeTo( x, y, z, eUp ) != NULL ? (b->ownerSegment->getTileRelativeTo( x, y, z, eUp )->bloodlevel > ssConfig.poolcutoff) : false ),
_S = ( b->ownerSegment->getTileRelativeTo( x, y, z, eDown ) != NULL ? (b->ownerSegment->getTileRelativeTo( x, y, z, eDown )->bloodlevel > ssConfig.poolcutoff) : false ),
_E = ( b->ownerSegment->getTileRelativeTo( x, y, z, eRight ) != NULL ? (b->ownerSegment->getTileRelativeTo( x, y, z, eRight )->bloodlevel > ssConfig.poolcutoff) : false ),
_W = ( b->ownerSegment->getTileRelativeTo( x, y, z, eLeft ) != NULL ? (b->ownerSegment->getTileRelativeTo( x, y, z, eLeft )->bloodlevel > ssConfig.poolcutoff) : false );

// do rules-based puddling
if( _N || _S || _E || _W ) {
if( _E ) {
if( _N && _S ) {
offset = 5;
} else if( _S ) {
offset = 3;
} else if( _W ) {
offset = 1;
} else {
offset = 6;
}
} else if( _W ) {
if( _S && _N) {
offset = 5;
} else if( _S ) {
offset = 2;
} else {
offset = 0;
}
} else if ( _N ) {
offset = 4;
} else {
offset = 2;
}
} else {
offset = 8;
}
}
}
return offset;
}
namespace {
uint8_t getXXBorders(const char* framestring, int whenNull)
{
Expand Down Expand Up @@ -931,7 +878,7 @@ void c_sprite::assemble_world_offset(int x, int y, int z, int plateoffset, Tile
}
//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) {
spriteoffset = getBloodOffset(b);
spriteoffset = b->GetBloodSpriteOffset();
}
if(!((water_direction < 0) || (water_direction == get_relative_water_direction(b, ssState.Rotation)))) {
goto draw_subsprite;
Expand Down
68 changes: 26 additions & 42 deletions Tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,31 @@ void destroyEffectSprites()
al_destroy_bitmap(sprite_oceanwave);
}

bool isNeighborBloody(Tile* b, dirRelative dir) {
// Checks if the neighbor tile exists, and has blood pooled.
Tile* neighbor = b->ownerSegment->getTileRelativeTo( b->x, b->y, b->z, dir );
if (neighbor != nullptr && neighbor->bloodlevel >= stonesenseState.ssConfig.poolcutoff)
return true;
return false;
}

int Tile::GetBloodSpriteOffset() {
if( this->designation.bits.flow_size < 1 && (this->bloodlevel)) {
if( this->bloodlevel < stonesenseState.ssConfig.poolcutoff ) {
return 16;
}
else {
int _N = isNeighborBloody(this, eUp),
_S = isNeighborBloody(this, eDown),
_E = isNeighborBloody(this, eRight),
_W = isNeighborBloody(this, eLeft);
// Spritesheet is aranged as to make this the proper offset
return (_N << 3) | (_E << 2) | (_S << 1) | _W;
}
}
return 0;
}

void Tile::AssembleFloorBlood ( int32_t drawx, int32_t drawy )
{
auto& ssConfig = stonesenseState.ssConfig;
Expand All @@ -792,48 +817,7 @@ void Tile::AssembleFloorBlood ( int32_t drawx, int32_t drawy )
if( designation.bits.flow_size < 1 && (bloodlevel)) {
sprite.fileIndex = INVALID_INDEX;

// Spatter (should be blood, not blood2) swapped for testing
if( bloodlevel <= stonesenseState.ssConfig.poolcutoff ) {
sprite.sheetIndex = 7;
}

// Smear (should be blood2, not blood) swapped for testing
else {
// if there's no tile in the respective direction it's false. if there's no blood in that direction it's false too. should also check to see if there's a ramp below, but since blood doesn't flow, that'd look wrong anyway.
bool _N = ( ownerSegment->getTileRelativeTo( x, y, z, eUp ) != NULL ? (ownerSegment->getTileRelativeTo( x, y, z, eUp )->bloodlevel > ssConfig.poolcutoff) : false ),
_S = ( ownerSegment->getTileRelativeTo( x, y, z, eDown ) != NULL ? (ownerSegment->getTileRelativeTo( x, y, z, eDown )->bloodlevel > ssConfig.poolcutoff) : false ),
_E = ( ownerSegment->getTileRelativeTo( x, y, z, eRight ) != NULL ? (ownerSegment->getTileRelativeTo( x, y, z, eRight )->bloodlevel > ssConfig.poolcutoff) : false ),
_W = ( ownerSegment->getTileRelativeTo( x, y, z, eLeft ) != NULL ? (ownerSegment->getTileRelativeTo( x, y, z, eLeft )->bloodlevel > ssConfig.poolcutoff) : false );

// do rules-based puddling
if( _N || _S || _E || _W ) {
if( _E ) {
if( _N && _S ) {
sprite.sheetIndex = 5;
} else if( _S ) {
sprite.sheetIndex = 3;
} else if( _W ) {
sprite.sheetIndex = 1;
} else {
sprite.sheetIndex = 6;
}
} else if( _W ) {
if( _S && _N) {
sprite.sheetIndex = 5;
} else if( _S ) {
sprite.sheetIndex = 2;
} else {
sprite.sheetIndex = 0;
}
} else if ( _N ) {
sprite.sheetIndex = 4;
} else {
sprite.sheetIndex = 2;
}
} else {
sprite.sheetIndex = 8;
}
}
sprite.sheetIndex = this->GetBloodSpriteOffset();

int sheetOffsetX = TILEWIDTH * (sprite.sheetIndex % SHEET_OBJECTSWIDE),
sheetOffsetY = 0;
Expand Down
1 change: 1 addition & 0 deletions Tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class Tile
void AssembleTile();
void AddRamptop();
void AssembleDesignationMarker( int32_t drawx, int32_t drawy );
int GetBloodSpriteOffset();
void AssembleFloorBlood ( int32_t drawx, int32_t drawy );
void AssembleParticleCloud(int count, float centerX, float centerY, float rangeX, float rangeY, ALLEGRO_BITMAP *sprite, ALLEGRO_COLOR tint);
void AssembleSpriteFromSheet(int spriteNum, ALLEGRO_BITMAP* spriteSheet, ALLEGRO_COLOR color, float x, float y, Tile * b=NULL, float in_scale=1.0f);
Expand Down
1 change: 1 addition & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Template for new versions:
- `stonesense`: reorganized the position of some existing art to be more intuitive
- `stonesense`: added index numbers empty sprite slots to aid in making the xml files for the sprites
- `stonesense`: zoom levels in stonesense now mirror the main game when in follow mode
- `stonesense`: added new connective tiles for pools of blood and vomit

# 50.15-r2

Expand Down
Binary file modified resources/buildings/bgibs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/gibs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7efb2d4

Please sign in to comment.