From 9cf74646b8b8e0a11029ffeeea6562b0045df260 Mon Sep 17 00:00:00 2001 From: Caldfir Date: Mon, 3 Dec 2012 14:52:44 -0800 Subject: [PATCH] Brought back ramp tops. --- Block.cpp | 65 +++++----- SpriteObjects.cpp | 35 +++--- SpriteObjects.h | 303 +++++++++++++++++++++++----------------------- 3 files changed, 202 insertions(+), 201 deletions(-) diff --git a/Block.cpp b/Block.cpp index b9f049c9..2072beae 100644 --- a/Block.cpp +++ b/Block.cpp @@ -201,22 +201,34 @@ void Block::Assemble() //Draw Ramp Tops - if(false){//tileType == tiletype::RampTop){ - Block * b = this->ownerSegment->getBlockLocal(this->x, this->y, this->z-1); + if(tileType == tiletype::RampTop){ + Block * b = this->ownerSegment->getBlock(this->x, this->y, this->z-1); if(b && b->tileShapeBasic == tiletype_shape_basic::Ramp) { - c_sprite * spriteobject = GetBlockSpriteMap(b->tileType,material,b->consForm); - if (spriteobject->get_sheetindex() == UNCONFIGURED_INDEX) { - spriteobject->set_sheetindex(0); - spriteobject->set_fileindex(INVALID_INDEX); - } - if (spriteobject->get_sheetindex() != INVALID_INDEX) { - spriteobject->set_size(SPRITEWIDTH, TILEHEIGHT); - spriteobject->set_offset(0, -(FLOORHEIGHT)); - spriteobject->set_tile_layout(RAMPTOPTILE); - spriteobject->set_defaultsheet(IMGRampSheet); - spriteobject->draw_world(x, y, z, this, (chopThisBlock && this->z == ownerSegment->z + ownerSegment->sizez -2)); - spriteobject->set_offset(0, 0); - } + spriteobject = GetBlockSpriteMap(b->tileType, b->material, b->consForm); + if (spriteobject->get_sheetindex() == UNCONFIGURED_INDEX) { + spriteobject->set_sheetindex(0); + spriteobject->set_fileindex(INVALID_INDEX); + spriteobject->set_defaultsheet(IMGRampSheet); + } + if (spriteobject->get_sheetindex() != INVALID_INDEX) { + spriteobject->set_size(SPRITEWIDTH, TILEHEIGHT); + spriteobject->set_tile_layout(RAMPTOPTILE); + spriteobject->set_offset(0, WALLHEIGHT); + spriteobject->draw_world_offset_src(x, y, z, 0, this, b, (chopThisBlock && this->z == ownerSegment->z + ownerSegment->sizez -2)); + spriteobject->set_offset(0, 0); + } + //if (spriteobject->get_sheetindex() == UNCONFIGURED_INDEX) { + // spriteobject->set_sheetindex(0); + // spriteobject->set_fileindex(INVALID_INDEX); + //} + //if (spriteobject->get_sheetindex() != INVALID_INDEX) { + // spriteobject->set_size(SPRITEWIDTH, TILEHEIGHT); + // spriteobject->set_offset(0, -(FLOORHEIGHT)); + // spriteobject->set_tile_layout(RAMPTOPTILE); + // spriteobject->set_defaultsheet(IMGRampSheet); + // spriteobject->draw_world(x, y, z, this, (chopThisBlock && this->z == ownerSegment->z + ownerSegment->sizez -2)); + // spriteobject->set_offset(0, 0); + //} spriteobject->set_tile_layout(BLOCKTILE); } } @@ -225,7 +237,7 @@ void Block::Assemble() if( tileShapeBasic==tiletype_shape_basic::Floor || tileShapeBasic==tiletype_shape_basic::Wall || tileShapeBasic==tiletype_shape_basic::Ramp || - tileShapeBasic==tiletype_shape_basic::Stair ) { + tileShapeBasic==tiletype_shape_basic::Stair) { //If tile has no floor, look for a Filler Floor from it's wall if (tileShapeBasic==tiletype_shape_basic::Floor) { @@ -238,21 +250,6 @@ void Block::Assemble() spriteobject = GetFloorSpriteMap(tileType, this->material, consForm); } if(spriteobject->get_sheetindex() != INVALID_INDEX) { - ////if floor is muddy, override regular floor - //if( mudlevel && water.index == 0) - //{ - // sprite.sheetIndex = SPRITEFLOOR_WATERFLOOR; - // sprite.fileIndex = INVALID_INDEX; - //} - ////if floor is snowed down, override regular floor - //if( snowlevel ) - //{ - // sprite.sheetIndex = SPRITEFLOOR_SNOW; - // sprite.fileIndex = INVALID_INDEX; - // spriteOffset = 0; - // al_set_separate_blender(op, src, dst, alpha_op, alpha_src, alpha_dst, color); - //} - if (spriteobject->get_sheetindex() == UNCONFIGURED_INDEX) { spriteobject->set_sheetindex(SPRITEOBJECT_FLOOR_NA); spriteobject->set_fileindex(INVALID_INDEX); @@ -301,7 +298,7 @@ void Block::Assemble() if (spriteobject->get_sheetindex() != INVALID_INDEX) { spriteobject->set_size(SPRITEWIDTH, SPRITEHEIGHT); spriteobject->set_tile_layout(RAMPBOTTOMTILE); - spriteobject->draw_world(x, y, z, this, (chopThisBlock && this->z == ownerSegment->z + ownerSegment->sizez -2)); + spriteobject->draw_world_offset(x, y, z, 0, this, (chopThisBlock && this->z == ownerSegment->z + ownerSegment->sizez -2)); } spriteobject->set_tile_layout(BLOCKTILE); } @@ -377,7 +374,7 @@ void Block::Assemble() spriteobject = GetFloorSpriteMap(tileType, material, consForm); if(spriteobject->get_sheetindex() != INVALID_INDEX && spriteobject->get_sheetindex() != UNCONFIGURED_INDEX) { if (mirrored) { - spriteobject->draw_world_offset(x, y, z, this, 1); + spriteobject->draw_world_offset(x, y, z, 1, this); } else { spriteobject->draw_world(x, y, z, this); } @@ -387,7 +384,7 @@ void Block::Assemble() spriteobject = GetBlockSpriteMap(tileType, material, consForm); if(spriteobject->get_sheetindex() != INVALID_INDEX && spriteobject->get_sheetindex() != UNCONFIGURED_INDEX) { if (mirrored) { - spriteobject->draw_world_offset(x, y, z, this, 1); + spriteobject->draw_world_offset(x, y, z, 1, this); } else { spriteobject->draw_world(x, y, z, this); } diff --git a/SpriteObjects.cpp b/SpriteObjects.cpp index 6e3ad61e..9a7c9783 100644 --- a/SpriteObjects.cpp +++ b/SpriteObjects.cpp @@ -624,13 +624,16 @@ void c_sprite::set_by_xml(TiXmlElement *elemSprite) // } //} -void c_sprite::draw_world(int x, int y, int z, Block * b, bool chop) +inline void c_sprite::draw_world(int x, int y, int z, Block * b, bool chop) { - draw_world_offset(x, y, z, b, 0, chop); + draw_world_offset_src(x, y, z, 0, b, b, chop); } +inline void c_sprite::draw_world_offset(int x, int y, int z, int tileoffset, Block * b, bool chop){ + draw_world_offset_src(x, y, z, tileoffset, b, b, chop); +} -void c_sprite::draw_world_offset(int x, int y, int z, Block * b, int tileoffset, bool chop) +void c_sprite::draw_world_offset_src(int x, int y, int z, int tileoffset, Block * b, Block* src, bool chop) { if(defaultsheet == 0) { defaultsheet = IMGObjectSheet; @@ -688,33 +691,33 @@ void c_sprite::draw_world_offset(int x, int y, int z, Block * b, int tileoffset, goto draw_subsprite; } int foo = 0; - if(!(snowmin <= b->snowlevel && (snowmax == -1 || snowmax >= b->snowlevel))) { + if(!(snowmin <= src->snowlevel && (snowmax == -1 || snowmax >= src->snowlevel))) { goto draw_subsprite; } - if (!(bloodmin <= b->bloodlevel && (bloodmax == -1 || bloodmax >= b->bloodlevel))) { + if (!(bloodmin <= src->bloodlevel && (bloodmax == -1 || bloodmax >= src->bloodlevel))) { goto draw_subsprite; } - if(!(mudmin <= b->mudlevel && (mudmax == -1 || mudmax >= b->mudlevel))) { + if(!(mudmin <= src->mudlevel && (mudmax == -1 || mudmax >= src->mudlevel))) { goto draw_subsprite; } - if(!(grassmin <= b->grasslevel && (grassmax == -1 || grassmax >= b->grasslevel))) { + if(!(grassmin <= src->grasslevel && (grassmax == -1 || grassmax >= src->grasslevel))) { goto draw_subsprite; } //only bother with this tile if it's in the light, or not. if(!((light==LIGHTANY) || ((light==LIGHTYES) && b->designation.bits.outside) || ((light==LIGHTNO) && !(b->designation.bits.outside)))) { goto draw_subsprite; } - if(!((grasstype == -1) || (grasstype == b->grassmat))) { + if(!((grasstype == -1) || (grasstype == src->grassmat))) { goto draw_subsprite; } if(!((grass_growth == GRASS_GROWTH_ANY) || ((grass_growth == GRASS_GROWTH_NORMAL) && - ((b->tileMaterial == tiletype_material::GRASS_DARK) || - (b->tileMaterial == tiletype_material::GRASS_LIGHT))) || + ((src->tileMaterial == tiletype_material::GRASS_DARK) || + (src->tileMaterial == tiletype_material::GRASS_LIGHT))) || ((grass_growth == GRASS_GROWTH_DRY) && - (b->tileMaterial == tiletype_material::GRASS_DRY)) || + (src->tileMaterial == tiletype_material::GRASS_DRY)) || ((grass_growth == GRASS_GROWTH_DEAD) && - (b->tileMaterial == tiletype_material::GRASS_DEAD)))) { + (src->tileMaterial == tiletype_material::GRASS_DEAD)))) { goto draw_subsprite; } @@ -764,16 +767,16 @@ void c_sprite::draw_world_offset(int x, int y, int z, Block * b, int tileoffset, sheetx = ((sheetindex+tileoffset+randoffset) % SHEET_OBJECTSWIDE) * spritewidth; sheety = ((sheetindex+tileoffset+randoffset) / SHEET_OBJECTSWIDE) * spriteheight; } else if(tilelayout == RAMPBOTTOMTILE) { - sheetx = SPRITEWIDTH * b->ramp.index; + sheetx = SPRITEWIDTH * src->ramp.index; sheety = ((TILEHEIGHT + FLOORHEIGHT + SPRITEHEIGHT) * (sheetindex+tileoffset+randoffset))+(TILEHEIGHT + FLOORHEIGHT); } else if(tilelayout == RAMPTOPTILE) { - sheetx = SPRITEWIDTH * b->ramp.index; + sheetx = SPRITEWIDTH * src->ramp.index; sheety = (TILEHEIGHT + FLOORHEIGHT + SPRITEHEIGHT) * (sheetindex+tileoffset+randoffset); } else { sheetx = ((sheetindex+tileoffset+randoffset) % SHEET_OBJECTSWIDE) * spritewidth; sheety = ((sheetindex+tileoffset+randoffset) / SHEET_OBJECTSWIDE) * spriteheight; } - ALLEGRO_COLOR shade_color = shadeAdventureMode(get_color(b), b->fog_of_war, b->designation.bits.outside); + ALLEGRO_COLOR shade_color = shadeAdventureMode(get_color(src), b->fog_of_war, b->designation.bits.outside); if(chop && ( halftile == HALFTILECHOP)) { if(fileindex < 0) { if(shade_color.a > 0.001f) @@ -895,7 +898,7 @@ void c_sprite::draw_world_offset(int x, int y, int z, Block * b, int tileoffset, draw_subsprite: if(!subsprites.empty()) { for(int i = 0; i < subsprites.size(); i++) { - subsprites.at(i).draw_world_offset(x, y, z, b, tileoffset, chop); + subsprites.at(i).draw_world_offset_src(x, y, z, tileoffset, b, src, chop); } } } diff --git a/SpriteObjects.h b/SpriteObjects.h index 4c60b8ea..fbc09b9b 100644 --- a/SpriteObjects.h +++ b/SpriteObjects.h @@ -1,152 +1,153 @@ -#pragma once - -#include "tinyxml.h" -#include "common.h" - -#define BLOCKTILE 0 -#define RAMPBOTTOMTILE 1 -#define RAMPTOPTILE 2 - -#define HALFTILECHOP 0 -#define HALFTILEYES 1 -#define HALFTILENO 2 -#define HALFTILEBOTH 3 - -#define OUTLINENONE 0 -#define OUTLINELEFT 1 -#define OUTLINERIGHT 2 -#define OUTLINEBOTTOM 3 - -#define LIGHTANY 0 -#define LIGHTYES 1 -#define LIGHTNO 2 - -enum grass_growth { - GRASS_GROWTH_ANY, - GRASS_GROWTH_NORMAL, - GRASS_GROWTH_DRY, - GRASS_GROWTH_DEAD -}; - - -class Block; - -class c_sprite -{ -private: - int32_t fileindex; - int32_t sheetindex; - uint8_t spritewidth; - uint8_t spriteheight; - int16_t offset_x; - int16_t offset_y; - int16_t offset_user_x; - int16_t offset_user_y; - uint8_t variations; - ShadeBy shadeBy; - std::vector subsprites; - ALLEGRO_COLOR shadecolor; - ALLEGRO_COLOR namedcolor; - char bodypart[128]; - char animframes; - - int snowmin; - int snowmax; - int bloodmin; - int bloodmax; - int mudmin; - int mudmax; - int grassmax; - int grassmin; - - int grasstype; - char grass_growth; - - unsigned int waterMin : 3; - unsigned int waterMax : 3; - unsigned int waterAboveMin : 3; - unsigned int waterAboveMax : 3; - unsigned int waterBelowMin : 3; - unsigned int waterBelowMax : 3; - unsigned int waterRightMin : 3; - unsigned int waterRightMax : 3; - unsigned int waterLeftMin : 3; - unsigned int waterLeftMax : 3; - char water_direction; - - bool needoutline; - bool randomanimation; - bool bloodsprite; - - unsigned char isoutline : 2; - - unsigned char halftile : 2; - - unsigned char light : 2; - - float spritescale; - - ALLEGRO_BITMAP * defaultsheet; - - uint8_t tilelayout; - - uint8_t openborders; - uint8_t wallborders; - uint8_t floorborders; - uint8_t rampborders; - uint8_t upstairborders; - uint8_t downstairborders; - uint8_t lightborders; - uint8_t darkborders; - uint8_t notopenborders; - uint8_t notwallborders; - uint8_t notfloorborders; - uint8_t notrampborders; - uint8_t notupstairborders; - uint8_t notdownstairborders; - - int itemtype; - int itemsubtype; -public: - c_sprite(void); - ~c_sprite(void); - //void draw_screen(int x, int y); - void draw_world(int x, int y, int z, Block * b, bool chop = false); - void draw_world_offset(int x, int y, int z, Block * b, int offset, bool chop = false); - void draw_world_ramp_bottom(int x, int y, int z, bool chop = false); - void set_by_xml(TiXmlElement* elemSprite, int32_t fileindex); - void set_by_xml(TiXmlElement* elemSprite); - int32_t get_sheetindex(void) { - return sheetindex; - } - int32_t get_animframes(void) { - return animframes; - } - char get_fileindex(void) { - return fileindex; - } - void set_sheetindex(int32_t in) { - sheetindex = in; - } - void set_fileindex(int32_t in) { - fileindex = in; - } - void set_animframes(char in) { - animframes = in; - } - void set_size(uint8_t x, uint8_t y); - void set_offset(int16_t x, int16_t y); - ALLEGRO_COLOR get_color(void * b); - ALLEGRO_BITMAP * get_defaultsprite(void) { - return defaultsheet; - } - void set_defaultsheet(ALLEGRO_BITMAP * in) { - defaultsheet = in; - } - void reset(); - void set_tile_layout(uint8_t layout); - void set_needoutline( bool i ) { - needoutline = i; - } - bool animate; +#pragma once + +#include "tinyxml.h" +#include "common.h" + +#define BLOCKTILE 0 +#define RAMPBOTTOMTILE 1 +#define RAMPTOPTILE 2 + +#define HALFTILECHOP 0 +#define HALFTILEYES 1 +#define HALFTILENO 2 +#define HALFTILEBOTH 3 + +#define OUTLINENONE 0 +#define OUTLINELEFT 1 +#define OUTLINERIGHT 2 +#define OUTLINEBOTTOM 3 + +#define LIGHTANY 0 +#define LIGHTYES 1 +#define LIGHTNO 2 + +enum grass_growth { + GRASS_GROWTH_ANY, + GRASS_GROWTH_NORMAL, + GRASS_GROWTH_DRY, + GRASS_GROWTH_DEAD +}; + + +class Block; + +class c_sprite +{ +private: + int32_t fileindex; + int32_t sheetindex; + uint8_t spritewidth; + uint8_t spriteheight; + int16_t offset_x; + int16_t offset_y; + int16_t offset_user_x; + int16_t offset_user_y; + uint8_t variations; + ShadeBy shadeBy; + std::vector subsprites; + ALLEGRO_COLOR shadecolor; + ALLEGRO_COLOR namedcolor; + char bodypart[128]; + char animframes; + + int snowmin; + int snowmax; + int bloodmin; + int bloodmax; + int mudmin; + int mudmax; + int grassmax; + int grassmin; + + int grasstype; + char grass_growth; + + unsigned int waterMin : 3; + unsigned int waterMax : 3; + unsigned int waterAboveMin : 3; + unsigned int waterAboveMax : 3; + unsigned int waterBelowMin : 3; + unsigned int waterBelowMax : 3; + unsigned int waterRightMin : 3; + unsigned int waterRightMax : 3; + unsigned int waterLeftMin : 3; + unsigned int waterLeftMax : 3; + char water_direction; + + bool needoutline; + bool randomanimation; + bool bloodsprite; + + unsigned char isoutline : 2; + + unsigned char halftile : 2; + + unsigned char light : 2; + + float spritescale; + + ALLEGRO_BITMAP * defaultsheet; + + uint8_t tilelayout; + + uint8_t openborders; + uint8_t wallborders; + uint8_t floorborders; + uint8_t rampborders; + uint8_t upstairborders; + uint8_t downstairborders; + uint8_t lightborders; + uint8_t darkborders; + uint8_t notopenborders; + uint8_t notwallborders; + uint8_t notfloorborders; + uint8_t notrampborders; + uint8_t notupstairborders; + uint8_t notdownstairborders; + + int itemtype; + int itemsubtype; +public: + c_sprite(void); + ~c_sprite(void); + //void draw_screen(int x, int y); + inline void draw_world(int x, int y, int z, Block * b, bool chop = false); + inline void draw_world_offset(int x, int y, int z, int tileoffset, Block * b, bool chop = false); + void draw_world_offset_src(int x, int y, int z, int tileoffset, Block * b, Block* src, bool chop = false); + void draw_world_ramp_bottom(int x, int y, int z, bool chop = false); + void set_by_xml(TiXmlElement* elemSprite, int32_t fileindex); + void set_by_xml(TiXmlElement* elemSprite); + int32_t get_sheetindex(void) { + return sheetindex; + } + int32_t get_animframes(void) { + return animframes; + } + char get_fileindex(void) { + return fileindex; + } + void set_sheetindex(int32_t in) { + sheetindex = in; + } + void set_fileindex(int32_t in) { + fileindex = in; + } + void set_animframes(char in) { + animframes = in; + } + void set_size(uint8_t x, uint8_t y); + void set_offset(int16_t x, int16_t y); + ALLEGRO_COLOR get_color(void * b); + ALLEGRO_BITMAP * get_defaultsprite(void) { + return defaultsheet; + } + void set_defaultsheet(ALLEGRO_BITMAP * in) { + defaultsheet = in; + } + void reset(); + void set_tile_layout(uint8_t layout); + void set_needoutline( bool i ) { + needoutline = i; + } + bool animate; }; \ No newline at end of file