Skip to content

Commit

Permalink
sk_client_renderer -> sk_renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
iWas-Coder committed Mar 28, 2024
1 parent 36fd9b2 commit d55b9c5
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 27 deletions.
9 changes: 4 additions & 5 deletions include/sk_client_renderer.h → include/sk_renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
#pragma once

#include <raylib.h>
#include <raymath.h>
#include <sk_gametypes.h>

#define sk_client_renderer_loop while (!WindowShouldClose())
#define sk_renderer_loop while (!WindowShouldClose())

void sk_client_renderer_init(void);
void sk_client_renderer_update(State *s);
void sk_client_renderer_draw(State *s);
void sk_renderer_init(void);
void sk_renderer_update(State *s);
void sk_renderer_draw(State *s);
30 changes: 14 additions & 16 deletions src/sk_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,12 @@

#include <sk_config.h>
#include <sk_client.h>
#include <sk_renderer.h>
#include <sk_gametypes.h>
#include <sk_client_renderer.h>

static State state = {0};

static void __init(void) {
if (!ChangeDirectory(GetApplicationDirectory())) {
TraceLog(LOG_WARNING, "Could not change CWD to the game's root directory");
}
sk_client_renderer_init();
state.current_scene = SCENE_MAIN_MENU;
sk_player_create(&state, SK_PLAYER_KIND_JETT);
}

static u8 __shutdown(void) {
static u8 destroy(void) {
sk_player_destroy(&state.player);
CloseAudioDevice();
CloseWindow();
Expand All @@ -48,10 +39,17 @@ u8 sk_client_run(const char *ip) {
TraceLog(LOG_INFO, "Initializing %s", SK_CLIENT_NAME);
if (!ip) TraceLog(LOG_WARNING, "Running in offline mode");
else TraceLog(LOG_INFO, "Connected to server @ %s", ip);
__init();
sk_client_renderer_loop {
sk_client_renderer_update(&state);
sk_client_renderer_draw(&state);

if (!ChangeDirectory(GetApplicationDirectory())) {
TraceLog(LOG_WARNING, "Could not change CWD to the game's root directory");
}
sk_renderer_init();
state.current_scene = SCENE_MAIN_MENU;
sk_player_create(&state, SK_PLAYER_KIND_JETT);

sk_renderer_loop {
sk_renderer_update(&state);
sk_renderer_draw(&state);
}
return __shutdown();
return destroy();
}
4 changes: 2 additions & 2 deletions src/sk_client_renderer.c → src/sk_renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <assert.h>
#include <sk_config.h>
#include <sk_client.h>
#include <sk_client_renderer.h>
#include <sk_renderer.h>

static inline void __open_window(void) {
SetConfigFlags(FLAG_MSAA_4X_HINT);
Expand All @@ -36,7 +36,7 @@ static inline void __init_audio(void) {
InitAudioDevice();
}

void sk_client_renderer_init(void) {
void sk_renderer_init(void) {
__open_window();
__init_audio();
SetTargetFPS(SK_CONFIG_CLIENT_FPS);
Expand Down
4 changes: 2 additions & 2 deletions src/sk_client_renderer_draw.c → src/sk_renderer_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <sk_config.h>
#include <sk_client.h>
#include <sk_defines.h>
#include <sk_client_renderer.h>
#include <sk_renderer.h>

static void __draw_main_menu(void) {
ClearBackground(BLACK);
Expand Down Expand Up @@ -95,7 +95,7 @@ static void __draw_gameplay_hud(void) {
__draw_crosshair();
}

void sk_client_renderer_draw(State *s) {
void sk_renderer_draw(State *s) {
BeginDrawing();
switch (s->current_scene) {
case SCENE_MAIN_MENU:
Expand Down
4 changes: 2 additions & 2 deletions src/sk_client_renderer_update.c → src/sk_renderer_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <assert.h>
#include <sk_config.h>
#include <sk_defines.h>
#include <sk_client_renderer.h>
#include <sk_renderer.h>

static void __update_main_menu(State *s) {
if (IsKeyPressed(KEY_ENTER)) {
Expand All @@ -32,7 +32,7 @@ static void __update_main_menu(State *s) {
}
}

void sk_client_renderer_update(State *s) {
void sk_renderer_update(State *s) {
switch (s->current_scene) {
case SCENE_MAIN_MENU:
__update_main_menu(s);
Expand Down

0 comments on commit d55b9c5

Please sign in to comment.