diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f321e6..3b2a375 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,10 @@ project(${PROJECT_NAME} C) set(CMAKE_C_STANDARD 99) set(RAYLIB_DIR $ENV{HOME}/Documents/Coding/raylib/out/) +if (${CMAKE_BUILD_TYPE} STREQUAL tile16) + set_directory_properties(PROPERTIES COMPILE_DEFINITIONS TILE16_SIZE) +endif() + set(GAME_LIBS lib_EC lib_scenes @@ -82,43 +86,34 @@ target_link_libraries(scene_test add_executable(scene_test_mem scene_test.c ) - target_include_directories(scene_test_mem PRIVATE ${CMAKE_CURRENT_LIST_DIR} ${RAYLIB_DIR}/include ) - target_link_options(scene_test_mem PRIVATE -Xlinker -Map=scene_test.map) - target_link_directories(scene_test_mem PRIVATE ${RAYLIB_DIR}/lib ) - target_link_libraries(scene_test_mem ${GAME_LIBS} ) -target_link_options(scene_test PRIVATE -fsanitize=address -gdwarf-4 ) add_executable(menu_test menu_test.c ) - target_include_directories(menu_test PRIVATE ${CMAKE_CURRENT_LIST_DIR} ${RAYLIB_DIR}/include ) - target_compile_options(menu_test PRIVATE -fsanitize=address -gdwarf-4) target_link_options(menu_test PRIVATE -fsanitize=address -gdwarf-4) - target_link_directories(menu_test PRIVATE ${RAYLIB_DIR}/lib ) - target_link_libraries(menu_test ${GAME_LIBS} ) diff --git a/engine/constants.h b/engine/constants.h index 354b548..3dc0aaa 100644 --- a/engine/constants.h +++ b/engine/constants.h @@ -1,22 +1,38 @@ // Constants to be used in game +#ifndef __CONSTANTS_H +#define __CONSTANTS_H +#ifndef TILE16_SIZE #define TILE_SIZE 32 +#define DEFAULT_MAP_WIDTH 32 +#define DEFAULT_MAP_HEIGHT 16 +#else +#define TILE_SIZE 16 +#define DEFAULT_MAP_WIDTH 64 +#define DEFAULT_MAP_HEIGHT 32 +#endif #define GRAV_ACCEL 1500 #define JUMP_SPEED 70 #define MOVE_ACCEL 1000 #define FRICTION 0.98 -#define PLAYER_STAND_WIDTH 30 +#ifndef TILE16_SIZE #define PLAYER_WIDTH 30 #define PLAYER_HEIGHT 55 - #define PLAYER_C_WIDTH 30 #define PLAYER_C_HEIGHT 30 -#define PLAYER_C_YOFFSET 25 -#define PLAYER_C_XOFFSET 0 +#else +#define PLAYER_WIDTH 14 +#define PLAYER_HEIGHT 30 +#define PLAYER_C_WIDTH 14 +#define PLAYER_C_HEIGHT 14 +#endif +#define PLAYER_C_YOFFSET (PLAYER_HEIGHT - PLAYER_C_HEIGHT) +#define PLAYER_C_XOFFSET (PLAYER_WIDTH - PLAYER_C_WIDTH) #define PLAYER_MAX_SPEED 1000 #define Y_FRICTION 0.98 #define X_FRICTION 0.85 #define MAX_WATER_LEVEL 4 +#endif // __CONSTANTS_H diff --git a/engine/scene_impl.c b/engine/scene_impl.c index 455ab64..82c8e01 100644 --- a/engine/scene_impl.c +++ b/engine/scene_impl.c @@ -273,19 +273,20 @@ void init_level_scene(LevelScene_t *scene) sc_map_put_64(&scene->scene.action_map, KEY_O, ACTION_PREV_SPAWN); sc_map_put_64(&scene->scene.action_map, KEY_P, ACTION_NEXT_SPAWN); - scene->data.tilemap.width = 32; - scene->data.tilemap.height = 16; - assert(32*16 <= MAX_N_TILES); - scene->data.tilemap.n_tiles = 32*16; + scene->data.tilemap.width = DEFAULT_MAP_WIDTH; + scene->data.tilemap.height = DEFAULT_MAP_HEIGHT; + scene->data.tilemap.n_tiles = scene->data.tilemap.width * scene->data.tilemap.height; + assert(scene->data.tilemap.n_tiles <= MAX_N_TILES); scene->data.tilemap.tiles = all_tiles; for (size_t i=0; idata.tilemap.width; ++i) { - all_tiles[15*32+i].solid = true; // for testing + unsigned int tile_idx = (scene->data.tilemap.height - 1) * scene->data.tilemap.width + i; + all_tiles[tile_idx].solid = true; // for testing } spawn_player(&scene->scene);