Compare commits
2 Commits
e465b0c1d4
...
68e8f7bf1c
Author | SHA1 | Date |
---|---|---|
|
68e8f7bf1c | |
|
8606b595ab |
|
@ -6,6 +6,10 @@ project(${PROJECT_NAME} C)
|
||||||
set(CMAKE_C_STANDARD 99)
|
set(CMAKE_C_STANDARD 99)
|
||||||
set(RAYLIB_DIR $ENV{HOME}/Documents/Coding/raylib/out/)
|
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
|
set(GAME_LIBS
|
||||||
lib_EC
|
lib_EC
|
||||||
lib_scenes
|
lib_scenes
|
||||||
|
@ -82,43 +86,34 @@ target_link_libraries(scene_test
|
||||||
add_executable(scene_test_mem
|
add_executable(scene_test_mem
|
||||||
scene_test.c
|
scene_test.c
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(scene_test_mem
|
target_include_directories(scene_test_mem
|
||||||
PRIVATE
|
PRIVATE
|
||||||
${CMAKE_CURRENT_LIST_DIR}
|
${CMAKE_CURRENT_LIST_DIR}
|
||||||
${RAYLIB_DIR}/include
|
${RAYLIB_DIR}/include
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_options(scene_test_mem PRIVATE -Xlinker -Map=scene_test.map)
|
target_link_options(scene_test_mem PRIVATE -Xlinker -Map=scene_test.map)
|
||||||
|
|
||||||
target_link_directories(scene_test_mem
|
target_link_directories(scene_test_mem
|
||||||
PRIVATE
|
PRIVATE
|
||||||
${RAYLIB_DIR}/lib
|
${RAYLIB_DIR}/lib
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(scene_test_mem
|
target_link_libraries(scene_test_mem
|
||||||
${GAME_LIBS}
|
${GAME_LIBS}
|
||||||
)
|
)
|
||||||
target_link_options(scene_test PRIVATE -fsanitize=address -gdwarf-4 )
|
|
||||||
|
|
||||||
add_executable(menu_test
|
add_executable(menu_test
|
||||||
menu_test.c
|
menu_test.c
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(menu_test
|
target_include_directories(menu_test
|
||||||
PRIVATE
|
PRIVATE
|
||||||
${CMAKE_CURRENT_LIST_DIR}
|
${CMAKE_CURRENT_LIST_DIR}
|
||||||
${RAYLIB_DIR}/include
|
${RAYLIB_DIR}/include
|
||||||
)
|
)
|
||||||
|
|
||||||
target_compile_options(menu_test PRIVATE -fsanitize=address -gdwarf-4)
|
target_compile_options(menu_test PRIVATE -fsanitize=address -gdwarf-4)
|
||||||
target_link_options(menu_test PRIVATE -fsanitize=address -gdwarf-4)
|
target_link_options(menu_test PRIVATE -fsanitize=address -gdwarf-4)
|
||||||
|
|
||||||
target_link_directories(menu_test
|
target_link_directories(menu_test
|
||||||
PRIVATE
|
PRIVATE
|
||||||
${RAYLIB_DIR}/lib
|
${RAYLIB_DIR}/lib
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(menu_test
|
target_link_libraries(menu_test
|
||||||
${GAME_LIBS}
|
${GAME_LIBS}
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,22 +1,38 @@
|
||||||
// Constants to be used in game
|
// Constants to be used in game
|
||||||
|
#ifndef __CONSTANTS_H
|
||||||
|
#define __CONSTANTS_H
|
||||||
|
#ifndef TILE16_SIZE
|
||||||
#define TILE_SIZE 32
|
#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 GRAV_ACCEL 1500
|
||||||
#define JUMP_SPEED 70
|
#define JUMP_SPEED 70
|
||||||
#define MOVE_ACCEL 1000
|
#define MOVE_ACCEL 1000
|
||||||
#define FRICTION 0.98
|
#define FRICTION 0.98
|
||||||
#define PLAYER_STAND_WIDTH 30
|
|
||||||
|
|
||||||
|
#ifndef TILE16_SIZE
|
||||||
#define PLAYER_WIDTH 30
|
#define PLAYER_WIDTH 30
|
||||||
#define PLAYER_HEIGHT 55
|
#define PLAYER_HEIGHT 55
|
||||||
|
|
||||||
#define PLAYER_C_WIDTH 30
|
#define PLAYER_C_WIDTH 30
|
||||||
#define PLAYER_C_HEIGHT 30
|
#define PLAYER_C_HEIGHT 30
|
||||||
#define PLAYER_C_YOFFSET 25
|
#else
|
||||||
#define PLAYER_C_XOFFSET 0
|
#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 PLAYER_MAX_SPEED 1000
|
||||||
#define Y_FRICTION 0.98
|
#define Y_FRICTION 0.98
|
||||||
#define X_FRICTION 0.85
|
#define X_FRICTION 0.85
|
||||||
|
|
||||||
#define MAX_WATER_LEVEL 4
|
#define MAX_WATER_LEVEL 4
|
||||||
|
#endif // __CONSTANTS_H
|
||||||
|
|
|
@ -212,34 +212,18 @@ void player_movement_input_system(Scene_t* scene)
|
||||||
// Check if possible to jump when jump is pressed
|
// Check if possible to jump when jump is pressed
|
||||||
if (p_pstate->jump_pressed && p_cjump->jumps > 0 && p_cjump->cooldown_timer == 0)
|
if (p_pstate->jump_pressed && p_cjump->jumps > 0 && p_cjump->cooldown_timer == 0)
|
||||||
{
|
{
|
||||||
bool jump_valid = true;
|
p_cjump->jumps--;
|
||||||
|
if (!in_water)
|
||||||
// Check Jump from crouch
|
|
||||||
if(p_pstate->is_crouch & 1)
|
|
||||||
{
|
{
|
||||||
Vector2 test_pos = p_ctransform->position;
|
p_ctransform->velocity.y -= p_cjump->jump_speed;
|
||||||
Vector2 test_bbox = {PLAYER_WIDTH, PLAYER_HEIGHT};
|
}
|
||||||
Vector2 top = {0, -1};
|
else
|
||||||
test_pos.x += PLAYER_C_XOFFSET;
|
{
|
||||||
test_pos.y -= PLAYER_C_YOFFSET;
|
p_ctransform->velocity.y -= p_cjump->jump_speed / 1.75;
|
||||||
jump_valid = !check_collision_at(test_pos, test_bbox, &tilemap, top, &scene->ent_manager);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Jump okay
|
p_cjump->jumped = true;
|
||||||
if (jump_valid)
|
p_cjump->cooldown_timer = 15;
|
||||||
{
|
|
||||||
if (!in_water)
|
|
||||||
{
|
|
||||||
p_ctransform->velocity.y -= p_cjump->jump_speed;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
p_ctransform->velocity.y -= p_cjump->jump_speed / 1.75;
|
|
||||||
}
|
|
||||||
|
|
||||||
p_cjump->jumped = true;
|
|
||||||
p_cjump->cooldown_timer = 15;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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_O, ACTION_PREV_SPAWN);
|
||||||
sc_map_put_64(&scene->scene.action_map, KEY_P, ACTION_NEXT_SPAWN);
|
sc_map_put_64(&scene->scene.action_map, KEY_P, ACTION_NEXT_SPAWN);
|
||||||
|
|
||||||
scene->data.tilemap.width = 32;
|
scene->data.tilemap.width = DEFAULT_MAP_WIDTH;
|
||||||
scene->data.tilemap.height = 16;
|
scene->data.tilemap.height = DEFAULT_MAP_HEIGHT;
|
||||||
assert(32*16 <= MAX_N_TILES);
|
scene->data.tilemap.n_tiles = scene->data.tilemap.width * scene->data.tilemap.height;
|
||||||
scene->data.tilemap.n_tiles = 32*16;
|
assert(scene->data.tilemap.n_tiles <= MAX_N_TILES);
|
||||||
scene->data.tilemap.tiles = all_tiles;
|
scene->data.tilemap.tiles = all_tiles;
|
||||||
for (size_t i=0; i<MAX_N_TILES;i++)
|
for (size_t i=0; i<MAX_N_TILES;i++)
|
||||||
{
|
{
|
||||||
all_tiles[i].solid = 0;
|
all_tiles[i].solid = 0;
|
||||||
sc_map_init_64(&all_tiles[i].entities_set, 16, 0);
|
sc_map_init_64(&all_tiles[i].entities_set, 16, 0);
|
||||||
}
|
}
|
||||||
for (size_t i=0; i<32; ++i)
|
for (size_t i=0; i<scene->data.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);
|
spawn_player(&scene->scene);
|
||||||
|
|
Loading…
Reference in New Issue