generated from AMay/CPlusPlusProjectTemplate
Modified cohesion feature in PGE header
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
bf1a0fbf17
commit
f717f7ef09
Binary file not shown.
6
main.cpp
6
main.cpp
@ -63,7 +63,7 @@ int MAP_WIDTH=-1;
|
||||
int MAP_HEIGHT=-1;
|
||||
Map*CURRENT_MAP=nullptr;
|
||||
std::map<MapName::Map,Map*> MAPS;
|
||||
int GAME_STATE=GameState::TEST_BOX;
|
||||
int GAME_STATE=GameState::FILE_LOAD_SELECT;
|
||||
vi2d SELECTED_TILE={0,0};
|
||||
vi2d HIGHLIGHTED_TILE={0,0};
|
||||
int EDITING_LAYER=layer::DYNAMIC;
|
||||
@ -2993,7 +2993,7 @@ void SeasonI::drawGame(){
|
||||
DrawLineDecal({1,0},{(float)ScreenWidth(),(float)ScreenHeight()-1},DARK_RED);
|
||||
DrawLineDecal({1,(float)ScreenHeight()-1},{(float)ScreenWidth(),0},DARK_RED);
|
||||
DrawDecal({32,32},SPRITES["additionalFont.png"],{1,1},BLACK);
|
||||
DrawStringDecal({16,(float)ScreenHeight()-24},"Screen Pixel Size: ("+std::to_string(GetScreenPixelSize().x)+","+std::to_string(GetScreenPixelSize().y)+")",VERY_DARK_GREEN);
|
||||
DrawStringDecal({16,(float)ScreenHeight()-24},"Screen Pixel\nSize: ("+std::to_string(GetScreenPixelSize().x)+","+std::to_string(GetScreenPixelSize().y)+")",VERY_DARK_GREEN);
|
||||
}break;
|
||||
case GameState::SHOPKEEPER_MENU:{
|
||||
DrawGameWorld();
|
||||
@ -5693,7 +5693,7 @@ void SeasonI::SetupGameDrawing(){
|
||||
int main()
|
||||
{
|
||||
SeasonI demo;
|
||||
if (demo.Construct(WIDTH, HEIGHT, 1, 1,false,false,true))
|
||||
if (demo.Construct(WIDTH, HEIGHT, 4, 4,false,false,true))
|
||||
demo.Start();
|
||||
|
||||
return 0;
|
||||
|
||||
@ -3337,7 +3337,11 @@ namespace olc
|
||||
|
||||
void PixelGameEngine::OnTextEntryComplete(const std::string& sText) { UNUSED(sText); }
|
||||
bool PixelGameEngine::OnConsoleCommand(const std::string& sCommand) { UNUSED(sCommand); return false; }
|
||||
|
||||
// Recursive function to return gcd of a and b in single line
|
||||
int gcd(int a, int b)
|
||||
{
|
||||
return b == 0 ? a : gcd(b, a % b);
|
||||
}
|
||||
|
||||
// Externalised API
|
||||
void PixelGameEngine::olc_UpdateViewport()
|
||||
@ -3348,18 +3352,19 @@ namespace olc
|
||||
|
||||
if (bPixelCohesion)
|
||||
{
|
||||
int32_t xmult = vWindowSize.x / vScreenSize.x;
|
||||
vViewSize.x = (vWindowSize.x / vScreenSize.x) * vScreenSize.x;
|
||||
vViewSize.y = vScreenSize.y*xmult;
|
||||
vScreenPixelSize.x = vWindowSize.x / vScreenSize.x;
|
||||
vScreenPixelSize.y = vScreenPixelSize.x;
|
||||
int baseFactor = gcd(vPixelSize.x,vPixelSize.y);
|
||||
int bw = vScreenSize.x*vPixelSize.x/baseFactor;
|
||||
int bh = vScreenSize.y*vPixelSize.y/baseFactor;
|
||||
|
||||
if (vWindowSize.x / vScreenSize.x > vWindowSize.y / vScreenSize.y) {
|
||||
int32_t ymult = vWindowSize.y / vScreenSize.y;
|
||||
vViewSize.y = (vWindowSize.y / vScreenSize.y) * vScreenSize.y;
|
||||
vViewSize.x = vScreenSize.x*ymult;
|
||||
vScreenPixelSize.y = vWindowSize.y / vScreenSize.y;
|
||||
vScreenPixelSize.x = vScreenPixelSize.y;
|
||||
int32_t xmult = vWindowSize.x / bw;
|
||||
vViewSize.x = (vWindowSize.x / bw) * bw;
|
||||
vViewSize.y = bh*xmult;
|
||||
vScreenPixelSize = vPixelSize*xmult/baseFactor;
|
||||
if (vWindowSize.x / bw > vWindowSize.y / bh) {
|
||||
int32_t ymult = vWindowSize.y / bh;
|
||||
vViewSize.y = (vWindowSize.y / bh) * bh;
|
||||
vViewSize.x = bw*ymult;
|
||||
vScreenPixelSize = vPixelSize*ymult/baseFactor;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user