From 3be7eb6653e8dc538695e96728e33fc908d32df4 Mon Sep 17 00:00:00 2001 From: julesgrc0 Date: Sun, 18 Feb 2024 22:40:47 +0100 Subject: [PATCH] new version --- CMakeLists.txt | 2 +- android/app/build.gradle.kts | 2 +- src/core/view.c | 4 ++-- src/entities/player.c | 4 ++-- src/gui/button.c | 2 +- src/screen/loading.c | 12 +++++++----- src/screen/menu.c | 12 ++++++------ src/terrain/chunk_view.c | 2 +- 8 files changed, 21 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 11f315f..510028a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.8) -project("wispy" VERSION 0.0.4 LANGUAGES C) +project("wispy" VERSION 0.0.5 LANGUAGES C) set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD_REQUIRED ON) diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index d966fad..e3253f9 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -11,7 +11,7 @@ android { minSdk = 19 targetSdk = 34 versionCode = 1 - versionName = "alpha-0.0.4" + versionName = "alpha-0.0.5" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } diff --git a/src/core/view.c b/src/core/view.c index b59dc89..c9d3cd7 100644 --- a/src/core/view.c +++ b/src/core/view.c @@ -41,7 +41,7 @@ Vector2 get_mouse_block_center(Camera2D *camera) { Vector2 vec_block_round(Vector2 vec) { return (Vector2){ - .x = round(vec.x / CUBE_W) * CUBE_W, - .y = round(vec.y / CUBE_H) * CUBE_H, + .x = round(vec.x / (float)CUBE_W) * (float)CUBE_W, + .y = round(vec.y / (float)CUBE_H) * (float)CUBE_H, }; } diff --git a/src/entities/player.c b/src/entities/player.c index 651ab14..a1acecb 100644 --- a/src/entities/player.c +++ b/src/entities/player.c @@ -29,7 +29,7 @@ void destroy_player(w_player *player) { void animate_player(w_player *player, bool should_walk) { player->animation += PHYSICS_TICK; - if (should_walk || abs(player->velocity.x) > 0) { + if (should_walk || fabsf(player->velocity.x) > 0) { if (player->animation > PHYSICS_TICK * PLAYER_ANIMATION_WALK) { player->animation = 0; player->state = (player->state == P_WALK_1) ? P_WALK_2 : P_WALK_1; @@ -52,7 +52,7 @@ void update_player_input(w_player *player, w_keyboard *keyboard) { player->jump = player->duration > 0 ? PJ_JUMP : PJ_FALL; player->velocity.y -= (MAX_PLAYER_VELOCITY_Y / 2.F * player->duration); if (player->duration <= 0) { - player->delay = (1 / PHYSICS_TICK) * 0.15; + player->delay = (1 / PHYSICS_TICK) * 0.15f; } } diff --git a/src/gui/button.c b/src/gui/button.c index ce7fccd..f59d111 100644 --- a/src/gui/button.c +++ b/src/gui/button.c @@ -8,7 +8,7 @@ w_guibutton *create_button(w_guicontext *ctx, Vector2 position, Color color, button->ctx = ctx; button->default_color = color; - button->hover_color = Fade(color, 0.8); + button->hover_color = Fade(color, 0.8f); button->text = text; button->size = (Vector2){ .x = MeasureText(text, ctx->font_size), diff --git a/src/screen/loading.c b/src/screen/loading.c index 084a7cb..368324a 100644 --- a/src/screen/loading.c +++ b/src/screen/loading.c @@ -39,12 +39,12 @@ void load_assets(w_state *state) { state->textures_id[state->textures_len] = items[i].name; state->textures_len++; } else if (strcmp(ext, ".ttf") == 0) { - int fontSize = 72; - char fontChars[73] = + const int fontsize = 72; + char codepoints[73] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789()?:+-" "=*\"'"; state->font = LoadFontFromMemory(".ttf", items[i].buffer, items[i].size, - fontSize, fontChars, 73); + fontsize, (int*)codepoints, 73); sfree(items[i].name); } else if (strcmp(ext, ".vs") == 0 || strcmp(ext, ".fs") == 0) { @@ -90,6 +90,8 @@ void loading_screen(w_state *state) { const char *loading_text = "Loading..."; const char *error_text = "Failed to load resources !"; + // TODO: use gui label + Vector2 loading_pos = { .x = (GetScreenWidth() - MeasureText(loading_text, text_size)) / 2.f, .y = (GetScreenHeight() - text_size) / 2.f}; @@ -103,7 +105,7 @@ void loading_screen(w_state *state) { case FS_DISPLAY: { BeginDrawing(); ClearBackground(BLACK); - DrawText(loading_text, loading_pos.x, loading_pos.y, text_size, WHITE); + DrawText(loading_text, (int)loading_pos.x, (int)loading_pos.y, text_size, WHITE); EndDrawing(); state->state = FS_LOAD; } break; @@ -113,7 +115,7 @@ void loading_screen(w_state *state) { case FS_FAILED: { BeginDrawing(); ClearBackground(BLACK); - DrawText(error_text, error_pos.x, error_pos.y, text_size, RED); + DrawText(error_text, (int)error_pos.x, (int)error_pos.y, text_size, RED); EndDrawing(); } break; case FS_OK: diff --git a/src/screen/menu.c b/src/screen/menu.c index 3eba8ea..3c75f7c 100644 --- a/src/screen/menu.c +++ b/src/screen/menu.c @@ -23,13 +23,13 @@ void menu_screen(w_state *state) { .y = CHUNK_MID_H * CUBE_H}; w_guicontext *ctx = - create_gui((Vector2){GetRenderWidth(), GetRenderHeight()}); + create_gui((Vector2){(float)GetRenderWidth(), (float)GetRenderHeight()}); ctx->font_size = 25; ctx->margin_height = 10; ctx->margin_width = 40; w_guibutton *play_button = create_button( - ctx, percent_to_pixel(ctx, (Vector2){0.5, 0.45}), WHITE, "Play"); + ctx, percent_to_pixel(ctx, (Vector2){0.5f, 0.45f}), WHITE, "Play"); w_guibutton *setting_button = create_button(ctx, (Vector2){ @@ -49,7 +49,7 @@ void menu_screen(w_state *state) { WHITE, "Exit"); w_guitext *title_text = create_text( - ctx, percent_to_pixel(ctx, (Vector2){0.5, 0.2}), "Wispy", 120, WHITE); + ctx, percent_to_pixel(ctx, (Vector2){0.5f, 0.2f}), "Wispy", 120, WHITE); center_text(title_text, true, true); w_guitext *credit_text = create_text( @@ -65,8 +65,8 @@ void menu_screen(w_state *state) { angle += speed; angle = fmod(angle, 360.0); - camera.target.x += (sin(angle) * 1000.0) * speed; - camera.target.y += (cos(angle) * 1000.0) * speed; + camera.target.x += (float)((sin(angle) * 1000.0) * speed); + camera.target.y += (float)((cos(angle) * 1000.0) * speed); update_chunkview(view, grp, get_camera_view(&camera)); update_chunkview_lighting( @@ -97,7 +97,7 @@ void menu_screen(w_state *state) { DrawRectangleLinesEx( (Rectangle){0, 0, ctx->render_size.x, ctx->render_size.y}, 5, - Fade(BLACK, 0.9)); + Fade(BLACK, 0.9f)); if (update_button(play_button)) { is_active = false; diff --git a/src/terrain/chunk_view.c b/src/terrain/chunk_view.c index 804ba9c..d727ecc 100644 --- a/src/terrain/chunk_view.c +++ b/src/terrain/chunk_view.c @@ -71,7 +71,7 @@ bool update_chunkview(w_chunkview *chunk_view, w_chunkgroup *grp, return true; } - unsigned int position = floor(view.x / FULL_CHUNK_W); + unsigned int position = floorf(view.x / FULL_CHUNK_W); if (position != chunk_view->target->position) { int group_move = need_chunkgroup_update(grp, position); if (group_move > 0) {