Skip to content

Commit

Permalink
fix: some UI tweaks and code organization
Browse files Browse the repository at this point in the history
  • Loading branch information
iWas-Coder committed Apr 24, 2024
1 parent 6ba6fd8 commit f9e0ba8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 38 deletions.
26 changes: 5 additions & 21 deletions src/sk_scene_gameplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,35 +37,19 @@ void sk_scene_gameplay_draw(sk_state *s) {
sk_map_draw(&s->map);
EndMode3D();
// HUD
DrawText("v" sk_xstr(SK_VERSION),
GetScreenWidth() - 100,
GetScreenHeight() - 20,
14,
GRAY);
DrawText("Client Version: " sk_xstr(SK_VERSION), GetScreenWidth() - 190, GetScreenHeight() - 20, 14, LIGHTGRAY);
DrawFPS(10, 10);
DrawText(TextFormat("%.4f ms", GetFrameTime() * 1000), 10, 33, 20, LIME);
if (s->is_online) {
DrawText(TextFormat("N/A ms"), 10, 50, 20, LIME);
DrawText(TextFormat("(d) N/A bps | (u) N/A bps"), 10, 70, 20, LIME);
}
// START: HUD's Crosshair
DrawCircle(GetScreenWidth() / 2,
GetScreenHeight() / 2,
s->config.crosshair.radius,
BLACK);
DrawCircle(GetScreenWidth() / 2,
GetScreenHeight() / 2,
s->config.crosshair.radius - 0.9f,
WHITE);
DrawCircle(GetScreenWidth() / 2, GetScreenHeight() / 2, s->config.crosshair.radius, BLACK);
DrawCircle(GetScreenWidth() / 2, GetScreenHeight() / 2, s->config.crosshair.radius - 0.9f, RAYWHITE);
// END: HUD's Crosshair
DrawText(TextFormat("%u", s->player.hp),
100,
GetScreenHeight() - 100,
25,
RAYWHITE);
DrawText(TextFormat("%u | %u",
s->player.weapon.ammo.magazine,
s->player.weapon.ammo.reserve),
DrawText(TextFormat("%u", s->player.hp), 100, GetScreenHeight() - 100, 25, RAYWHITE);
DrawText(TextFormat("%u | %u", s->player.weapon.ammo.magazine, s->player.weapon.ammo.reserve),
GetScreenWidth() - 100,
GetScreenHeight() - 100,
25,
Expand Down
18 changes: 6 additions & 12 deletions src/sk_scene_intro.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,21 @@ void sk_scene_intro_draw(sk_state *s) {
case 0:
ClearBackground(BLACK);
DrawText(INTRO_PHASE0_TXT1,
(GetScreenWidth() - MeasureText(INTRO_PHASE0_TXT1,
INTRO_PHASE0_TXT1_SIZE)) / 2,
(GetScreenHeight() - MeasureText(INTRO_PHASE0_TXT1,
INTRO_PHASE0_TXT1_SIZE)) / 2,
(GetScreenWidth() - MeasureText(INTRO_PHASE0_TXT1, INTRO_PHASE0_TXT1_SIZE)) / 2,
(GetScreenHeight() - MeasureText(INTRO_PHASE0_TXT1, INTRO_PHASE0_TXT1_SIZE)) / 2,
INTRO_PHASE0_TXT1_SIZE,
RAYWHITE);
DrawText(INTRO_PHASE0_TXT2,
(GetScreenWidth() - MeasureText(INTRO_PHASE0_TXT2,
INTRO_PHASE0_TXT2_SIZE)) / 2,
((GetScreenHeight() - MeasureText(INTRO_PHASE0_TXT2,
INTRO_PHASE0_TXT2_SIZE)) / 2) - 55,
(GetScreenWidth() - MeasureText(INTRO_PHASE0_TXT2, INTRO_PHASE0_TXT2_SIZE)) / 2,
((GetScreenHeight() - MeasureText(INTRO_PHASE0_TXT2, INTRO_PHASE0_TXT2_SIZE)) / 2) - 55,
INTRO_PHASE0_TXT2_SIZE,
RAYWHITE);
break;
case 1:
ClearBackground(BLACK);
DrawText(INTRO_PHASE1_TXT,
(GetScreenWidth() - MeasureText(INTRO_PHASE1_TXT,
INTRO_PHASE1_TXT_SIZE)) / 2,
(GetScreenHeight() - MeasureText(INTRO_PHASE1_TXT,
INTRO_PHASE1_TXT_SIZE)) / 2,
(GetScreenWidth() - MeasureText(INTRO_PHASE1_TXT, INTRO_PHASE1_TXT_SIZE)) / 2,
(GetScreenHeight() - MeasureText(INTRO_PHASE1_TXT, INTRO_PHASE1_TXT_SIZE)) / 2,
INTRO_PHASE1_TXT_SIZE,
RAYWHITE);
break;
Expand Down
6 changes: 1 addition & 5 deletions src/sk_scene_main_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ void sk_scene_main_menu_draw(sk_state *s) {
DrawText("[DEBUG MODE]", GetScreenWidth() - 155, 10, 20, YELLOW);
#endif
if (!s->is_online) DrawText("OFFLINE MODE", 10, 10, 20, YELLOW);
DrawText("v" sk_xstr(SK_VERSION), 10, GetScreenHeight() - 25, 20, RAYWHITE);
DrawText(MAIN_MENU_TITLE,
(GetScreenWidth() - MeasureText(MAIN_MENU_TITLE,
MAIN_MENU_TITLE_SIZE)) / 2,
Expand All @@ -81,11 +82,6 @@ void sk_scene_main_menu_draw(sk_state *s) {
((GetScreenHeight() - MeasureText(MAIN_MENU_EXIT, MAIN_MENU_EXIT_SIZE)) / 2) + 225,
MAIN_MENU_EXIT_SIZE,
RAYWHITE);
DrawText("v" sk_xstr(SK_VERSION),
10,
GetScreenHeight() - 25,
20,
RAYWHITE);
if (s->config.err_title &&
s->config.err_body &&
strcmp(s->config.err_body, "") &&
Expand Down
12 changes: 12 additions & 0 deletions src/sk_scene_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
#include <sk_scene_options.h>
#include <sk_scene_main_menu.h>

#define OPTIONS_TITLE "OPTIONS"
#define OPTIONS_TITLE_SIZE 50
#define OPTIONS_RETURN "<-- Press <ESC> to return"
#define OPTIONS_RETURN_SIZE 20

void sk_scene_options_update(sk_state *s) {
if (IsMusicStreamPlaying(s->menu_music)) UpdateMusicStream(s->menu_music);
if (IsKeyPressed(KEY_ESCAPE)) {
Expand All @@ -38,4 +43,11 @@ void sk_scene_options_draw(sk_state *s) {
DrawText("[DEBUG MODE]", GetScreenWidth() - 155, 10, 20, YELLOW);
#endif
if (!s->is_online) DrawText("OFFLINE MODE", 10, 10, 20, YELLOW);
DrawText("v" sk_xstr(SK_VERSION), 10, GetScreenHeight() - 25, 20, RAYWHITE);
DrawText(OPTIONS_TITLE,
(GetScreenWidth() - MeasureText(OPTIONS_TITLE, OPTIONS_TITLE_SIZE)) / 2,
50,
OPTIONS_TITLE_SIZE,
RAYWHITE);
DrawText(OPTIONS_RETURN, 120, 60, OPTIONS_RETURN_SIZE, RAYWHITE);
}

0 comments on commit f9e0ba8

Please sign in to comment.