Skip to content

Commit

Permalink
Multi monitor fix and background reco from @strager.
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan McQuen <rpcm@linux.com>
  • Loading branch information
ryanpcmcquen committed Aug 26, 2020
1 parent a79fb6c commit 60bb2c2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
6 changes: 3 additions & 3 deletions line_count.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
cloc|github.com/AlDanial/cloc v 1.86 T=0.13 s (53.1 files/s, 10600.9 lines/s)
cloc|github.com/AlDanial/cloc v 1.82 T=0.02 s (328.9 files/s, 65876.7 lines/s)
--- | ---

Language|files|blank|comment|code
:-------|-------:|-------:|-------:|-------:
C/C++ Header|6|252|143|982
C/C++ Header|6|256|144|982
C|1|6|0|14
--------|--------|--------|--------|--------
SUM:|7|258|143|996
SUM:|7|262|144|996
3 changes: 3 additions & 0 deletions source/initialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ int init()
SDL_Log("Detected resolution: %ix%i\n", display_mode.w, display_mode.h);
}

// Fix for multi-montior setups:
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, 0);

app.window = SDL_CreateWindow(GAME_TITLE, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, (int)SCREEN_WIDTH, (int)SCREEN_HEIGHT, SDL_WINDOW_RESIZABLE);
// SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_RESIZABLE);

Expand Down
26 changes: 14 additions & 12 deletions source/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,20 @@ void generate_map(App* app, Game* game)
{
Axes background;

int initial_background_x;
int initial_background_y;

if (strcmp(game->map.layout_file, MAP_LIBRARY_FILE) == 0) {
background.x = game->player.global.x - game->player.window.x;
background.y = game->player.global.y - game->player.window.y;
initial_background_x = game->player.global.x - game->player.window.x;
initial_background_y = game->player.global.y - game->player.window.y;
} else {
background.x = 0, background.y = 0;
initial_background_x = 0;
initial_background_y = 0;
}

background.x = initial_background_x;
background.y = initial_background_y;

char last_char = ',';
int current_row = 0, current_column = 0;

Expand Down Expand Up @@ -281,11 +288,8 @@ void generate_map(App* app, Game* game)
// Record row data to be used for the map editor:
game->map.columns_in_row[current_row] = current_column;

if (strcmp(game->map.layout_file, MAP_LIBRARY_FILE) == 0) {
background.x = game->player.global.x - game->player.window.x;
} else {
background.x = 0;
}
background.x = initial_background_x;

current_column = 0;

// Y axis increases!
Expand Down Expand Up @@ -366,8 +370,6 @@ void generate_map(App* app, Game* game)
}

// Reset positioning when the library is loaded so it appears in the upper left of the viewport.
if (strcmp(game->map.layout_file, MAP_LIBRARY_FILE) == 0) {
background.x = game->player.global.x - game->player.window.x;
background.y = game->player.global.y - game->player.window.y;
}
background.x = initial_background_x;
background.y = initial_background_y;
}

0 comments on commit 60bb2c2

Please sign in to comment.