From 750b30aa890b1632a484d55afbd088c31880710f Mon Sep 17 00:00:00 2001 From: Sara Date: Fri, 5 May 2023 22:14:01 +0200 Subject: [PATCH 01/22] no_sprite is now a #define for a all-zero sprite --- src/corelib/render.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/corelib/render.h b/src/corelib/render.h index 62ce38f..62dc9a8 100644 --- a/src/corelib/render.h +++ b/src/corelib/render.h @@ -104,9 +104,7 @@ extern text_style_t make_text_style(const char* font, SDL_Color color, int dpi, extern SDL_Rect get_srcrect_from(spritesheet_t* sheet, int index); extern void set_active_view(const view_t* view); -inline sprite_t no_sprite() { - return (sprite_t){NULL, 0.0, 0.0, {0.0, 0.0}, 0.0, 0.0, 0.0, 0, {0, 0, 0, 0}}; -} +#define no_sprite (sprite_t){NULL, 0.0, 0.0, {0.0, 0.0}, 0.0, 0.0, 0.0, 0, {0, 0, 0, 0}} #ifdef __cplusplus } From 2b927259a88a7208d7900a26b33e08a8d019fd01 Mon Sep 17 00:00:00 2001 From: Sara Date: Fri, 5 May 2023 22:14:30 +0200 Subject: [PATCH 02/22] draw(cmd) is now no longer in declared in header --- src/corelib/render.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/corelib/render.h b/src/corelib/render.h index 62dc9a8..5c71492 100644 --- a/src/corelib/render.h +++ b/src/corelib/render.h @@ -89,7 +89,6 @@ extern void screen_to_view(float* x, float* y); extern void clear_buffer(); extern void swap_buffer(); -extern void draw(const drawcmd_t* cmd); extern sprite_t render_text(const char* str, SDL_FRect area, text_style_t style); extern void draw_sprite(const sprite_t* sprite); From b898fd5b317611ee8c41773ef8c4fb65eab63e2f Mon Sep 17 00:00:00 2001 From: Sara Date: Fri, 5 May 2023 22:17:28 +0200 Subject: [PATCH 03/22] added return in guard clause for empty drawcmd buffer draw(cmd) had a bug causing the first drawcmd in every frame to be added twice, for text this would cause a double free --- src/corelib/render.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/render.c b/src/corelib/render.c index 543e7d1..e39b58b 100644 --- a/src/corelib/render.c +++ b/src/corelib/render.c @@ -344,6 +344,7 @@ void insert_drawcmd_at(size_t index, const drawcmd_t* cmd) { void draw(const drawcmd_t* cmd) { if(g_drawdata_endptr == g_drawdata) { insert_drawcmd_at(0, cmd); + return; } long top = (size_t)(g_drawdata_endptr - g_drawdata), bot = 0, From 3a4c037aa7d9b809214e92086913d6a05d45aa82 Mon Sep 17 00:00:00 2001 From: Sara Date: Fri, 5 May 2023 23:18:11 +0200 Subject: [PATCH 04/22] removed tilemap.csv --- tilemap.csv | 1 - 1 file changed, 1 deletion(-) delete mode 100644 tilemap.csv diff --git a/tilemap.csv b/tilemap.csv deleted file mode 100644 index 859be96..0000000 --- a/tilemap.csv +++ /dev/null @@ -1 +0,0 @@ -128,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, \ No newline at end of file From 851714810c1c5127956d30f89d75e7f282fb760f Mon Sep 17 00:00:00 2001 From: Sara Date: Fri, 5 May 2023 23:19:02 +0200 Subject: [PATCH 05/22] changed to single build directory and now using debug and build sh scripts --- .gitignore | 1 + CMakeLists.txt | 2 +- debug | 3 +++ release | 3 +++ 4 files changed, 8 insertions(+), 1 deletion(-) create mode 100755 debug create mode 100755 release diff --git a/.gitignore b/.gitignore index e0267df..2e89d55 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # build dirs bin/ release/ +build/ debug/ # clangd cache diff --git a/CMakeLists.txt b/CMakeLists.txt index d5cd436..330f641 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,4 +30,4 @@ add_executable(${PROJECT} target_link_libraries(${PROJECT} SDL2 SDL2_image SDL2_ttf) -target_include_directories(${PROJECT} PRIVATE "${CMAKE_SOURCE_DIR}/include/" "${CMAKE_SOURCE_DIR}/src/sge/") +target_include_directories(${PROJECT} PRIVATE "${CMAKE_SOURCE_DIR}/include/" "${CMAKE_SOURCE_DIR}/src/corelib" "${CMAKE_SOURCE_DIR}/src/ui") diff --git a/debug b/debug new file mode 100755 index 0000000..9b57e31 --- /dev/null +++ b/debug @@ -0,0 +1,3 @@ +#!/bin/sh + +cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Debug && cmake --build build && lldb bin/sim-game -o r -b diff --git a/release b/release new file mode 100755 index 0000000..56a6220 --- /dev/null +++ b/release @@ -0,0 +1,3 @@ +#!/bin/sh + +cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build && bin/sim-game From 465551e9817cacf3028e9ab5ae0d89af3cca2ffb Mon Sep 17 00:00:00 2001 From: Sara Date: Fri, 5 May 2023 23:20:07 +0200 Subject: [PATCH 06/22] replaced tilemap with world --- src/tilemap.c | 82 --------------------------------------------------- src/tilemap.h | 41 -------------------------- src/world.c | 60 +++++++++++++++++++++++++++++++++++++ src/world.h | 37 +++++++++++++++++++++++ 4 files changed, 97 insertions(+), 123 deletions(-) delete mode 100644 src/tilemap.c delete mode 100644 src/tilemap.h create mode 100644 src/world.c create mode 100644 src/world.h diff --git a/src/tilemap.c b/src/tilemap.c deleted file mode 100644 index ef9ce4d..0000000 --- a/src/tilemap.c +++ /dev/null @@ -1,82 +0,0 @@ -#include "tilemap.h" -#include "corelib/layers.h" -#include "stdio.h" -#include "string.h" -#include "signal.h" -#include "stdio.h" - -void draw_tilemap(const tilemap_t* tilemap, const tileset_t* tileset) { - sprite_t sprite; - for(int y=0;yheight;++y) { - for(int x=0;xwidth;++x) { - size_t index = get_tile(tilemap, x, y); - if(index == 0) continue; - const tile_t tile = tileset->set[index-1]; - sprite = tile.sprite; - sprite.depth = RLAYER_TILEMAP; - sprite.x = x; sprite.y = y; - draw_sprite(&sprite); - } - } -} - -int save_tilemap(const tilemap_t* map, const char* file) { - FILE* fs = fopen(file, "w"); - if(fs == NULL) { - fprintf(stderr, "ERROR: Failed to open file %s\n", file); - return 1; - } - fprintf(fs, "%d,%d,", map->width, map->height); - for(int i = 0; i < map->width * map->height; ++i) - fprintf(fs,"%zu,", map->tiles[i]); - fclose(fs); - return 0; -} - -int load_tilemap(tilemap_t* map, const char* file) { - FILE* fs = fopen(file, "r"); - if(fs == NULL) { - fprintf(stderr, "ERROR: Failed to open file %s\n", file); - return 1; - } - char buf[99]; - char* writer = buf; - int n = 0; - size_t* tile = map->tiles; - int entries=0; - while(1) { - n = fgetc(fs); - const char c = (char)n; - switch(n) { - case ' ': - case '\n': - case '\t': - break; // ignore - case EOF: - case ',': - *writer = '\0'; - if(entries == 0) { - map->width = atoi(buf); - } else if(entries == 1) { - map->height = atoi(buf); - } else { - if(entries-2 >= TILEMAP_MAX_SIZE) goto end_while; - *tile = (size_t)atoi(buf); - ++tile; - } - writer = buf; - ++entries; - if(n == EOF) - goto end_while; - else - break; - default: - *writer = c; - ++writer; - break; - } - } -end_while: - fclose(fs); - return 0; -} diff --git a/src/tilemap.h b/src/tilemap.h deleted file mode 100644 index 478bebd..0000000 --- a/src/tilemap.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef _tilemap_h -#define _tilemap_h - -#include "corelib/render.h" - -#define TILEMAP_MAX_SIZE 16384 -#define TILESET_MAX_SIZE 255 - -typedef struct tile_t { - sprite_t sprite; - short walkable; -} tile_t; - -typedef struct tileset_t { - tile_t* set; - size_t size; -} tileset_t; - -typedef struct tilemap_t { - size_t tiles[TILEMAP_MAX_SIZE]; - int width, height; - float x, y; -} tilemap_t; - -static inline int get_tilemap_index(const tilemap_t* tilemap, int x, int y) { - return x + y * tilemap->width; -} -static inline size_t get_tile(const tilemap_t* tilemap, int x, int y) { - return *(tilemap->tiles + get_tilemap_index(tilemap, x, y)); -} -static inline void set_tile(tilemap_t* tilemap, int x, int y, size_t value) { - *(tilemap->tiles + get_tilemap_index(tilemap, x, y)) = value; -} - -extern void draw_tilemap(const tilemap_t* tilemap, const tileset_t* tileset); -/*load csv tilemap from file*/ -extern int load_tilemap(tilemap_t* tilemap, const char* file); -/*write csv tilemap to file*/ -extern int save_tilemap(const tilemap_t* tilemap, const char* file); - -#endif /* _tilemap_h */ diff --git a/src/world.c b/src/world.c new file mode 100644 index 0000000..6f62c91 --- /dev/null +++ b/src/world.c @@ -0,0 +1,60 @@ +#include "world.h" + +object_t g_objects[WORLD_NUM_OBJECTS]; + +void world_clear() { + for(int i = 0; i < WORLD_NUM_OBJECTS; ++i) { + g_objects[i].active = 0; + g_objects[i].enabled = 0; + } +} + +void object_draw_sprite(object_t* object) { + draw_sprite(&object->sprite); +} + +object_t* _find_free_object() { + for(int i = 0; i < WORLD_NUM_OBJECTS; ++i) { + if(g_objects[i].active == 0) { + return g_objects + i; + } + } + return NULL; +} + +object_t* make_object() { + object_t* o = _find_free_object(); + o->active = 1; + o->enabled = 1; + o->evt_draw = &object_draw_sprite; + o->evt_update = NULL; + memset(&o->sprite, 0, sizeof(sprite_t)); + return o; +} + +object_t* instantiate_object(const object_t *original) { + object_t* obj = make_object(); + *obj = *original; + obj->active = 1; + return obj; +} + +void update_objects() { + for(int i = 0; i < WORLD_NUM_OBJECTS; ++i) { + if(g_objects[i].active == 1 + && g_objects[i].enabled == 1 + && g_objects[i].evt_update != NULL) { + g_objects[i].evt_update(g_objects + i); + } + } +} + +void draw_objects() { + for(int i = 0; i < WORLD_NUM_OBJECTS; ++i) { + if(g_objects[i].active == 1 + && g_objects[i].enabled == 1 + && g_objects[i].evt_draw != NULL) { + g_objects[i].evt_draw(g_objects + i); + } + } +} diff --git a/src/world.h b/src/world.h new file mode 100644 index 0000000..2fd381d --- /dev/null +++ b/src/world.h @@ -0,0 +1,37 @@ +#ifndef _world_h +#define _world_h + +#include "render.h" +#include + +#define WORLD_NUM_OBJECTS 255 + +typedef struct object_t object_t; + +typedef void(*tick_fn)(struct object_t*); +typedef void(*draw_fn)(struct object_t*); + +struct object_t { + sprite_t sprite; + int active; // 1 if this object is in use and should not be overriden + int enabled; // 1 if this object's events should be triggered + + uintptr_t timer; // free to use for whatever + + tick_fn evt_update; + draw_fn evt_draw; +}; + +extern object_t g_objects[WORLD_NUM_OBJECTS]; + +void world_clear(); + +object_t* make_object(); +object_t* instantiate_object(const object_t* original); + +void object_draw_sprite(object_t* object); + +void update_objects(); +void draw_objects(); + +#endif /* _world_h */ From 6afac7041132924849fa18db0ef1c4edea75b4a3 Mon Sep 17 00:00:00 2001 From: Sara Date: Fri, 5 May 2023 23:20:23 +0200 Subject: [PATCH 07/22] added player to test world --- src/player.c | 41 +++++++++++++++++++++++++++++++++++++++++ src/player.h | 18 ++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 src/player.c create mode 100644 src/player.h diff --git a/src/player.c b/src/player.c new file mode 100644 index 0000000..6c87fc4 --- /dev/null +++ b/src/player.c @@ -0,0 +1,41 @@ +#include "player.h" +#include "layers.h" +#include "ui.h" +#include "world.h" +#include "input.h" +#include "engine.h" +#include + +float player_move_x = 0; +float player_move_y = 0; +float player_xv = 0; +float player_yv = 0; +object_t* player_instance = NULL; + +void player_update(object_t *object) { + float m = sqrtf(player_move_x*player_move_x + player_move_y*player_move_y); + if(m == FP_NAN) m = 1; + player_xv = player_move_x * 10.f / m, + player_yv = player_move_y * 10.f / m; + object->sprite.x += player_xv* delta_time(); + object->sprite.y += player_yv* delta_time(); +} + +object_t* create_player() { + player_instance = make_object(); + player_instance->evt_update = &player_update; + player_instance->sprite = make_sprite("player.png", 0, 0); + + add_key_listener(SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT, &player_axis_horizontal); + add_key_listener(SDL_SCANCODE_DOWN, SDL_SCANCODE_UP, &player_axis_vertical); + + return player_instance; +} + +void player_axis_horizontal(int axis) { + player_move_x = axis; +} + +void player_axis_vertical(int axis) { + player_move_y = -axis; +} diff --git a/src/player.h b/src/player.h new file mode 100644 index 0000000..52c65a7 --- /dev/null +++ b/src/player.h @@ -0,0 +1,18 @@ +#ifndef _player_h +#define _player_h + +struct object_t; + +extern float player_move_x; +extern float player_move_y; +extern float player_xv; +extern float player_yv; +extern struct object_t* player_instance; + +void player_update(struct object_t* object); +struct object_t* create_player(); + +extern void player_axis_horizontal(int axis); +extern void player_axis_vertical(int axis); + +#endif /* _player_h */ From ee2dd74566291f5d0f0e4309ed9452bb91a692b8 Mon Sep 17 00:00:00 2001 From: Sara Date: Fri, 5 May 2023 23:20:38 +0200 Subject: [PATCH 08/22] added updated game to test world --- src/game.c | 164 ++++------------------------------------------------- 1 file changed, 10 insertions(+), 154 deletions(-) diff --git a/src/game.c b/src/game.c index 2e442fd..6601076 100644 --- a/src/game.c +++ b/src/game.c @@ -1,53 +1,17 @@ #include "engine.h" -#include "tilemap.h" +#include "world.h" +#include "player.h" +#include "ui.h" #include "corelib/input.h" #include "corelib/render.h" #include "corelib/assets.h" #include "corelib/layers.h" #include "SDL2/SDL_mouse.h" #include "SDL2/SDL_scancode.h" -#include "ui.h" -int cursor_tile = 1; int dragging = 0; int drawing = 0; -sprite_t cursor; spritesheet_t world_sheet; -tileset_t tileset; -tilemap_t tilemap = { - .width = 0,.height = 0, - .x=0,.y=0 -}; - -void on_save_key(int down) { - if(down) save_tilemap(&tilemap, "tilemap.csv"); -} - -void on_load_key(int down) { - if(down) load_tilemap(&tilemap, "tilemap.csv"); -} - -void on_clear_key(int down) { - if(down) { - for(int i = 0; i < tilemap.height * tilemap.width; ++i) { - tilemap.tiles[i] = 0; - } - } -} - -void on_cycle_tile(int axis) { - cursor_tile += axis; - if(cursor_tile <= 0) { - cursor_tile = 1; - } - int size = tileset.size; - if(cursor_tile >= size) { - cursor_tile = size-1; - } - if(tileset.size >= cursor_tile && 0 < cursor_tile) { - cursor = tileset.set[cursor_tile-1].sprite; - } -} void on_quit_key(int down) { if(down) { @@ -92,51 +56,13 @@ void on_scroll_zoom(float delta) { } void load_game() { - style.button.button = style.button.active = make_nineslice("button.png", 126, 0.01); + ui_style.button.button = ui_style.button.active = make_nineslice("button.png", 126, 0.01); + ui_style.text = make_text_style("ui_font.otf", (SDL_Color){255, 255, 255, 255}, 50, 0.02f); world_sheet = make_spritesheet("tileset.png", 189, 189); - tileset.set = (tile_t*)calloc(21, sizeof(tile_t)); - tileset.size = 21; - tileset.set[0] = (tile_t){.sprite=sprite_from_spritesheet(&world_sheet, 0),.walkable=0}; - tileset.set[1] = (tile_t){.sprite=sprite_from_spritesheet(&world_sheet, 1),.walkable=0}; - tileset.set[2] = (tile_t){.sprite=sprite_from_spritesheet(&world_sheet, 2),.walkable=0}; - - tileset.set[3] = (tile_t){.sprite=sprite_from_spritesheet(&world_sheet, 10),.walkable=0}; - tileset.set[4] = (tile_t){.sprite=sprite_from_spritesheet(&world_sheet, 11),.walkable=0}; - tileset.set[5] = (tile_t){.sprite=sprite_from_spritesheet(&world_sheet, 12),.walkable=0}; - - tileset.set[6] = (tile_t){.sprite=sprite_from_spritesheet(&world_sheet, 20),.walkable=0}; - tileset.set[7] = (tile_t){.sprite=sprite_from_spritesheet(&world_sheet, 21),.walkable=0}; - tileset.set[8] = (tile_t){.sprite=sprite_from_spritesheet(&world_sheet, 22),.walkable=0}; - - tileset.set[9] = (tile_t){.sprite=sprite_from_spritesheet(&world_sheet, 30),.walkable=1}; - tileset.set[10]= (tile_t){.sprite=sprite_from_spritesheet(&world_sheet, 31),.walkable=1}; - tileset.set[11]= (tile_t){.sprite=sprite_from_spritesheet(&world_sheet, 32),.walkable=1}; - - tileset.set[12]= (tile_t){.sprite=sprite_from_spritesheet(&world_sheet, 3),.walkable=1}; - tileset.set[13]= (tile_t){.sprite=sprite_from_spritesheet(&world_sheet, 4),.walkable=1}; - tileset.set[14]= (tile_t){.sprite=sprite_from_spritesheet(&world_sheet, 5),.walkable=1}; - - tileset.set[15]= (tile_t){.sprite=sprite_from_spritesheet(&world_sheet, 13),.walkable=1}; - tileset.set[16]= (tile_t){.sprite=sprite_from_spritesheet(&world_sheet, 14),.walkable=1}; - tileset.set[17]= (tile_t){.sprite=sprite_from_spritesheet(&world_sheet, 15),.walkable=1}; - - tileset.set[18]= (tile_t){.sprite=sprite_from_spritesheet(&world_sheet, 23),.walkable=1}; - tileset.set[19]= (tile_t){.sprite=sprite_from_spritesheet(&world_sheet, 24),.walkable=1}; - tileset.set[20]= (tile_t){.sprite=sprite_from_spritesheet(&world_sheet, 25),.walkable=1}; - - // register calloc'd array to be deleted with free(...) - add_arbitrary_asset(tileset.set, &free); - - tilemap.width = tilemap.height = 128; - on_cycle_tile(0); - input_init(); - add_key_listener(SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_W, &on_save_key); - add_key_listener(SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_R, &on_load_key); - add_key_listener(SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_C, &on_clear_key); + world_clear(); add_key_listener(SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_Q, &on_quit_key); - add_key_listener(SDL_SCANCODE_A, SDL_SCANCODE_D, &on_cycle_tile); add_key_listener(SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_TAB, &on_debug_frame); add_key_listener(SDL_SCANCODE_MINUS, SDL_SCANCODE_EQUALS, &on_button_zoom); add_mouse_button_listener(SDL_BUTTON_LMASK, &on_click); @@ -144,94 +70,24 @@ void load_game() { add_mouse_button_listener(SDL_BUTTON_MMASK, &on_middle_mouse); add_mouse_listener(&on_drag_world); add_scroll_listener(&on_scroll_zoom); + + create_player(); } void start_game() { g_active_view.width = 21; - on_clear_key(1); } void update_game() { if(drawing == 1) { drawing = 2; } - - float fx, fy; - mouse_world_position(&fx, &fy); - cursor.x = floor(fx); cursor.y = floor(fy); - if(drawing) { - int x, y; - x = floorf(fx); - y = floorf(fy); - if(x >= 0 && y >= 0 && x < tilemap.width && y < tilemap.height) { - if(drawing > 0) { - set_tile(&tilemap, x, y, cursor_tile); - } else { - set_tile(&tilemap, x, y, 0); - } - } - } - - rectshape_t world_outline = { - tilemap.x, tilemap.y, (float)tilemap.width, (float)tilemap.height, - 0.01f, RLAYER_TILEMAP-1, {0,0,0,0}, {255, 255, 255, 255} - }; - rectshape_t cursor_outline = { - cursor.x, cursor.y, 1.0f, 1.0f, 0.01f, RLAYER_SPRITES-1, - {0, 0, 0, 0}, {255, 255, 255, 255} - }; - - draw_rect(&world_outline); - draw_rect(&cursor_outline); - draw_sprite(&cursor); - draw_tilemap(&tilemap, &tileset); + update_objects(); + draw_objects(); } void update_ui() { update_input(); - - nineslice_t sliced = style.button.active; - sliced.rect = (SDL_FRect){0, 0.25f, 0.2, 0.05}; - sliced.depth = RLAYER_UI - 20; - draw_sliced(&sliced); - - const int offset_selected = cursor_tile - 1; - - rectshape_t selected_tile_rect = (rectshape_t) { - offset_selected * 0.015f, 0.f, 0.015f, 0.015f, 0.001f, RLAYER_UI-10, - {0,0,0,0}, {255, 255, 255, 255} - }; - draw_rect(&selected_tile_rect); - - rectshape_t shape = (rectshape_t) { - 0.0f, 0.0f, 1.f, 0.015f, 0, RLAYER_UI, - {100,100,100,255}, {0,0,0,0} - }; - draw_rect(&shape); - text_style_t style = make_text_style("ui_font.otf", 100, 0.01); - draw_text("M", - (SDL_FRect){0.0, 0.0, 10.0, 10.0}, style, (SDL_Color){255, 255, 255, 255}, RLAYER_UI - 100); - - float mx, my; - mouse_screen_position(&mx, &my); - for(int i = 0; i < tileset.size; ++i) { - // make a copy of the reference sprite and adjust it to fit the ui - sprite_t sprite = tileset.set[i].sprite; - sprite.depth = RLAYER_UI-5; - sprite.x = i * 0.015f; sprite.y = 0; - sprite.sx = 0.015f; sprite.sy = 0.015f; - float amx=mx-sprite.x, amy=my-sprite.y; - draw_sprite(&sprite); - - // allow user to select tiles with mouse - if(amx >= 0 && amy >= 0 && amx < sprite.sx && amy < sprite.sy) { - if(drawing == 1) { - drawing = 0; - cursor_tile = i+1; - on_cycle_tile(0); - } - } - } } void game_exit() {} From 24578583992eda56b00b83e4de30bb7b936f2561 Mon Sep 17 00:00:00 2001 From: Sara Date: Fri, 5 May 2023 23:22:32 +0200 Subject: [PATCH 09/22] changed many of the functions to now be static --- src/corelib/render.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/corelib/render.c b/src/corelib/render.c index e39b58b..d1a3144 100644 --- a/src/corelib/render.c +++ b/src/corelib/render.c @@ -75,7 +75,7 @@ SDL_FRect get_dest_with_size(SDL_FRect untransformed, int ui) { return r; } -void exec_sprite_cmd(const drawcmd_t* cmd) { +static void _exec_sprite_cmd(const drawcmd_t* cmd) { const sprite_t* sprite = &cmd->sprite; float fw, fh, fwm, fhm; get_scaling_factors(&fw, &fh, &fwm, &fhm, cmd->ui); @@ -94,7 +94,7 @@ void exec_sprite_cmd(const drawcmd_t* cmd) { &sprite->origin,SDL_FLIP_NONE); } -void exec_rect_cmd(const drawcmd_t* cmd) { +static void _exec_rect_cmd(const drawcmd_t* cmd) { float w, h, wm, hm; get_scaling_factors(&w, &h, &wm, &hm, cmd->ui); SDL_FRect rect = (SDL_FRect) { @@ -134,7 +134,7 @@ void exec_rect_cmd(const drawcmd_t* cmd) { SDL_RenderFillRectF(g_context.renderer, &r); } -void exec_sliced_cmd(const drawcmd_t* cmd) { +static void _exec_sliced_cmd(const drawcmd_t* cmd) { const nineslice_t* sliced = &cmd->sliced; // target rect in world space @@ -229,7 +229,7 @@ void exec_sliced_cmd(const drawcmd_t* cmd) { SDL_RenderCopyF(g_context.renderer, t, &srcr, &dstr); } -void exec_text_cmd(const drawcmd_t* cmd) { +static void _exec_text_cmd(const drawcmd_t* cmd) { SDL_FRect r = cmd->text.area; int fh = TTF_FontHeight(cmd->text.style.font); int wrap = (int)(fh * r.w / cmd->text.style.size); @@ -295,14 +295,14 @@ sprite_t render_text(const char* str, SDL_FRect area, text_style_t style) { } typedef void(*drawcmd_delegate)(const drawcmd_t*); -drawcmd_delegate const drawcmd_funcs[] = { - &exec_sprite_cmd, - &exec_rect_cmd, - &exec_sliced_cmd, - &exec_text_cmd, +static drawcmd_delegate const drawcmd_funcs[] = { + &_exec_sprite_cmd, + &_exec_rect_cmd, + &_exec_sliced_cmd, + &_exec_text_cmd, }; -void exec_buffer() { +static void _exec_buffer() { if(d_debug_next_frame) printf("debug capture of draw buffer\ncount: %zu\n", (size_t)(g_drawdata_endptr - g_drawdata)); for(const drawcmd_t* cmd = g_drawdata; cmd != g_drawdata_endptr; ++cmd) { if(cmd->type > DRAWCMDTYPE_MIN && cmd->type < DRAWCMDTYPE_MAX) { @@ -320,12 +320,12 @@ void swap_buffer() { SDL_GetRendererOutputSize(g_context.renderer, &iw, &ih); _render_width = (float)iw; _render_height = (float)ih; _aspect_ratio = _render_height/_render_width; - exec_buffer(); + _exec_buffer(); SDL_RenderPresent(g_context.renderer); g_drawdata_endptr = g_drawdata; } -void insert_drawcmd_at(size_t index, const drawcmd_t* cmd) { +static void _insert_drawcmd_at(size_t index, const drawcmd_t* cmd) { drawcmd_t* insertpoint = g_drawdata + index; drawcmd_t* dest = insertpoint + 1; size_t size = (size_t)(g_drawdata_endptr - g_drawdata); @@ -341,9 +341,9 @@ void insert_drawcmd_at(size_t index, const drawcmd_t* cmd) { insertpoint->ui = _render_mode == 1; } -void draw(const drawcmd_t* cmd) { +static void _draw(const drawcmd_t* cmd) { if(g_drawdata_endptr == g_drawdata) { - insert_drawcmd_at(0, cmd); + _insert_drawcmd_at(0, cmd); return; } long top = (size_t)(g_drawdata_endptr - g_drawdata), @@ -368,7 +368,7 @@ void draw(const drawcmd_t* cmd) { med++; diff = g_drawdata[med].depth - cmd->depth; } - insert_drawcmd_at(med, cmd); + _insert_drawcmd_at(med, cmd); } void draw_sprite(const sprite_t* sprite) { @@ -377,7 +377,7 @@ void draw_sprite(const sprite_t* sprite) { .depth=sprite->depth, .sprite=*sprite }; - draw(&d); + _draw(&d); } void draw_rect(const rectshape_t* rect) { @@ -386,7 +386,7 @@ void draw_rect(const rectshape_t* rect) { .depth=rect->depth, .rect=*rect }; - draw(&d); + _draw(&d); } void draw_sliced(const nineslice_t *sliced) { @@ -395,7 +395,7 @@ void draw_sliced(const nineslice_t *sliced) { .depth=sliced->depth, .sliced=*sliced }; - draw(&d); + _draw(&d); } void draw_text(const char *str, SDL_FRect area, text_style_t style, depth_t depth) { @@ -411,7 +411,7 @@ void draw_text(const char *str, SDL_FRect area, text_style_t style, depth_t dept .text=t, .depth=depth, }; - draw(&d); + _draw(&d); } spritesheet_t make_spritesheet(const char *file, int tile_width, int tile_height) { From 64b8dbcbf3ca48b53b48023e8dafd253edf95a12 Mon Sep 17 00:00:00 2001 From: Sara Date: Fri, 5 May 2023 23:23:04 +0200 Subject: [PATCH 10/22] removed one use of memcpy and replaced with *a = *b --- src/corelib/render.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/render.c b/src/corelib/render.c index d1a3144..3be0081 100644 --- a/src/corelib/render.c +++ b/src/corelib/render.c @@ -9,6 +9,7 @@ #include "SDL2/SDL_render.h" #include "SDL2/SDL_surface.h" #include "SDL2/SDL_ttf.h" +#include #define NUM_DRAWCMDS 2048 @@ -337,7 +338,7 @@ static void _insert_drawcmd_at(size_t index, const drawcmd_t* cmd) { memmove(dest, insertpoint, count*sizeof(drawcmd_t)); } } - memcpy(insertpoint, cmd, sizeof(drawcmd_t)); + *insertpoint = *cmd; insertpoint->ui = _render_mode == 1; } From cc08588b177348a34992299942f4fa1d796b9eab Mon Sep 17 00:00:00 2001 From: Sara Date: Fri, 5 May 2023 23:23:41 +0200 Subject: [PATCH 11/22] internal asset functions are now static --- src/corelib/assets.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/assets.c b/src/corelib/assets.c index d753967..537f864 100644 --- a/src/corelib/assets.c +++ b/src/corelib/assets.c @@ -6,12 +6,12 @@ #define NUM_ASSETS 256 -void _remove_asset(resource_t*); +static void _remove_asset(resource_t*); resource_t g_assets[NUM_ASSETS]; resource_t* g_assets_endptr = g_assets; -resource_t* insert_asset(const resource_t* resource) { +static resource_t* insert_asset(const resource_t* resource) { *g_assets_endptr = *resource; resource_t* inserted = g_assets_endptr; ++g_assets_endptr; @@ -95,7 +95,7 @@ resource_t* get_asset(const char* file) { return NULL; } -void _delete_referenced_asset(resource_t* res) { +static void _delete_referenced_asset(resource_t* res) { free(res->name); switch(res->type) { default: @@ -139,7 +139,7 @@ void clean_assets() { g_assets_endptr = g_assets; } -void _remove_asset(resource_t* res) { +static void _remove_asset(resource_t* res) { _delete_referenced_asset(res); resource_t* last = g_assets_endptr - 1; memmove(res, last, sizeof(resource_t)); From 182cfc66cb2979de9da75481a66b768c5361da0c Mon Sep 17 00:00:00 2001 From: Sara Date: Fri, 5 May 2023 23:26:30 +0200 Subject: [PATCH 12/22] added delta_time to engine.c --- src/engine.c | 14 +++++++++++++- src/engine.h | 10 ++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/engine.c b/src/engine.c index f524f90..2a4ab5f 100644 --- a/src/engine.c +++ b/src/engine.c @@ -2,8 +2,14 @@ #include "corelib/assets.h" #include "corelib/render.h" #include "corelib/input.h" +#include "time.h" int engine_start() { +static float _delta_time = 0; +static struct timespec start_last_frame; +inline float delta_time() { + return _delta_time; +} init_context(); return 0; } @@ -37,9 +43,15 @@ int engine_run() { load_game(); start_game(); - + + timespec_get(&start_last_frame, TIME_UTC); + struct timespec next_time; while(g_context.running) { handle_events(); + timespec_get(&next_time, TIME_UTC); + _delta_time = (next_time.tv_nsec - start_last_frame.tv_nsec) * 1E-9; + if(next_time.tv_nsec < start_last_frame.tv_nsec) _delta_time = 0; + start_last_frame = next_time; _render_mode = 1; update_ui(); _render_mode = 0; diff --git a/src/engine.h b/src/engine.h index fa546de..ada21c4 100644 --- a/src/engine.h +++ b/src/engine.h @@ -1,6 +1,12 @@ #ifndef _engine_h #define _engine_h +#ifdef __cplusplus +extern "C" { +#endif + +extern float delta_time(); + /* TO BE DEFINED IN GAME */ extern void load_game(); @@ -9,4 +15,8 @@ extern void start_game(); extern void update_game(); extern void update_ui(); +#ifdef __cplusplus +} +#endif + #endif /* _engine_h */ From a55bf84aef99e666e2981f770a49dc718ef2100a Mon Sep 17 00:00:00 2001 From: Sara Date: Fri, 5 May 2023 23:27:08 +0200 Subject: [PATCH 13/22] engine internal functions are now static inline --- src/engine.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/engine.c b/src/engine.c index 2a4ab5f..bdf201a 100644 --- a/src/engine.c +++ b/src/engine.c @@ -4,35 +4,41 @@ #include "corelib/input.h" #include "time.h" -int engine_start() { static float _delta_time = 0; static struct timespec start_last_frame; + inline float delta_time() { return _delta_time; } + +static inline +int _engine_start() { init_context(); return 0; } -int engine_shutdown() { +static inline +int _engine_shutdown() { game_exit(); clean_assets(); close_context(); exit(0); } -void handle_events() { +static inline +void _handle_events() { while(SDL_PollEvent(&g_context.event)) { input_event(g_context.event); switch(g_context.event.type) { - case SDL_QUIT: + case SDL_QUIT: g_context.running = 0; break; } } } -int engine_run() { +static inline +int _engine_run() { SDL_Window* window = SDL_CreateWindow("Tabletop", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 420, SDL_WINDOW_FULLSCREEN_DESKTOP); g_context = (context_t){ @@ -47,11 +53,11 @@ int engine_run() { timespec_get(&start_last_frame, TIME_UTC); struct timespec next_time; while(g_context.running) { - handle_events(); timespec_get(&next_time, TIME_UTC); _delta_time = (next_time.tv_nsec - start_last_frame.tv_nsec) * 1E-9; if(next_time.tv_nsec < start_last_frame.tv_nsec) _delta_time = 0; start_last_frame = next_time; + _handle_events(); _render_mode = 1; update_ui(); _render_mode = 0; @@ -62,7 +68,7 @@ int engine_run() { } int main(int argc, char* argv[]) { - engine_start(); - engine_run(); - engine_shutdown(); + _engine_start(); + _engine_run(); + _engine_shutdown(); } From 76dbc267870536c1232e8a068096ff526dd1af5b Mon Sep 17 00:00:00 2001 From: Sara Date: Sat, 6 May 2023 00:01:56 +0200 Subject: [PATCH 14/22] added breakpoint at main for debug --- debug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug b/debug index 9b57e31..0596bf2 100755 --- a/debug +++ b/debug @@ -1,3 +1,3 @@ #!/bin/sh -cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Debug && cmake --build build && lldb bin/sim-game -o r -b +cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Debug && cmake --build build && lldb bin/sim-game -o "breakpoint set -n main" -o r From d28305920f7e658d17b8027010f9dfe8d1d5bba2 Mon Sep 17 00:00:00 2001 From: Sara Date: Sat, 6 May 2023 00:05:05 +0200 Subject: [PATCH 15/22] added inline to static functions --- src/corelib/render.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/corelib/render.c b/src/corelib/render.c index 3be0081..a144493 100644 --- a/src/corelib/render.c +++ b/src/corelib/render.c @@ -76,7 +76,8 @@ SDL_FRect get_dest_with_size(SDL_FRect untransformed, int ui) { return r; } -static void _exec_sprite_cmd(const drawcmd_t* cmd) { +static +void _exec_sprite_cmd(const drawcmd_t* cmd) { const sprite_t* sprite = &cmd->sprite; float fw, fh, fwm, fhm; get_scaling_factors(&fw, &fh, &fwm, &fhm, cmd->ui); @@ -95,7 +96,8 @@ static void _exec_sprite_cmd(const drawcmd_t* cmd) { &sprite->origin,SDL_FLIP_NONE); } -static void _exec_rect_cmd(const drawcmd_t* cmd) { +static +void _exec_rect_cmd(const drawcmd_t* cmd) { float w, h, wm, hm; get_scaling_factors(&w, &h, &wm, &hm, cmd->ui); SDL_FRect rect = (SDL_FRect) { @@ -135,7 +137,8 @@ static void _exec_rect_cmd(const drawcmd_t* cmd) { SDL_RenderFillRectF(g_context.renderer, &r); } -static void _exec_sliced_cmd(const drawcmd_t* cmd) { +static +void _exec_sliced_cmd(const drawcmd_t* cmd) { const nineslice_t* sliced = &cmd->sliced; // target rect in world space @@ -230,7 +233,8 @@ static void _exec_sliced_cmd(const drawcmd_t* cmd) { SDL_RenderCopyF(g_context.renderer, t, &srcr, &dstr); } -static void _exec_text_cmd(const drawcmd_t* cmd) { +static +void _exec_text_cmd(const drawcmd_t* cmd) { SDL_FRect r = cmd->text.area; int fh = TTF_FontHeight(cmd->text.style.font); int wrap = (int)(fh * r.w / cmd->text.style.size); @@ -303,7 +307,8 @@ static drawcmd_delegate const drawcmd_funcs[] = { &_exec_text_cmd, }; -static void _exec_buffer() { +static inline +void _exec_buffer() { if(d_debug_next_frame) printf("debug capture of draw buffer\ncount: %zu\n", (size_t)(g_drawdata_endptr - g_drawdata)); for(const drawcmd_t* cmd = g_drawdata; cmd != g_drawdata_endptr; ++cmd) { if(cmd->type > DRAWCMDTYPE_MIN && cmd->type < DRAWCMDTYPE_MAX) { @@ -326,7 +331,8 @@ void swap_buffer() { g_drawdata_endptr = g_drawdata; } -static void _insert_drawcmd_at(size_t index, const drawcmd_t* cmd) { +static inline +void _insert_drawcmd_at(size_t index, const drawcmd_t* cmd) { drawcmd_t* insertpoint = g_drawdata + index; drawcmd_t* dest = insertpoint + 1; size_t size = (size_t)(g_drawdata_endptr - g_drawdata); @@ -342,7 +348,8 @@ static void _insert_drawcmd_at(size_t index, const drawcmd_t* cmd) { insertpoint->ui = _render_mode == 1; } -static void _draw(const drawcmd_t* cmd) { +static inline +void _draw(const drawcmd_t* cmd) { if(g_drawdata_endptr == g_drawdata) { _insert_drawcmd_at(0, cmd); return; From 7fc3439c9c71a3630755a7bd12a1cc6ecb479b74 Mon Sep 17 00:00:00 2001 From: Sara Date: Sun, 7 May 2023 16:08:25 +0200 Subject: [PATCH 16/22] removed breakpoint from debug script --- debug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug b/debug index 0596bf2..9b57e31 100755 --- a/debug +++ b/debug @@ -1,3 +1,3 @@ #!/bin/sh -cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Debug && cmake --build build && lldb bin/sim-game -o "breakpoint set -n main" -o r +cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Debug && cmake --build build && lldb bin/sim-game -o r -b From 1034fff697a494c9913bac9895dbb655e377a351 Mon Sep 17 00:00:00 2001 From: Sara Date: Sun, 7 May 2023 16:09:10 +0200 Subject: [PATCH 17/22] removed compile_commands.json --- compile_commands.json | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 compile_commands.json diff --git a/compile_commands.json b/compile_commands.json deleted file mode 100644 index ef03aaa..0000000 --- a/compile_commands.json +++ /dev/null @@ -1,22 +0,0 @@ -[ -{ - "directory": "/home/sara/Documents/c-projects/tabletop/release", - "command": "/usr/bin/cc -I/home/sara/Documents/c-projects/tabletop/include -I/home/sara/Documents/c-projects/tabletop/src/sge -O3 -DNDEBUG -o CMakeFiles/tabletop.dir/src/assets.c.o -c /home/sara/Documents/c-projects/tabletop/src/assets.c", - "file": "/home/sara/Documents/c-projects/tabletop/src/assets.c" -}, -{ - "directory": "/home/sara/Documents/c-projects/tabletop/release", - "command": "/usr/bin/cc -I/home/sara/Documents/c-projects/tabletop/include -I/home/sara/Documents/c-projects/tabletop/src/sge -O3 -DNDEBUG -o CMakeFiles/tabletop.dir/src/engine.c.o -c /home/sara/Documents/c-projects/tabletop/src/engine.c", - "file": "/home/sara/Documents/c-projects/tabletop/src/engine.c" -}, -{ - "directory": "/home/sara/Documents/c-projects/tabletop/release", - "command": "/usr/bin/cc -I/home/sara/Documents/c-projects/tabletop/include -I/home/sara/Documents/c-projects/tabletop/src/sge -O3 -DNDEBUG -o CMakeFiles/tabletop.dir/src/game.c.o -c /home/sara/Documents/c-projects/tabletop/src/game.c", - "file": "/home/sara/Documents/c-projects/tabletop/src/game.c" -}, -{ - "directory": "/home/sara/Documents/c-projects/tabletop/release", - "command": "/usr/bin/cc -I/home/sara/Documents/c-projects/tabletop/include -I/home/sara/Documents/c-projects/tabletop/src/sge -O3 -DNDEBUG -o CMakeFiles/tabletop.dir/src/render.c.o -c /home/sara/Documents/c-projects/tabletop/src/render.c", - "file": "/home/sara/Documents/c-projects/tabletop/src/render.c" -} -] \ No newline at end of file From 1021d040135f65a4cc5748eafcc938af0cd565bc Mon Sep 17 00:00:00 2001 From: Sara Date: Sun, 7 May 2023 16:09:19 +0200 Subject: [PATCH 18/22] fixed nan issue in player --- src/player.c | 9 +++++---- src/player.h | 6 ++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/player.c b/src/player.c index 6c87fc4..f90c3c2 100644 --- a/src/player.c +++ b/src/player.c @@ -15,10 +15,11 @@ object_t* player_instance = NULL; void player_update(object_t *object) { float m = sqrtf(player_move_x*player_move_x + player_move_y*player_move_y); if(m == FP_NAN) m = 1; - player_xv = player_move_x * 10.f / m, - player_yv = player_move_y * 10.f / m; - object->sprite.x += player_xv* delta_time(); - object->sprite.y += player_yv* delta_time(); + m = 1.f/m; + player_xv = player_move_x * 3.f * m, + player_yv = player_move_y * 3.f * m; + object->sprite.x += player_xv * delta_time(); + object->sprite.y += player_yv * delta_time(); } object_t* create_player() { diff --git a/src/player.h b/src/player.h index 52c65a7..3f116e9 100644 --- a/src/player.h +++ b/src/player.h @@ -3,10 +3,8 @@ struct object_t; -extern float player_move_x; -extern float player_move_y; -extern float player_xv; -extern float player_yv; +extern float player_move_x, player_move_y, + player_xv, player_yv; extern struct object_t* player_instance; void player_update(struct object_t* object); From 2a2ea2c7847861db62854f51aeecc7f4129ce973 Mon Sep 17 00:00:00 2001 From: Sara Date: Sun, 7 May 2023 16:10:08 +0200 Subject: [PATCH 19/22] compile_commands.json is now ignored --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 2e89d55..717648a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,7 @@ release/ build/ debug/ +compile_commands.json + # clangd cache .cache/ From 0bdfba4d117da7ce70b7d52242ca2a2afd0e3c62 Mon Sep 17 00:00:00 2001 From: Sara Date: Sun, 7 May 2023 17:54:14 +0200 Subject: [PATCH 20/22] added -DCMAKE_EXPORT_COMPILE_COMMANDS to debug and release build scripts --- debug | 2 +- release | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/debug b/debug index 9b57e31..8c12ba3 100755 --- a/debug +++ b/debug @@ -1,3 +1,3 @@ #!/bin/sh -cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Debug && cmake --build build && lldb bin/sim-game -o r -b +cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1 && cmake --build build && lldb bin/sim-game -o r -b diff --git a/release b/release index 56a6220..b3daa33 100755 --- a/release +++ b/release @@ -1,3 +1,3 @@ #!/bin/sh -cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build && bin/sim-game +cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=1 && cmake --build build && bin/sim-game From 8f7792c6734b7bd2317d41bdc242eb1b8ac1f856 Mon Sep 17 00:00:00 2001 From: Sara Date: Sun, 7 May 2023 17:55:08 +0200 Subject: [PATCH 21/22] removed all references of ui module since this is now a separate branch/pr --- src/game.c | 3 --- src/player.c | 1 - 2 files changed, 4 deletions(-) diff --git a/src/game.c b/src/game.c index 6601076..c2feec3 100644 --- a/src/game.c +++ b/src/game.c @@ -1,7 +1,6 @@ #include "engine.h" #include "world.h" #include "player.h" -#include "ui.h" #include "corelib/input.h" #include "corelib/render.h" #include "corelib/assets.h" @@ -56,8 +55,6 @@ void on_scroll_zoom(float delta) { } void load_game() { - ui_style.button.button = ui_style.button.active = make_nineslice("button.png", 126, 0.01); - ui_style.text = make_text_style("ui_font.otf", (SDL_Color){255, 255, 255, 255}, 50, 0.02f); world_sheet = make_spritesheet("tileset.png", 189, 189); input_init(); diff --git a/src/player.c b/src/player.c index f90c3c2..6589109 100644 --- a/src/player.c +++ b/src/player.c @@ -1,6 +1,5 @@ #include "player.h" #include "layers.h" -#include "ui.h" #include "world.h" #include "input.h" #include "engine.h" From 9f9cc446fe91c9e4bc8d47f3ffc1fa8298b3d707 Mon Sep 17 00:00:00 2001 From: Sara Date: Sun, 7 May 2023 17:55:22 +0200 Subject: [PATCH 22/22] switched testing player controller to wasd (from arrows) --- src/player.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/player.c b/src/player.c index 6589109..4fada2e 100644 --- a/src/player.c +++ b/src/player.c @@ -26,8 +26,8 @@ object_t* create_player() { player_instance->evt_update = &player_update; player_instance->sprite = make_sprite("player.png", 0, 0); - add_key_listener(SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT, &player_axis_horizontal); - add_key_listener(SDL_SCANCODE_DOWN, SDL_SCANCODE_UP, &player_axis_vertical); + add_key_listener(SDL_SCANCODE_A, SDL_SCANCODE_D, &player_axis_horizontal); + add_key_listener(SDL_SCANCODE_S, SDL_SCANCODE_W, &player_axis_vertical); return player_instance; }