Sun, 27 Jul 2025 23:44:14 +0200
first idea of what the main scene could look like
src/Makefile | file | annotate | diff | comparison | revisions | |
test/snake/snake.c | file | annotate | diff | comparison | revisions |
--- a/src/Makefile Sun Jul 27 23:34:19 2025 +0200 +++ b/src/Makefile Sun Jul 27 23:44:14 2025 +0200 @@ -49,8 +49,7 @@ $(BUILD_DIR)/2d.o: 2d.c ascension/2d.h ascension/scene_node.h \ ascension/datatypes.h ascension/transform.h ascension/mesh.h \ - ascension/constants.h ascension/error.h ascension/shader.h \ - ascension/camera.h + ascension/constants.h ascension/shader.h ascension/camera.h @echo "Compiling $<" $(CC) -o $@ $(CFLAGS) -c $<
--- a/test/snake/snake.c Sun Jul 27 23:34:19 2025 +0200 +++ b/test/snake/snake.c Sun Jul 27 23:44:14 2025 +0200 @@ -230,6 +230,18 @@ } static asc_rect update_viewport_for_window_resize(asc_vec2u window_size) { + + // TODO: special case: window is SO small that nothing would be rendered + + // remove margins + const unsigned margin = 10; + window_size.width -= 2*margin; + window_size.height -= 2*margin; + + // remove space for score, power-ups, etc. + const unsigned left_area = (unsigned) (asc_active_window->ui_scale*200); + window_size.width -= left_area; + // Compute scaling and offsets unsigned viewport_size, offset_x = 0, offset_y = 0; if (window_size.width > window_size.height) { @@ -241,6 +253,8 @@ offset_y = (window_size.height - window_size.width) / 2; viewport_size = window_size.width; } + offset_x += left_area + margin; + offset_y += margin; // Set the viewport to the scaled and centered region return ASC_RECT(offset_x, offset_y, viewport_size, viewport_size); @@ -261,7 +275,8 @@ AscWindowSettings settings; asc_window_settings_init_defaults(&settings); settings.title = "Snake"; - settings.dimensions = ASC_VEC2U(800, 800); + settings.dimensions = ASC_VEC2U(900, 600); + // TODO: resize window depending on ui scale factor asc_window_initialize(0, &settings); asc_ui_scale_auto();