Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
john314thegeekygenius committed Jul 6, 2022
1 parent afe067a commit 94d5588
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
25 changes: 20 additions & 5 deletions src/VKFM_Graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ int VK_MakeSpriteSheet(int sprstart, int sprend, std::string sprname){
spr_height = bmp_sprite.dib_head.bitmap_height;
}
}
uint32_t fsw = spr_width/2;
uint32_t fsh = spr_height;

for(int sprite_num = sprstart; sprite_num <= sprend; sprite_num++){
// make the file name
Expand Down Expand Up @@ -168,6 +170,7 @@ int VK_MakeSpriteSheet(int sprstart, int sprend, std::string sprname){
uint32_t cw = spr_width/2;
uint32_t ch = spr_height;


if(bmp_sprite.dib_head.bitmap_width<spr_width||bmp_sprite.dib_head.bitmap_height<spr_height){
std::cout << std::string("vkmgfx: ") <<
VK_SetConsoleColor(VK_CONSOLE_COLORS::PURPLE,VK_CONSOLE_COLORS::DEFAULT) <<
Expand All @@ -192,12 +195,24 @@ int VK_MakeSpriteSheet(int sprstart, int sprend, std::string sprname){
bmp_sprite.crop_bmp(bmp_sprite,0,0,cw,ch);
}

// Fix height
// Fix the size
int divch = ch/8;
int divcw = cw/8;
bool changedsize = false;
if((divch*8)<ch){
bmp_sprite.resize_bmp(bmp_sprite,cw,(divch*8)+8,0x10);
ch = (divch*8)+8;
changedsize = true;
fsh = ch;
}

if((divcw*8)<cw){
cw = (divcw*8)+8;
changedsize = true;
fsw = cw;
}
if(changedsize){
bmp_sprite.resize_bmp(bmp_sprite,cw,ch,0x10);
}

std::cout<< std::dec << cw << " x " << ch << std::endl;

sprite_sheet.stitch(bmp_sprite,place_x,0);
Expand All @@ -219,13 +234,13 @@ int VK_MakeSpriteSheet(int sprstart, int sprend, std::string sprname){

// Export the tileset
if((VKMake_Flags&static_cast<int>(VKFLAG::HD_SPRITES)) ){
bitmap_error = sprite_sheet.exportsprgb(VK_FileDirectory+"/graph/sheets/exports/"+sprname+".h",sprname,spr_width/2,spr_height);
bitmap_error = sprite_sheet.exportsprgb(VK_FileDirectory+"/graph/sheets/exports/"+sprname+".h",sprname,fsw,fsh);
if(bitmap_error!=VK_BMPERRORS::NO_ERROR){
std::cout << "Error saving header! Error code " << (int)bitmap_error << std::endl;
return 1;
}
}else{
bitmap_error = sprite_sheet.exportspr(VK_FileDirectory+"/graph/sheets/exports/"+sprname+".h",sprname,spr_width/2,spr_height);
bitmap_error = sprite_sheet.exportspr(VK_FileDirectory+"/graph/sheets/exports/"+sprname+".h",sprname,fsw,fsh);
if(bitmap_error!=VK_BMPERRORS::NO_ERROR){
std::cout << "Error saving header! Error code " << (int)bitmap_error << std::endl;
return 1;
Expand Down
15 changes: 10 additions & 5 deletions src/VKFM_Levels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,17 @@ int VK_LoadLevel(int level_id){
for(auto t : const_tiles){
if(VK_PartCompareString(t.name,"BACKGROUND")==0){
int addnew = 1;
for(auto c : VK_LevelTiles){
if(c == t.value) addnew = 0;
}
if(addnew){
VK_LevelTiles.push_back(t.value);
if(t.value==9999)
addnew = 0;
else{
for(auto c : VK_LevelTiles){
if(c == t.value) addnew = 0;
}
if(addnew){
VK_LevelTiles.push_back(t.value);
}
}
break;
}
}

Expand Down

0 comments on commit 94d5588

Please sign in to comment.