|
|
|
@ -570,7 +570,7 @@ void Crawler::RenderTile(TileRenderData&tileSheet,Pixel col){ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Crawler::RenderWorld(float fElapsedTime){ |
|
|
|
|
Clear(BLANK); |
|
|
|
|
|
|
|
|
|
LayerTag*bridgeLayer=nullptr; |
|
|
|
|
bool bridgeLayerFade=false; |
|
|
|
|
Player*pl=GetPlayer(); |
|
|
|
@ -623,6 +623,10 @@ void Crawler::RenderWorld(float fElapsedTime){ |
|
|
|
|
} |
|
|
|
|
SetDecalMode(DecalMode::NORMAL); |
|
|
|
|
} |
|
|
|
|
if(GetCurrentMap().optimized){ |
|
|
|
|
view.FillRectDecal(-WINDOW_SIZE,vf2d{float(GetCurrentMap().width),float(GetCurrentMap().height)}*GetCurrentMap().tilewidth+WINDOW_SIZE*2,{100,180,100}); |
|
|
|
|
view.DrawDecal({0,0},MAP_DATA[GetCurrentLevel()].optimizedTile->Decal()); |
|
|
|
|
}else{ |
|
|
|
|
for (int x = view.GetTopLeftTile().x/GetCurrentMap().tilewidth-1; x <= view.GetBottomRightTile().x/GetCurrentMap().tilewidth; x++){ |
|
|
|
|
for (int y = view.GetTopLeftTile().y/GetCurrentMap().tilewidth-1; y <= view.GetBottomRightTile().y/GetCurrentMap().tilewidth; y++){ |
|
|
|
|
if(x>=0&&x<GetCurrentMap().width&&y>=0&&y<GetCurrentMap().height){ |
|
|
|
@ -701,6 +705,7 @@ void Crawler::RenderWorld(float fElapsedTime){ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(bridgeLayerFade){ |
|
|
|
|
bridgeFadeFactor=std::min(bridgeFadeFactor+fElapsedTime,TileGroup::FADE_TIME); |
|
|
|
|
}else{ |
|
|
|
@ -1147,6 +1152,38 @@ void Crawler::InitializeLevel(std::string mapFile,MapName map){ |
|
|
|
|
r->Load("assets/maps/"+tileset.GetData().ImageData.data["source"]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(MAP_DATA[map].MapData.optimized){ |
|
|
|
|
std::cout<<"Generating optimized map for Map "<<map<<std::endl; |
|
|
|
|
MAP_DATA[map].optimizedTile=new Renderable(); |
|
|
|
|
MAP_DATA[map].optimizedTile->Create(MAP_DATA[map].MapData.width*MAP_DATA[map].MapData.tilewidth,MAP_DATA[map].MapData.height*MAP_DATA[map].MapData.tileheight); |
|
|
|
|
SetDrawTarget(MAP_DATA[map].optimizedTile->Sprite()); |
|
|
|
|
Pixel::Mode prevMode=GetPixelMode(); |
|
|
|
|
SetPixelMode(Pixel::Mode::MASK); |
|
|
|
|
Clear(BLANK); |
|
|
|
|
for(int y=0;y<MAP_DATA[map].MapData.height;y++){ |
|
|
|
|
for(int x=0;x<MAP_DATA[map].MapData.width;x++){ |
|
|
|
|
for(auto&layer:MAP_DATA[map].LayerData){ |
|
|
|
|
int tileID=layer.tiles[y][x]-1; |
|
|
|
|
if(tileID!=-1){ |
|
|
|
|
TilesheetData tileSheet=GetTileSheet(map,tileID); |
|
|
|
|
int tileSheetWidth=tileSheet.tileset->tileset->Sprite()->width/tileSheet.tileset->tilewidth; |
|
|
|
|
int tileSheetHeight=tileSheet.tileset->tileset->Sprite()->height/tileSheet.tileset->tileheight; |
|
|
|
|
int tileSheetIndex=tileID-(tileSheet.firstgid-1); |
|
|
|
|
int tileSheetX=tileSheetIndex%tileSheetWidth; |
|
|
|
|
int tileSheetY=tileSheetIndex/tileSheetWidth; |
|
|
|
|
vi2d pos=vi2d{x,y}*tileSheet.tileset->tilewidth; |
|
|
|
|
DrawPartialSprite(pos,tileSheet.tileset->tileset->Sprite(),vi2d{tileSheetX,tileSheetY}*tileSheet.tileset->tilewidth,{tileSheet.tileset->tilewidth,tileSheet.tileset->tileheight}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
SetPixelMode(prevMode); |
|
|
|
|
MAP_DATA[map].optimizedTile->Decal()->Update(); |
|
|
|
|
SetDrawTarget(nullptr); |
|
|
|
|
std::cout<<" Clearing Layer Data..."<<std::endl; |
|
|
|
|
MAP_DATA[map].LayerData.clear(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Crawler::LoadLevel(MapName map){ |
|
|
|
@ -1557,6 +1594,11 @@ bool Crawler::IsReflectiveTile(TilesheetData tileSheet,int tileID){ |
|
|
|
|
|
|
|
|
|
bool Crawler::OnUserDestroy(){ |
|
|
|
|
GFX.Reset(); |
|
|
|
|
for(auto&data:MAP_DATA){ |
|
|
|
|
if(MAP_DATA[data.first].optimizedTile!=nullptr){ |
|
|
|
|
delete MAP_DATA[data.first].optimizedTile; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|