Skip to content

Commit

Permalink
update menu view layout + gradle version
Browse files Browse the repository at this point in the history
  • Loading branch information
julesgrc0 committed May 27, 2024
1 parent d9a318a commit dc75d0e
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 36 deletions.
18 changes: 18 additions & 0 deletions android/.idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version "8.3.0" apply false
id("com.android.application") version "8.4.1" apply false
}
4 changes: 2 additions & 2 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Feb 29 22:26:39 CET 2024
#Mon May 27 19:56:43 CEST 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-rc-2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-rc-2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 0 additions & 2 deletions src/core/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ w_config *load_config() {
cfg->break_position = VEC(RENDER_W - PERCENT_W(0.05), PERCENT_H(0.75));
cfg->jump_position = VEC(PERCENT_W(0.85), RENDER_H - PERCENT_H(0.05));

cfg->place_position = {0};
cfg->inventory_position = {0};
#endif

#if defined(WISPY_ANDROID)
Expand Down
6 changes: 3 additions & 3 deletions src/screens/game/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ void game_screen(w_state *state) {
}

w_guijoystick *js = create_joystick(
ctx, state->config->joysitck_position, PERCENT_W(0.1));
ctx, state->config->joystick_position, PERCENT_W(0.1));
if (js == NULL) {
destroy_bridge(td);
destroy_blockbreaker(bb);
destroy_gui(ctx);
return;
}

w_guiiconbutton *break_button = create_iconbutton(ctx, cfg->break_position,
w_guiiconbutton *break_button = create_iconbutton(ctx, state->config->break_position,
PERCENT_W(0.05), break_icon);
if (break_button == NULL) {
destroy_bridge(td);
Expand All @@ -57,7 +57,7 @@ void game_screen(w_state *state) {
return;
}

w_guiiconbutton *jump_button = create_iconbutton(ctx, cfg->jump_position,
w_guiiconbutton *jump_button = create_iconbutton(ctx, state->config->jump_position,
PERCENT_W(0.05), player_textures[3]);
if (jump_button == NULL) {
destroy_bridge(td);
Expand Down
32 changes: 17 additions & 15 deletions src/screens/menu/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,30 @@ void menu_screen(w_state *state) {
w_menu_view *current_view = home_view;
w_menu_state view_state = MENU_STATE_HOME;

/// TODO: pre-render to a texture
unsigned int cubes[RENDER_CUBE_COUNT * RENDER_CUBE_COUNT] = {0};
RenderTexture background = LoadRenderTexture(RENDER_W, RENDER_H);

BeginTextureMode(background);
ClearBackground(BLACK);
DrawRectangleGradientV(0, 0, RENDER_W, RENDER_H, (Color){66, 135, 245, 255},
(Color){142, 184, 250, 255});

for (unsigned int y = 0; y < RENDER_CUBE_COUNT; y++) {
for (unsigned int x = 0; x < RENDER_CUBE_COUNT; x++) {
/// TODO: fix sin wave
cubes[x + y * RENDER_CUBE_COUNT] = (int)(sin(x / 100.0f) * 1.5f + 1.5f);
unsigned int block_id = (int)(sin(x / 100.0f) * 1.5f + 1.5f);
DrawTexturePro(block_textures[block_id], CUBE_SRC_RECT,
RECT((float)x * CUBE_W, (float)y * CUBE_H, CUBE_W, CUBE_H),
VEC_ZERO, 0, WHITE);
}
}
EndTextureMode();

while (!WindowShouldClose() && is_active && view_state != MENU_STATE_EXIT) {

BeginTextureMode(state->render);
ClearBackground(BLACK);
DrawRectangleGradientV(0, 0, RENDER_W, RENDER_H, (Color){66, 135, 245, 255},
(Color){142, 184, 250, 255});

for (unsigned int y = 0; y < RENDER_CUBE_COUNT; y++) {
for (unsigned int x = 0; x < RENDER_CUBE_COUNT; x++) {
DrawTexturePro(
block_textures[cubes[x + y * RENDER_CUBE_COUNT]], CUBE_SRC_RECT,
RECT((float)x * CUBE_W, (float)y * CUBE_H, CUBE_W, CUBE_H),
VEC_ZERO, 0, WHITE);
}
}
DrawTexturePro(background.texture, RECT(0.f, 0.f, (float)background.texture.width, -(float)background.texture.height),
RECT(0.f, 0.f, (float)state->render.texture.width, (float)state->render.texture.height),
VEC_ZERO, 0, WHITE);

view_state = current_view->update(current_view);
switch (view_state) {
Expand Down Expand Up @@ -70,6 +70,8 @@ void menu_screen(w_state *state) {
destroy_menu_maps(maps_view);
destroy_menu_settings(settings_view);

UnloadRenderTexture(background);

if (is_active) {
state->state = FS_EXIT;
}
Expand Down
24 changes: 12 additions & 12 deletions src/screens/menu/views/home.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ w_menu_view *create_menu_home(w_state *state) {
data->ctx->margin_width = 40;

data->play_button = create_button(
data->ctx, VEC(PERCENT_W(0.5f), PERCENT_H(0.45f)), WHITE, "Play");
data->ctx, VEC(PERCENT_W(0.5f), PERCENT_H(0.40f)), WHITE, "Play");

data->settings_button = create_button(
data->ctx,
VEC(.x = data->play_button->position.x + data->play_button->size.x / 2,
.y =
data->play_button->rect.y + data->play_button->rect.height * 2, ),
WHITE, "Settings");
data->settings_button->default_color = Fade(WHITE, 0.5);
data->settings_button->hover_color = Fade(WHITE, 0.5);

data->exit_button = create_button(
data->ctx,
VEC(.x = data->play_button->position.x + data->play_button->size.x / 2,
.y = data->settings_button->rect.y +
data->settings_button->rect.height * 2),
WHITE, "Exit");
data->maps_button =
create_button(data->ctx,
VEC(.x = data->settings_button->position.x +
data->settings_button->size.x / 2,
.y = data->settings_button->rect.y +
data->settings_button->rect.height * 2, ),
WHITE, "Maps");

data->title_text = create_text(
data->ctx, VEC(PERCENT_W(0.5f), PERCENT_H(0.2f)), "Wispy", 120, WHITE);
Expand All @@ -62,8 +62,8 @@ w_menu_state update_menu_home(w_menu_view *view) {
if (update_button(data->settings_button)) {
state = MENU_STATE_SETTINGS;
}
if (update_button(data->exit_button)) {
state = MENU_STATE_EXIT;
if (update_button(data->maps_button)) {
state = MENU_STATE_MAPS;
}

update_text(data->title_text);
Expand All @@ -88,7 +88,7 @@ void destroy_menu_home(w_menu_view *view) {

destroy_button(data->play_button);
destroy_button(data->settings_button);
destroy_button(data->exit_button);
destroy_button(data->maps_button);

destroy_gui(data->ctx);

Expand Down
1 change: 0 additions & 1 deletion src/screens/menu/views/home.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ typedef struct w_menu_home_data {
w_guibutton *play_button;
w_guibutton *maps_button;
w_guibutton *settings_button;
w_guibutton *exit_button;

w_guitext *title_text;
w_guitext *credit_text;
Expand Down

0 comments on commit dc75d0e

Please sign in to comment.