summaryrefslogtreecommitdiff
path: root/SpriteObjects.cpp
diff options
context:
space:
mode:
authorJapa Illo2012-02-13 22:59:56 +0530
committerJapa Illo2012-02-13 22:59:56 +0530
commitaa921e71bd1a551ced19d29051439e88d2330975 (patch)
tree4cf6797ead59fef54b004d2ef0aab1bcb198720c /SpriteObjects.cpp
parent78f13e7490e78098152af2c6771dc63b09808f46 (diff)
downloadstonesense-aa921e71bd1a551ced19d29051439e88d2330975.tar.gz
stonesense-aa921e71bd1a551ced19d29051439e88d2330975.tar.bz2
stonesense-aa921e71bd1a551ced19d29051439e88d2330975.tar.xz
Zoom and enhance!
Signed-off-by: Japa Illo <japa.mala.illo@gmail.com>
Diffstat (limited to 'SpriteObjects.cpp')
-rw-r--r--SpriteObjects.cpp70
1 files changed, 60 insertions, 10 deletions
diff --git a/SpriteObjects.cpp b/SpriteObjects.cpp
index 183e466..8001920 100644
--- a/SpriteObjects.cpp
+++ b/SpriteObjects.cpp
@@ -188,6 +188,7 @@ void c_sprite::reset(void)
randomanimation = 0;
animate = 1;
bloodsprite = 0;
+ spritescale=1.0f;
{
for(int i = 0; i < subsprites.size(); i++)
{
@@ -232,6 +233,13 @@ void c_sprite::set_by_xml(TiXmlElement *elemSprite)
{
randomanimation=atoi(animoffStr);
}
+ const char* scaleStr;
+ scaleStr = elemSprite->Attribute("zoom");
+ if (scaleStr != NULL && scaleStr[0] != 0)
+ {
+ int scalev=atoi(scaleStr);
+ spritescale=pow(2.0f,(float)scalev);
+ }
//load files, if any
const char* filename = elemSprite->Attribute("file");
if (filename != NULL && filename[0] != 0)
@@ -544,14 +552,14 @@ void c_sprite::draw_screen(int x, int y)
if(config.block_count)
config.drawcount ++;
- al_draw_bitmap_region(IMGObjectSheet, sheetx * spritewidth, sheety * spriteheight, spritewidth, spriteheight, x + offset_x, y + offset_y, 0);
+ al_draw_bitmap_region(IMGObjectSheet, sheetx * spritewidth * spritescale, sheety * spriteheight * spritescale, spritewidth * spritescale, spriteheight * spritescale, x + offset_x, y + offset_y, 0);
}
else
{
if(config.block_count)
config.drawcount ++;
- al_draw_bitmap_region(getImgFile(fileindex), sheetx * spritewidth, sheety * spriteheight, spritewidth, spriteheight, x + offset_x, y + (offset_y - WALLHEIGHT), 0);
+ al_draw_bitmap_region(getImgFile(fileindex), sheetx * spritewidth * spritescale, sheety * spriteheight * spritescale, spritewidth * spritescale, spriteheight * spritescale, x + offset_x, y + (offset_y - WALLHEIGHT * spritescale), 0);
}
if(!subsprites.empty())
{
@@ -692,13 +700,13 @@ void c_sprite::draw_world_offset(int x, int y, int z, Block * b, int tileoffset,
}
else if(tilelayout == RAMPBOTTOMTILE)
{
- sheetx = sheetx = SPRITEWIDTH * b->ramp.index;
- sheety = sheety = ((TILEHEIGHT + FLOORHEIGHT + SPRITEHEIGHT) * (sheetindex+tileoffset+randoffset))+(TILEHEIGHT + FLOORHEIGHT);
+ sheetx = SPRITEWIDTH * b->ramp.index;
+ 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);
+ sheetx = SPRITEWIDTH * b->ramp.index;
+ sheety = (TILEHEIGHT + FLOORHEIGHT + SPRITEHEIGHT) * (sheetindex+tileoffset+randoffset);
}
else
{
@@ -718,14 +726,35 @@ void c_sprite::draw_world_offset(int x, int y, int z, Block * b, int tileoffset,
{
if(config.block_count)
config.drawcount ++;
- al_draw_tinted_scaled_bitmap(defaultsheet, premultiply(shade_color), sheetx, sheety+WALL_CUTOFF_HEIGHT, spritewidth, spriteheight-WALL_CUTOFF_HEIGHT, drawx + (offset_x + offset_user_x)*config.scale, drawy + (offset_user_y + (offset_y - WALLHEIGHT)+WALL_CUTOFF_HEIGHT)*config.scale, spritewidth*config.scale, (spriteheight-WALL_CUTOFF_HEIGHT)*config.scale, 0);
+ al_draw_tinted_scaled_bitmap(
+ defaultsheet, premultiply(shade_color),
+ sheetx * spritescale,
+ (sheety+WALL_CUTOFF_HEIGHT) * spritescale,
+ spritewidth * spritescale,
+ (spriteheight-WALL_CUTOFF_HEIGHT) * spritescale,
+ drawx + (offset_x + offset_user_x)*config.scale,
+ drawy + (offset_user_y + (offset_y - WALLHEIGHT)+WALL_CUTOFF_HEIGHT)*config.scale,
+ spritewidth*config.scale,
+ (spriteheight-WALL_CUTOFF_HEIGHT)*config.scale,
+ 0);
}
else
{
if(config.block_count)
config.drawcount ++;
- al_draw_tinted_scaled_bitmap(getImgFile(fileindex), premultiply(shade_color), sheetx, (sheety)+WALL_CUTOFF_HEIGHT, spritewidth, spriteheight-WALL_CUTOFF_HEIGHT, drawx + (offset_x + offset_user_x)*config.scale, drawy + (offset_user_y + (offset_y - WALLHEIGHT)+WALL_CUTOFF_HEIGHT)*config.scale, spritewidth*config.scale, (spriteheight-WALL_CUTOFF_HEIGHT)*config.scale, 0);
+ al_draw_tinted_scaled_bitmap(
+ getImgFile(fileindex),
+ premultiply(shade_color),
+ sheetx * spritescale,
+ (sheety+WALL_CUTOFF_HEIGHT) * spritescale,
+ spritewidth * spritescale,
+ (spriteheight-WALL_CUTOFF_HEIGHT) * spritescale,
+ drawx + (offset_x + offset_user_x)*config.scale,
+ drawy + (offset_user_y + (offset_y - WALLHEIGHT)+WALL_CUTOFF_HEIGHT)*config.scale,
+ spritewidth*config.scale,
+ (spriteheight-WALL_CUTOFF_HEIGHT)*config.scale,
+ 0);
}
//draw cut-off floor thing
if(config.block_count)
@@ -746,14 +775,35 @@ void c_sprite::draw_world_offset(int x, int y, int z, Block * b, int tileoffset,
if(config.block_count)
config.drawcount ++;
- al_draw_tinted_scaled_bitmap(defaultsheet, premultiply(shade_color), sheetx, sheety, spritewidth, spriteheight, drawx + (offset_x + offset_user_x)*config.scale, drawy + (offset_user_y + (offset_y - WALLHEIGHT))*config.scale,spritewidth*config.scale, spriteheight*config.scale, 0);
+ al_draw_tinted_scaled_bitmap(
+ defaultsheet, premultiply(shade_color),
+ sheetx * spritescale,
+ sheety * spritescale,
+ spritewidth * spritescale,
+ spriteheight * spritescale,
+ drawx + (offset_x + offset_user_x)*config.scale,
+ drawy + (offset_user_y + (offset_y - WALLHEIGHT))*config.scale,
+ spritewidth*config.scale,
+ spriteheight*config.scale,
+ 0);
}
else
{
if(config.block_count)
config.drawcount ++;
- al_draw_tinted_scaled_bitmap(getImgFile(fileindex), premultiply(shade_color), sheetx, sheety, spritewidth, spriteheight, drawx + (offset_x + offset_user_x)*config.scale, drawy + (offset_user_y + (offset_y - WALLHEIGHT))*config.scale,spritewidth*config.scale, spriteheight*config.scale, 0);
+ al_draw_tinted_scaled_bitmap(
+ getImgFile(fileindex),
+ premultiply(shade_color),
+ sheetx * spritescale,
+ sheety * spritescale,
+ spritewidth * spritescale,
+ spriteheight * spritescale,
+ drawx + (offset_x + offset_user_x)*config.scale,
+ drawy + (offset_user_y + (offset_y - WALLHEIGHT))*config.scale,
+ spritewidth*config.scale,
+ spriteheight*config.scale,
+ 0);
}
}
if(needoutline)