Skip to content

Commit

Permalink
new version
Browse files Browse the repository at this point in the history
  • Loading branch information
julesgrc0 committed Feb 18, 2024
1 parent 069d82b commit 3be7eb6
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}
4 changes: 2 additions & 2 deletions src/entities/player.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/button.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
12 changes: 7 additions & 5 deletions src/screen/loading.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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};
Expand All @@ -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;
Expand All @@ -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:
Expand Down
12 changes: 6 additions & 6 deletions src/screen/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand All @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/terrain/chunk_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 3be7eb6

Please sign in to comment.