WIP Resolution agnosticism

This commit is contained in:
Dusk 2022-07-07 16:49:15 +02:00
parent 3cca4ced3f
commit 0fdf0accb2
2 changed files with 16 additions and 5 deletions

View File

@ -32,11 +32,12 @@ rotate_right_action: bool = false,
rotate_left_action: bool = false,
pub fn init(_renderer: *SDL.SDL_Renderer) Self {
var ret = Self{
.grid = Grid.init(),
.grid_cell_size = 16,
.grid_pos_x = 200,
.grid_pos_y = -50,
.grid_cell_size = undefined,
.grid_pos_x = undefined,
.grid_pos_y = undefined,
.bag = Bag.init(),
.piece = undefined,
@ -44,6 +45,16 @@ pub fn init(_renderer: *SDL.SDL_Renderer) Self {
.held = null,
.renderer = _renderer,
};
var aux_w: i32 = undefined;
var aux_h: i32 = undefined;
_ = SDL.SDL_GetRendererOutputSize(_renderer, &aux_w, &aux_h);
ret.grid_cell_size = @divFloor(@minimum(aux_w, aux_h), 32);
ret.grid_pos_x = @divFloor(aux_w, 2) - (ret.grid_cell_size * @divFloor(Grid.ncolumns, 2));
ret.grid_pos_y = @divFloor(aux_h, 2) - (ret.grid_cell_size * @divFloor(Grid.nrows + Grid.buffer, 2));
ret.piece = ret.bag.pop();
// ret.shadow = movement.shadow(ret.grid, ret.piece);
// ret.shadow.color.a /= 2;

View File

@ -18,8 +18,8 @@ pub fn main() !void {
"USG",
SDL.SDL_WINDOWPOS_CENTERED,
SDL.SDL_WINDOWPOS_CENTERED,
640,
480,
1280,
720,
SDL.SDL_WINDOW_SHOWN,
) orelse return;
defer _ = SDL.SDL_DestroyWindow(window);