Compare commits
8 Commits
963ba34164
...
dee5ebd178
Author | SHA1 | Date |
---|---|---|
|
dee5ebd178 | |
|
567b7ab173 | |
|
e26f972600 | |
|
cf8e2ca1be | |
|
fae37eeecd | |
|
99c34b4107 | |
|
731a84273a | |
|
e6683dfec1 |
|
@ -0,0 +1,131 @@
|
||||||
|
set(PROJECT_NAME HATPC_remake)
|
||||||
|
set(CMAKE_C_COMPILER clang)
|
||||||
|
set(CMAKE_C_FLAGS "-Wall")
|
||||||
|
cmake_minimum_required(VERSION 3.22.1)
|
||||||
|
project(${PROJECT_NAME} C)
|
||||||
|
set(CMAKE_C_STANDARD 99)
|
||||||
|
set(RAYLIB_DIR /usr/local/lib CACHE FILEPATH "directory to Raylib")
|
||||||
|
|
||||||
|
if (${CMAKE_BUILD_TYPE} STREQUAL tile16)
|
||||||
|
set_directory_properties(PROPERTIES COMPILE_DEFINITIONS TILE16_SIZE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(GAME_LIBS
|
||||||
|
lib_scenes
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
add_subdirectory(scenes)
|
||||||
|
add_executable(${PROJECT_NAME}
|
||||||
|
main.c
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(${PROJECT_NAME}
|
||||||
|
PRIVATE
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(${PROJECT_NAME}
|
||||||
|
${GAME_LIBS}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(EntManager_test
|
||||||
|
entManager_test.c
|
||||||
|
)
|
||||||
|
target_compile_options(EntManager_test PRIVATE -fsanitize=address -gdwarf-4)
|
||||||
|
target_link_options(EntManager_test PRIVATE -fsanitize=address -gdwarf-4)
|
||||||
|
target_include_directories(EntManager_test
|
||||||
|
PRIVATE
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}
|
||||||
|
)
|
||||||
|
target_link_libraries(EntManager_test
|
||||||
|
${GAME_LIBS}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(scene_test
|
||||||
|
scene_test.c
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(scene_test
|
||||||
|
PRIVATE
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_compile_options(scene_test PRIVATE -fsanitize=address -gdwarf-4)
|
||||||
|
target_link_options(scene_test PRIVATE -fsanitize=address -gdwarf-4)
|
||||||
|
|
||||||
|
target_link_libraries(scene_test
|
||||||
|
${GAME_LIBS}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(scene_test_mem
|
||||||
|
scene_test.c
|
||||||
|
)
|
||||||
|
target_include_directories(scene_test_mem
|
||||||
|
PRIVATE
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}
|
||||||
|
)
|
||||||
|
target_link_options(scene_test_mem PRIVATE -Xlinker -Map=scene_test.map)
|
||||||
|
|
||||||
|
target_link_libraries(scene_test_mem
|
||||||
|
${GAME_LIBS}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(water_test
|
||||||
|
water_test.c
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(water_test
|
||||||
|
PRIVATE
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}
|
||||||
|
)
|
||||||
|
target_link_libraries(water_test
|
||||||
|
${GAME_LIBS}
|
||||||
|
)
|
||||||
|
target_compile_options(water_test PRIVATE -fsanitize=address -gdwarf-4)
|
||||||
|
target_link_options(water_test PRIVATE -fsanitize=address -gdwarf-4)
|
||||||
|
|
||||||
|
add_executable(level_load_test
|
||||||
|
level_load_test.c
|
||||||
|
)
|
||||||
|
target_include_directories(level_load_test
|
||||||
|
PRIVATE
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}
|
||||||
|
)
|
||||||
|
target_link_libraries(level_load_test
|
||||||
|
${GAME_LIBS}
|
||||||
|
)
|
||||||
|
target_compile_options(level_load_test PRIVATE -fsanitize=address -gdwarf-4)
|
||||||
|
target_link_options(level_load_test PRIVATE -fsanitize=address -gdwarf-4)
|
||||||
|
|
||||||
|
add_executable(menu_test
|
||||||
|
menu_test.c
|
||||||
|
)
|
||||||
|
target_include_directories(menu_test
|
||||||
|
PRIVATE
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}
|
||||||
|
)
|
||||||
|
target_compile_options(menu_test PRIVATE -fsanitize=address -gdwarf-4)
|
||||||
|
target_link_options(menu_test PRIVATE -fsanitize=address -gdwarf-4)
|
||||||
|
target_link_libraries(menu_test
|
||||||
|
${GAME_LIBS}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(assets_test
|
||||||
|
assets_test.c
|
||||||
|
)
|
||||||
|
target_include_directories(assets_test
|
||||||
|
PRIVATE
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}
|
||||||
|
)
|
||||||
|
target_compile_options(assets_test PRIVATE -fsanitize=address -gdwarf-4)
|
||||||
|
target_link_options(assets_test PRIVATE -fsanitize=address -gdwarf-4)
|
||||||
|
target_link_libraries(assets_test
|
||||||
|
${GAME_LIBS}
|
||||||
|
)
|
||||||
|
|
||||||
|
if (BUILD_TESTING)
|
||||||
|
find_package(cmocka 1.1.0 REQUIRED)
|
||||||
|
add_subdirectory(tests)
|
||||||
|
endif()
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
set(PROJECT_NAME HATPC_remake)
|
||||||
|
set(CMAKE_C_FLAGS "-Wall")
|
||||||
|
cmake_minimum_required(VERSION 3.22.1)
|
||||||
|
project(${PROJECT_NAME} C)
|
||||||
|
set(CMAKE_C_STANDARD 99)
|
||||||
|
set(RAYLIB_DIR /usr/local/lib CACHE FILEPATH "directory to Raylib")
|
||||||
|
|
||||||
|
if (EMSCRIPTEN)
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s ASYNCIFY")
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s ASYNCIFY")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s ASYNCIFY")
|
||||||
|
set(CMAKE_EXECUTABLE_SUFFIX ".html")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
set(GAME_LIBS
|
||||||
|
lib_scenes
|
||||||
|
)
|
||||||
|
|
||||||
|
add_subdirectory(scenes)
|
||||||
|
add_executable(scene_test
|
||||||
|
scene_test.c
|
||||||
|
)
|
||||||
|
target_include_directories(scene_test
|
||||||
|
PRIVATE
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}
|
||||||
|
)
|
||||||
|
target_com
|
||||||
|
target_link_libraries(scene_test
|
||||||
|
${GAME_LIBS}
|
||||||
|
)
|
42
scene_test.c
42
scene_test.c
|
@ -4,6 +4,9 @@
|
||||||
#include "assets_loader.h"
|
#include "assets_loader.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#if defined(PLATFORM_WEB)
|
||||||
|
#include <emscripten/emscripten.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
Scene_t* scenes[1];
|
Scene_t* scenes[1];
|
||||||
|
@ -15,6 +18,17 @@ static GameEngine_t engine =
|
||||||
.assets = {0}
|
.assets = {0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void update_loop(void)
|
||||||
|
{
|
||||||
|
Scene_t* scene = engine.scenes[engine.curr_scene];
|
||||||
|
process_inputs(&engine, scene);
|
||||||
|
|
||||||
|
update_scene(scene);
|
||||||
|
update_entity_manager(&scene->ent_manager);
|
||||||
|
// This is needed to advance time delta
|
||||||
|
render_scene(scene);
|
||||||
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
init_engine(&engine);
|
init_engine(&engine);
|
||||||
|
@ -39,22 +53,26 @@ int main(void)
|
||||||
scenes[0] = &scene.scene;
|
scenes[0] = &scene.scene;
|
||||||
change_scene(&engine, 0);
|
change_scene(&engine, 0);
|
||||||
|
|
||||||
|
#if defined(PLATFORM_WEB)
|
||||||
|
emscripten_set_main_loop(update_loop, 0, 1);
|
||||||
|
#else
|
||||||
|
while(true)
|
||||||
|
{
|
||||||
|
|
||||||
while(true)
|
// This entire key processing relies on the assumption that a pressed key will
|
||||||
{
|
// appear in the polling of raylib
|
||||||
|
process_inputs(&engine, &scene.scene);
|
||||||
|
|
||||||
// This entire key processing relies on the assumption that a pressed key will
|
update_scene(&scene.scene);
|
||||||
// appear in the polling of raylib
|
update_entity_manager(&scene.scene.ent_manager);
|
||||||
process_inputs(&engine, &scene.scene);
|
// This is needed to advance time delta
|
||||||
|
render_scene(&scene.scene);
|
||||||
update_scene(&scene.scene);
|
if (WindowShouldClose()) break;
|
||||||
update_entity_manager(&scene.scene.ent_manager);
|
}
|
||||||
// This is needed to advance time delta
|
#endif
|
||||||
render_scene(&scene.scene);
|
|
||||||
if (WindowShouldClose()) break;
|
|
||||||
}
|
|
||||||
free_sandbox_scene(&scene);
|
free_sandbox_scene(&scene);
|
||||||
deinit_engine(&engine);
|
deinit_engine(&engine);
|
||||||
term_assets(&engine.assets);
|
term_assets(&engine.assets);
|
||||||
CloseWindow();
|
CloseWindow();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
if (EMSCRIPTEN)
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_WEB")
|
||||||
|
endif ()
|
||||||
|
|
||||||
add_subdirectory(engine)
|
add_subdirectory(engine)
|
||||||
add_library(lib_scenes STATIC
|
add_library(lib_scenes STATIC
|
||||||
assets_loader.c
|
assets_loader.c
|
||||||
|
|
|
@ -75,98 +75,118 @@ static inline unsigned int get_tile_idx(int x, int y, const TileGrid_t* tilemap)
|
||||||
return MAX_N_TILES;
|
return MAX_N_TILES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static RenderTexture2D selection_section;
|
||||||
static void level_scene_render_func(Scene_t* scene)
|
static void level_scene_render_func(Scene_t* scene)
|
||||||
{
|
{
|
||||||
LevelSceneData_t* data = &(CONTAINER_OF(scene, LevelScene_t, scene)->data);
|
LevelSceneData_t* data = &(CONTAINER_OF(scene, LevelScene_t, scene)->data);
|
||||||
TileGrid_t tilemap = data->tilemap;
|
TileGrid_t tilemap = data->tilemap;
|
||||||
|
|
||||||
Entity_t* p_ent;
|
Entity_t* p_ent;
|
||||||
|
Vector2 min = GetScreenToWorld2D((Vector2){data->game_rec.x, data->game_rec.y}, data->cam);
|
||||||
|
Vector2 max = GetScreenToWorld2D(
|
||||||
|
(Vector2){
|
||||||
|
data->game_rec.x + data->game_rec.width,
|
||||||
|
data->game_rec.y + data->game_rec.height
|
||||||
|
},
|
||||||
|
data->cam
|
||||||
|
);
|
||||||
|
min = Vector2Scale(min, 1.0f/tilemap.tile_size);
|
||||||
|
max = Vector2Scale(max, 1.0f/tilemap.tile_size);
|
||||||
|
min.x = (int)fmax(0, min.x - 1);
|
||||||
|
min.y = (int)fmax(0, min.y - 1);
|
||||||
|
max.x = (int)fmin(tilemap.width-1, max.x + 1);
|
||||||
|
max.y = (int)fmin(tilemap.height-1, max.y + 1);
|
||||||
|
|
||||||
BeginTextureMode(data->game_viewport);
|
BeginTextureMode(data->game_viewport);
|
||||||
ClearBackground(WHITE);
|
ClearBackground(WHITE);
|
||||||
BeginMode2D(data->cam);
|
BeginMode2D(data->cam);
|
||||||
for (size_t i = 0; i < tilemap.n_tiles; ++i)
|
for (int tile_y = min.y; tile_y <= max.y; tile_y++)
|
||||||
{
|
{
|
||||||
char buffer[6] = {0};
|
for (int tile_x = min.x; tile_x <= max.x; tile_x++)
|
||||||
int x = (i % tilemap.width) * TILE_SIZE;
|
|
||||||
int y = (i / tilemap.width) * TILE_SIZE;
|
|
||||||
sprintf(buffer, "%u", sc_map_size_64v(&tilemap.tiles[i].entities_set));
|
|
||||||
|
|
||||||
if (!tilemap.tiles[i].moveable)
|
|
||||||
{
|
{
|
||||||
|
int i = tile_x + tile_y * tilemap.width;
|
||||||
|
int x = tile_x * TILE_SIZE;
|
||||||
|
int y = tile_y * TILE_SIZE;
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(PLATFORM_WEB)
|
||||||
|
if (!tilemap.tiles[i].moveable)
|
||||||
|
{
|
||||||
|
// Draw water tile
|
||||||
|
Color water_colour = ColorAlpha(RED, 0.2);
|
||||||
|
DrawRectangle(x, y, TILE_SIZE, TILE_SIZE, water_colour);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint8_t tile_sprite_idx = tilemap.tiles[i].tile_type + tilemap.tiles[i].rotation;
|
||||||
|
if (data->tile_sprites[tile_sprite_idx] != NULL)
|
||||||
|
{
|
||||||
|
draw_sprite(data->tile_sprites[tile_sprite_idx], (Vector2){x,y}, false);
|
||||||
|
}
|
||||||
|
else if (tilemap.tiles[i].tile_type == SOLID_TILE)
|
||||||
|
{
|
||||||
|
DrawRectangle(x, y, TILE_SIZE, TILE_SIZE, BLACK);
|
||||||
|
}
|
||||||
|
else if (tilemap.tiles[i].tile_type == ONEWAY_TILE)
|
||||||
|
{
|
||||||
|
DrawRectangle(x, y, TILE_SIZE, TILE_SIZE, MAROON);
|
||||||
|
}
|
||||||
|
else if (tilemap.tiles[i].tile_type == LADDER)
|
||||||
|
{
|
||||||
|
DrawRectangle(x, y, TILE_SIZE, TILE_SIZE, ORANGE);
|
||||||
|
}
|
||||||
|
else if (tilemap.tiles[i].tile_type == SPIKES)
|
||||||
|
{
|
||||||
|
DrawRectangle(
|
||||||
|
x + tilemap.tiles[i].offset.x, y + tilemap.tiles[i].offset.y,
|
||||||
|
tilemap.tiles[i].size.x, tilemap.tiles[i].size.y, RED
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (tilemap.tiles[i].wet)
|
||||||
|
{
|
||||||
|
#define SURFACE_THICKNESS 4
|
||||||
|
int up = i - tilemap.width;
|
||||||
|
int bot = i + tilemap.width;
|
||||||
|
int right = i + 1;
|
||||||
|
int left = i - 1;
|
||||||
|
int bot_line = y + TILE_SIZE - tilemap.tiles[i].water_level * WATER_BBOX_STEP - SURFACE_THICKNESS / 2;
|
||||||
|
if (up >= 0 && tilemap.tiles[up].wet)
|
||||||
|
{
|
||||||
|
DrawLineEx((Vector2){x + TILE_SIZE / 2, y}, (Vector2){x + TILE_SIZE / 2, y + TILE_SIZE - tilemap.tiles[i].water_level * WATER_BBOX_STEP}, SURFACE_THICKNESS, ColorAlpha(BLUE, 0.7));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (
|
||||||
|
bot <= tilemap.n_tiles
|
||||||
|
&& tilemap.tiles[i].water_level == 0
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (i % tilemap.width != 0 && tilemap.tiles[left].wet && (tilemap.tiles[bot].solid == SOLID || tilemap.tiles[bot-1].solid == SOLID))
|
||||||
|
{
|
||||||
|
DrawLineEx((Vector2){x, bot_line}, (Vector2){x + TILE_SIZE / 2, bot_line}, SURFACE_THICKNESS, ColorAlpha(BLUE, 0.7));
|
||||||
|
}
|
||||||
|
if (right % tilemap.width != 0 && tilemap.tiles[right].wet && (tilemap.tiles[bot].solid == SOLID || tilemap.tiles[bot+1].solid == SOLID))
|
||||||
|
{
|
||||||
|
DrawLineEx((Vector2){x + TILE_SIZE / 2, bot_line}, (Vector2){x + TILE_SIZE, bot_line}, SURFACE_THICKNESS, ColorAlpha(BLUE, 0.7));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Draw water tile
|
// Draw water tile
|
||||||
Color water_colour = ColorAlpha(RED, 0.2);
|
uint32_t water_height = tilemap.tiles[i].water_level * WATER_BBOX_STEP;
|
||||||
DrawRectangle(x, y, TILE_SIZE, TILE_SIZE, water_colour);
|
// Draw water tile
|
||||||
}
|
Color water_colour = ColorAlpha(BLUE, 0.5);
|
||||||
|
|
||||||
uint8_t tile_sprite_idx = tilemap.tiles[i].tile_type + tilemap.tiles[i].rotation;
|
|
||||||
if (data->tile_sprites[tile_sprite_idx] != NULL)
|
|
||||||
{
|
|
||||||
draw_sprite(data->tile_sprites[tile_sprite_idx], (Vector2){x,y}, false);
|
|
||||||
}
|
|
||||||
else if (tilemap.tiles[i].tile_type == SOLID_TILE)
|
|
||||||
{
|
|
||||||
DrawRectangle(x, y, TILE_SIZE, TILE_SIZE, BLACK);
|
|
||||||
}
|
|
||||||
else if (tilemap.tiles[i].tile_type == ONEWAY_TILE)
|
|
||||||
{
|
|
||||||
DrawRectangle(x, y, TILE_SIZE, TILE_SIZE, MAROON);
|
|
||||||
}
|
|
||||||
else if (tilemap.tiles[i].tile_type == LADDER)
|
|
||||||
{
|
|
||||||
DrawRectangle(x, y, TILE_SIZE, TILE_SIZE, ORANGE);
|
|
||||||
}
|
|
||||||
else if (tilemap.tiles[i].tile_type == SPIKES)
|
|
||||||
{
|
|
||||||
DrawRectangle(
|
DrawRectangle(
|
||||||
x + tilemap.tiles[i].offset.x, y + tilemap.tiles[i].offset.y,
|
x,
|
||||||
tilemap.tiles[i].size.x, tilemap.tiles[i].size.y, RED
|
y + (TILE_SIZE - water_height),
|
||||||
|
TILE_SIZE,
|
||||||
|
water_height,
|
||||||
|
water_colour
|
||||||
);
|
);
|
||||||
}
|
if (tilemap.tiles[i].max_water_level < MAX_WATER_LEVEL)
|
||||||
if (tilemap.tiles[i].wet)
|
|
||||||
{
|
|
||||||
#define SURFACE_THICKNESS 4
|
|
||||||
int up = i - tilemap.width;
|
|
||||||
int bot = i + tilemap.width;
|
|
||||||
int right = i + 1;
|
|
||||||
int left = i - 1;
|
|
||||||
int bot_line = y + TILE_SIZE - tilemap.tiles[i].water_level * WATER_BBOX_STEP - SURFACE_THICKNESS / 2;
|
|
||||||
if (up >= 0 && tilemap.tiles[up].wet)
|
|
||||||
{
|
{
|
||||||
DrawLineEx((Vector2){x + TILE_SIZE / 2, y}, (Vector2){x + TILE_SIZE / 2, y + TILE_SIZE - tilemap.tiles[i].water_level * WATER_BBOX_STEP}, SURFACE_THICKNESS, ColorAlpha(BLUE, 0.7));
|
DrawRectangleLinesEx((Rectangle){x, y, TILE_SIZE, TILE_SIZE}, 2.0, ColorAlpha(BLUE, 0.5));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (
|
|
||||||
bot <= tilemap.n_tiles
|
|
||||||
&& tilemap.tiles[i].water_level == 0
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (i % tilemap.width != 0 && tilemap.tiles[left].wet && (tilemap.tiles[bot].solid == SOLID || tilemap.tiles[bot-1].solid == SOLID))
|
|
||||||
{
|
|
||||||
DrawLineEx((Vector2){x, bot_line}, (Vector2){x + TILE_SIZE / 2, bot_line}, SURFACE_THICKNESS, ColorAlpha(BLUE, 0.7));
|
|
||||||
}
|
|
||||||
if (right % tilemap.width != 0 && tilemap.tiles[right].wet && (tilemap.tiles[bot].solid == SOLID || tilemap.tiles[bot+1].solid == SOLID))
|
|
||||||
{
|
|
||||||
DrawLineEx((Vector2){x + TILE_SIZE / 2, bot_line}, (Vector2){x + TILE_SIZE, bot_line}, SURFACE_THICKNESS, ColorAlpha(BLUE, 0.7));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw water tile
|
|
||||||
uint32_t water_height = tilemap.tiles[i].water_level * WATER_BBOX_STEP;
|
|
||||||
// Draw water tile
|
|
||||||
Color water_colour = ColorAlpha(BLUE, 0.5);
|
|
||||||
DrawRectangle(
|
|
||||||
x,
|
|
||||||
y + (TILE_SIZE - water_height),
|
|
||||||
TILE_SIZE,
|
|
||||||
water_height,
|
|
||||||
water_colour
|
|
||||||
);
|
|
||||||
if (tilemap.tiles[i].max_water_level < MAX_WATER_LEVEL)
|
|
||||||
{
|
|
||||||
DrawRectangleLinesEx((Rectangle){x, y, TILE_SIZE, TILE_SIZE}, 2.0, ColorAlpha(BLUE, 0.5));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,6 +195,15 @@ static void level_scene_render_func(Scene_t* scene)
|
||||||
{
|
{
|
||||||
CTransform_t* p_ct = get_component(p_ent, CTRANSFORM_COMP_T);
|
CTransform_t* p_ct = get_component(p_ent, CTRANSFORM_COMP_T);
|
||||||
CBBox_t* p_bbox = get_component(p_ent, CBBOX_COMP_T);
|
CBBox_t* p_bbox = get_component(p_ent, CBBOX_COMP_T);
|
||||||
|
|
||||||
|
// TODO: Figure out better way to cull this
|
||||||
|
//if (
|
||||||
|
// p_ct->position.x + p_bbox < min.x * tilemap.tile_size
|
||||||
|
// || p_ct->position.x + p_bbox->size.x > max.x * tilemap.tile_size
|
||||||
|
// || p_ct->position.y < min.y * tilemap.tile_size
|
||||||
|
// || p_ct->position.y + p_bbox->size.y > max.y * tilemap.tile_size
|
||||||
|
//) continue;
|
||||||
|
|
||||||
Color colour;
|
Color colour;
|
||||||
switch(p_ent->m_tag)
|
switch(p_ent->m_tag)
|
||||||
{
|
{
|
||||||
|
@ -301,30 +330,35 @@ static void level_scene_render_func(Scene_t* scene)
|
||||||
unsigned int y = ((p_runner->current_tile) / tilemap.width) * tilemap.tile_size;
|
unsigned int y = ((p_runner->current_tile) / tilemap.width) * tilemap.tile_size;
|
||||||
DrawCircle(x+16, y+16, 8, ColorAlpha(BLUE, 0.6));
|
DrawCircle(x+16, y+16, 8, ColorAlpha(BLUE, 0.6));
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < tilemap.n_tiles; ++i)
|
for (int tile_y = min.y; tile_y <= max.y; tile_y++)
|
||||||
{
|
{
|
||||||
int x = (i % tilemap.width) * TILE_SIZE;
|
for (int tile_x = min.x; tile_x <= max.x; tile_x++)
|
||||||
int y = (i / tilemap.width) * TILE_SIZE;
|
{
|
||||||
sprintf(buffer, "%u", sc_map_size_64v(&tilemap.tiles[i].entities_set));
|
int i = tile_x + tile_y * tilemap.width;
|
||||||
|
int x = tile_x * TILE_SIZE;
|
||||||
|
int y = tile_y * TILE_SIZE;
|
||||||
|
|
||||||
if (tilemap.tiles[i].solid > 0)
|
sprintf(buffer, "%u", sc_map_size_64v(&tilemap.tiles[i].entities_set));
|
||||||
{
|
|
||||||
DrawText(buffer, x, y, 10, WHITE);
|
if (tilemap.tiles[i].solid > 0)
|
||||||
}
|
{
|
||||||
else
|
DrawText(buffer, x, y, 10, WHITE);
|
||||||
{
|
}
|
||||||
// Draw water tile
|
else
|
||||||
DrawText(buffer, x, y, 10, BLACK);
|
{
|
||||||
|
// Draw water tile
|
||||||
|
DrawText(buffer, x, y, 10, BLACK);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw tile grid
|
// Draw tile grid
|
||||||
for (size_t i = 0; i < tilemap.width; ++i)
|
for (size_t i = min.x; i < max.x; ++i)
|
||||||
{
|
{
|
||||||
int x = (i+1)*TILE_SIZE;
|
int x = (i+1)*TILE_SIZE;
|
||||||
DrawLine(x, 0, x, tilemap.height * TILE_SIZE, BLACK);
|
DrawLine(x, 0, x, tilemap.height * TILE_SIZE, BLACK);
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < tilemap.height;++i)
|
for (size_t i = min.y; i < max.y;++i)
|
||||||
{
|
{
|
||||||
int y = (i+1)*TILE_SIZE;
|
int y = (i+1)*TILE_SIZE;
|
||||||
DrawLine(0, y, tilemap.width * TILE_SIZE, y, BLACK);
|
DrawLine(0, y, tilemap.width * TILE_SIZE, y, BLACK);
|
||||||
|
@ -344,152 +378,36 @@ static void level_scene_render_func(Scene_t* scene)
|
||||||
(Vector2){data->game_rec.x, data->game_rec.y},
|
(Vector2){data->game_rec.x, data->game_rec.y},
|
||||||
WHITE
|
WHITE
|
||||||
);
|
);
|
||||||
|
draw_rec.width = SELECTION_REGION_WIDTH;
|
||||||
|
draw_rec.height = -(SELECTION_REGION_HEIGHT * 2 + 10);
|
||||||
|
|
||||||
|
|
||||||
Vector2 draw_pos = {data->game_rec.x, data->game_rec.y + data->game_rec.height + SELECTION_GAP};
|
Vector2 draw_pos = {data->game_rec.x, data->game_rec.y + data->game_rec.height + SELECTION_GAP};
|
||||||
const Color crate_colour = metal_toggle ? GRAY : BROWN;
|
DrawTextureRec(
|
||||||
const Color draw_colour[MAX_SPAWN_TYPE] = {
|
selection_section.texture,
|
||||||
BLACK, MAROON, ORANGE, ColorAlpha(RAYWHITE, 0.5), ColorAlpha(BLUE, 0.5), ColorAlpha(RAYWHITE, 0.5),
|
draw_rec,
|
||||||
crate_colour, crate_colour, crate_colour, crate_colour, crate_colour, crate_colour,
|
draw_pos,
|
||||||
ColorAlpha(RAYWHITE, 0.5), ColorAlpha(RAYWHITE, 0.5)
|
WHITE
|
||||||
};
|
);
|
||||||
for (uint8_t i = 0; i < MAX_SPAWN_TYPE; ++i)
|
|
||||||
{
|
draw_pos.x = data->game_rec.x + current_spawn_selection * SELECTION_TILE_SIZE;
|
||||||
if (i != current_spawn_selection)
|
DrawRectangleLines(
|
||||||
{
|
draw_pos.x, draw_pos.y,
|
||||||
DrawRectangle(draw_pos.x, draw_pos.y, SELECTION_TILE_SIZE, SELECTION_TILE_SIZE, draw_colour[i]);
|
SELECTION_TILE_SIZE, SELECTION_TILE_SIZE, GREEN
|
||||||
Vector2 half_size = {SELECTION_TILE_HALFSIZE, SELECTION_TILE_HALFSIZE};
|
|
||||||
switch (i)
|
|
||||||
{
|
|
||||||
case TOGGLE_SPIKE:
|
|
||||||
DrawRectangle(draw_pos.x, draw_pos.y + SELECTION_TILE_HALFSIZE, SELECTION_TILE_SIZE, SELECTION_TILE_HALFSIZE, RED);
|
|
||||||
break;
|
|
||||||
case SPAWN_BOULDER:
|
|
||||||
DrawCircleV(Vector2Add(draw_pos, half_size), half_size.x, GRAY);
|
|
||||||
break;
|
|
||||||
case SPAWN_CRATE_ARROW_L:
|
|
||||||
DrawLine(
|
|
||||||
draw_pos.x,
|
|
||||||
draw_pos.y + half_size.y,
|
|
||||||
draw_pos.x + half_size.x,
|
|
||||||
draw_pos.y + half_size.y,
|
|
||||||
BLACK
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case SPAWN_CRATE_ARROW_R:
|
|
||||||
DrawLine(
|
|
||||||
draw_pos.x + half_size.x,
|
|
||||||
draw_pos.y + half_size.y,
|
|
||||||
draw_pos.x + half_size.x * 2,
|
|
||||||
draw_pos.y + half_size.y,
|
|
||||||
BLACK
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case SPAWN_CRATE_ARROW_U:
|
|
||||||
DrawLine(
|
|
||||||
draw_pos.x + half_size.x,
|
|
||||||
draw_pos.y,
|
|
||||||
draw_pos.x + half_size.x,
|
|
||||||
draw_pos.y + half_size.y,
|
|
||||||
BLACK
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case SPAWN_CRATE_ARROW_D:
|
|
||||||
DrawLine(
|
|
||||||
draw_pos.x + half_size.x,
|
|
||||||
draw_pos.y + half_size.y,
|
|
||||||
draw_pos.x + half_size.x,
|
|
||||||
draw_pos.y + half_size.y * 2,
|
|
||||||
BLACK
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case SPAWN_CRATE_BOMB:
|
|
||||||
DrawCircleV(Vector2Add(draw_pos, half_size), half_size.x, BLACK);
|
|
||||||
break;
|
|
||||||
case SPAWN_WATER_RUNNER:
|
|
||||||
DrawCircleV(Vector2Add(draw_pos, half_size), half_size.x, ColorAlpha(BLUE, 0.2));
|
|
||||||
break;
|
|
||||||
case TOGGLE_AIR_POCKET:
|
|
||||||
DrawRectangleLinesEx((Rectangle){draw_pos.x, draw_pos.y, SELECTION_TILE_SIZE, SELECTION_TILE_SIZE}, 2.0, ColorAlpha(BLUE, 0.5));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
draw_pos.x += SELECTION_TILE_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
draw_pos.x = data->game_rec.x + current_spawn_selection * SELECTION_TILE_SIZE;
|
|
||||||
DrawRectangle(
|
|
||||||
draw_pos.x - 2, draw_pos.y - 2,
|
|
||||||
SELECTION_TILE_SIZE + 4, SELECTION_TILE_SIZE + 4, GREEN
|
|
||||||
);
|
);
|
||||||
DrawRectangle(draw_pos.x, draw_pos.y, SELECTION_TILE_SIZE, SELECTION_TILE_SIZE, draw_colour[current_spawn_selection]);
|
|
||||||
const Vector2 half_size = {SELECTION_TILE_HALFSIZE, SELECTION_TILE_HALFSIZE};
|
|
||||||
switch (current_spawn_selection)
|
|
||||||
{
|
|
||||||
case TOGGLE_SPIKE:
|
|
||||||
DrawRectangle(draw_pos.x, draw_pos.y + SELECTION_TILE_HALFSIZE, SELECTION_TILE_SIZE, SELECTION_TILE_HALFSIZE, RED);
|
|
||||||
break;
|
|
||||||
case SPAWN_BOULDER:
|
|
||||||
DrawCircleV(Vector2Add(draw_pos, half_size), half_size.x, GRAY);
|
|
||||||
break;
|
|
||||||
case SPAWN_CRATE_ARROW_L:
|
|
||||||
DrawLine(
|
|
||||||
draw_pos.x,
|
|
||||||
draw_pos.y + half_size.y,
|
|
||||||
draw_pos.x + half_size.x,
|
|
||||||
draw_pos.y + half_size.y,
|
|
||||||
BLACK
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case SPAWN_CRATE_ARROW_R:
|
|
||||||
DrawLine(
|
|
||||||
draw_pos.x + half_size.x,
|
|
||||||
draw_pos.y + half_size.y,
|
|
||||||
draw_pos.x + half_size.x * 2,
|
|
||||||
draw_pos.y + half_size.y,
|
|
||||||
BLACK
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case SPAWN_CRATE_ARROW_U:
|
|
||||||
DrawLine(
|
|
||||||
draw_pos.x + half_size.x,
|
|
||||||
draw_pos.y,
|
|
||||||
draw_pos.x + half_size.x,
|
|
||||||
draw_pos.y + half_size.y,
|
|
||||||
BLACK
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case SPAWN_CRATE_ARROW_D:
|
|
||||||
DrawLine(
|
|
||||||
draw_pos.x + half_size.x,
|
|
||||||
draw_pos.y + half_size.y,
|
|
||||||
draw_pos.x + half_size.x,
|
|
||||||
draw_pos.y + half_size.y * 2,
|
|
||||||
BLACK
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case SPAWN_CRATE_BOMB:
|
|
||||||
DrawCircleV(Vector2Add(draw_pos, half_size), half_size.x, BLACK);
|
|
||||||
break;
|
|
||||||
case SPAWN_WATER_RUNNER:
|
|
||||||
DrawCircleV(Vector2Add(draw_pos, half_size), half_size.x, ColorAlpha(BLUE, 0.2));
|
|
||||||
break;
|
|
||||||
case TOGGLE_AIR_POCKET:
|
|
||||||
DrawRectangleLinesEx((Rectangle){draw_pos.x, draw_pos.y, SELECTION_TILE_SIZE, SELECTION_TILE_SIZE}, 2.0, ColorAlpha(BLUE, 0.5));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
draw_pos.x = data->game_rec.x + (MAX_SPAWN_TYPE + 1) * SELECTION_TILE_SIZE;
|
draw_pos.x = data->game_rec.x + (MAX_SPAWN_TYPE + 1) * SELECTION_TILE_SIZE;
|
||||||
sprintf(buffer, "Crate %s on spawn", crate_activation? "active" : "inactive");
|
|
||||||
DrawText(buffer, draw_pos.x, draw_pos.y, 20, BLACK);
|
|
||||||
draw_pos.x = data->game_rec.x;
|
|
||||||
draw_pos.y += SELECTION_TILE_SIZE + 5;
|
|
||||||
sprintf(buffer, "Selection: %s", get_spawn_selection_string(current_spawn_selection));
|
sprintf(buffer, "Selection: %s", get_spawn_selection_string(current_spawn_selection));
|
||||||
DrawText(buffer, draw_pos.x, draw_pos.y, 20, BLACK);
|
DrawText(buffer, draw_pos.x, draw_pos.y, 20, BLACK);
|
||||||
draw_pos.x = data->game_rec.x + (MAX_SPAWN_TYPE + 1) * SELECTION_TILE_SIZE;
|
draw_pos.y += SELECTION_TILE_SIZE + 5;
|
||||||
DrawText("Press R to reset the map\nO,P to cycle the selection, T to toggle crate spawn behaviour", draw_pos.x, draw_pos.y, 16, BLACK);
|
sprintf(buffer, "Crate %s on spawn", crate_activation? "active" : "inactive");
|
||||||
|
DrawText(buffer, draw_pos.x, draw_pos.y, 20, BLACK);
|
||||||
|
|
||||||
// For DEBUG
|
// For DEBUG
|
||||||
const int gui_x = data->game_rec.x + data->game_rec.width + 10;
|
const int gui_x = data->game_rec.x + data->game_rec.width + 10;
|
||||||
|
int gui_y = 15;
|
||||||
|
|
||||||
|
#if !defined(PLATFORM_WEB)
|
||||||
sc_map_foreach_value(&scene->ent_manager.entities_map[PLAYER_ENT_TAG], p_ent)
|
sc_map_foreach_value(&scene->ent_manager.entities_map[PLAYER_ENT_TAG], p_ent)
|
||||||
{
|
{
|
||||||
CTransform_t* p_ct = get_component(p_ent, CTRANSFORM_COMP_T);
|
CTransform_t* p_ct = get_component(p_ent, CTRANSFORM_COMP_T);
|
||||||
|
@ -497,30 +415,37 @@ static void level_scene_render_func(Scene_t* scene)
|
||||||
CPlayerState_t* p_pstate = get_component(p_ent, CPLAYERSTATE_T);
|
CPlayerState_t* p_pstate = get_component(p_ent, CPLAYERSTATE_T);
|
||||||
CMovementState_t* p_mstate = get_component(p_ent, CMOVEMENTSTATE_T);
|
CMovementState_t* p_mstate = get_component(p_ent, CMOVEMENTSTATE_T);
|
||||||
sprintf(buffer, "Pos: %.3f\n %.3f", p_ct->position.x, p_ct->position.y);
|
sprintf(buffer, "Pos: %.3f\n %.3f", p_ct->position.x, p_ct->position.y);
|
||||||
DrawText(buffer, gui_x, 15, 12, BLACK);
|
DrawText(buffer, gui_x, gui_y, 12, BLACK);
|
||||||
sprintf(buffer, "Vel: %.3f\n %.3f", p_ct->velocity.x, p_ct->velocity.y);
|
sprintf(buffer, "Vel: %.3f\n %.3f", p_ct->velocity.x, p_ct->velocity.y);
|
||||||
DrawText(buffer, gui_x + 80, 15, 12, BLACK);
|
DrawText(buffer, gui_x + 80, gui_y, 12, BLACK);
|
||||||
//sprintf(buffer, "Accel: %.3f\n %.3f", p_ct->accel.x, p_ct->accel.y);
|
|
||||||
//DrawText(buffer, tilemap.width * TILE_SIZE + 128, 60, 12, BLACK);
|
gui_y += 45;
|
||||||
sprintf(buffer, "Jumps: %u", p_cjump->jumps);
|
sprintf(buffer, "Jumps: %u", p_cjump->jumps);
|
||||||
DrawText(buffer, gui_x, 60, 12, BLACK);
|
DrawText(buffer, gui_x, gui_y, 12, BLACK);
|
||||||
|
gui_y += 30;
|
||||||
sprintf(buffer, "Crouch: %u", p_pstate->is_crouch);
|
sprintf(buffer, "Crouch: %u", p_pstate->is_crouch);
|
||||||
DrawText(buffer, gui_x, 90, 12, BLACK);
|
DrawText(buffer, gui_x, gui_y, 12, BLACK);
|
||||||
|
gui_y += 30;
|
||||||
sprintf(buffer, "Water: %s", p_mstate->water_state & 1? "YES":"NO");
|
sprintf(buffer, "Water: %s", p_mstate->water_state & 1? "YES":"NO");
|
||||||
DrawText(buffer, gui_x, 120, 12, BLACK);
|
DrawText(buffer, gui_x, gui_y, 12, BLACK);
|
||||||
|
gui_y += 30;
|
||||||
sprintf(buffer, "Ladder: %u", p_pstate->ladder_state);
|
sprintf(buffer, "Ladder: %u", p_pstate->ladder_state);
|
||||||
DrawText(buffer, gui_x, 150, 12, BLACK);
|
DrawText(buffer, gui_x, gui_y, 12, BLACK);
|
||||||
|
gui_y += 30;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
//sprintf(buffer, "Spawn Entity: %s", get_spawn_selection_string(current_spawn_selection));
|
//sprintf(buffer, "Spawn Entity: %s", get_spawn_selection_string(current_spawn_selection));
|
||||||
//DrawText(buffer, gui_x, 240, 12, BLACK);
|
//DrawText(buffer, gui_x, 240, 12, BLACK);
|
||||||
sprintf(buffer, "Number of Entities: %u", sc_map_size_64v(&scene->ent_manager.entities));
|
sprintf(buffer, "Number of Entities: %u", sc_map_size_64v(&scene->ent_manager.entities));
|
||||||
DrawText(buffer, gui_x, 270, 12, BLACK);
|
DrawText(buffer, gui_x, gui_y, 12, BLACK);
|
||||||
|
gui_y += 30;
|
||||||
sprintf(buffer, "FPS: %u", GetFPS());
|
sprintf(buffer, "FPS: %u", GetFPS());
|
||||||
DrawText(buffer, gui_x, 320, 12, BLACK);
|
DrawText(buffer, gui_x, gui_y, 12, BLACK);
|
||||||
|
|
||||||
|
gui_y += 30;
|
||||||
static char mempool_stats[512];
|
static char mempool_stats[512];
|
||||||
print_mempool_stats(mempool_stats);
|
print_mempool_stats(mempool_stats);
|
||||||
DrawText(mempool_stats, gui_x, 350, 12, BLACK);
|
DrawText(mempool_stats, gui_x, gui_y, 12, BLACK);
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -801,6 +726,58 @@ static void level_do_action(Scene_t* scene, ActionType_t action, bool pressed)
|
||||||
break;
|
break;
|
||||||
case ACTION_METAL_TOGGLE:
|
case ACTION_METAL_TOGGLE:
|
||||||
if (!pressed) metal_toggle = !metal_toggle;
|
if (!pressed) metal_toggle = !metal_toggle;
|
||||||
|
const Color crate_colour = metal_toggle ? GRAY : BROWN;
|
||||||
|
Vector2 draw_pos = {SPAWN_CRATE * SELECTION_TILE_SIZE , 0};
|
||||||
|
BeginTextureMode(selection_section);
|
||||||
|
for (uint8_t i = SPAWN_CRATE; i <= SPAWN_CRATE_BOMB; ++i)
|
||||||
|
{
|
||||||
|
DrawRectangle(draw_pos.x, draw_pos.y, SELECTION_TILE_SIZE, SELECTION_TILE_SIZE, crate_colour);
|
||||||
|
Vector2 half_size = {SELECTION_TILE_HALFSIZE, SELECTION_TILE_HALFSIZE};
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case SPAWN_CRATE_ARROW_L:
|
||||||
|
DrawLine(
|
||||||
|
draw_pos.x,
|
||||||
|
draw_pos.y + half_size.y,
|
||||||
|
draw_pos.x + half_size.x,
|
||||||
|
draw_pos.y + half_size.y,
|
||||||
|
BLACK
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case SPAWN_CRATE_ARROW_R:
|
||||||
|
DrawLine(
|
||||||
|
draw_pos.x + half_size.x,
|
||||||
|
draw_pos.y + half_size.y,
|
||||||
|
draw_pos.x + half_size.x * 2,
|
||||||
|
draw_pos.y + half_size.y,
|
||||||
|
BLACK
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case SPAWN_CRATE_ARROW_U:
|
||||||
|
DrawLine(
|
||||||
|
draw_pos.x + half_size.x,
|
||||||
|
draw_pos.y,
|
||||||
|
draw_pos.x + half_size.x,
|
||||||
|
draw_pos.y + half_size.y,
|
||||||
|
BLACK
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case SPAWN_CRATE_ARROW_D:
|
||||||
|
DrawLine(
|
||||||
|
draw_pos.x + half_size.x,
|
||||||
|
draw_pos.y + half_size.y,
|
||||||
|
draw_pos.x + half_size.x,
|
||||||
|
draw_pos.y + half_size.y * 2,
|
||||||
|
BLACK
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case SPAWN_CRATE_BOMB:
|
||||||
|
DrawCircleV(Vector2Add(draw_pos, half_size), half_size.x, BLACK);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
draw_pos.x += SELECTION_TILE_SIZE;
|
||||||
|
}
|
||||||
|
EndTextureMode();
|
||||||
break;
|
break;
|
||||||
case ACTION_CRATE_ACTIVATION:
|
case ACTION_CRATE_ACTIVATION:
|
||||||
if (!pressed) crate_activation = !crate_activation;
|
if (!pressed) crate_activation = !crate_activation;
|
||||||
|
@ -835,6 +812,83 @@ void init_sandbox_scene(LevelScene_t* scene)
|
||||||
unsigned int tile_idx = (scene->data.tilemap.height - 1) * scene->data.tilemap.width + i;
|
unsigned int tile_idx = (scene->data.tilemap.height - 1) * scene->data.tilemap.width + i;
|
||||||
change_a_tile(&scene->data.tilemap, tile_idx, SOLID_TILE);
|
change_a_tile(&scene->data.tilemap, tile_idx, SOLID_TILE);
|
||||||
}
|
}
|
||||||
|
selection_section = LoadRenderTexture(SELECTION_REGION_WIDTH, SELECTION_REGION_HEIGHT * 2 + 10);
|
||||||
|
|
||||||
|
BeginTextureMode(selection_section);
|
||||||
|
ClearBackground(LIGHTGRAY);
|
||||||
|
Vector2 draw_pos = {0, 0};
|
||||||
|
const Color crate_colour = metal_toggle ? GRAY : BROWN;
|
||||||
|
const Color draw_colour[MAX_SPAWN_TYPE] = {
|
||||||
|
BLACK, MAROON, ORANGE, ColorAlpha(RAYWHITE, 0.5), ColorAlpha(BLUE, 0.5), ColorAlpha(RAYWHITE, 0.5),
|
||||||
|
crate_colour, crate_colour, crate_colour, crate_colour, crate_colour, crate_colour,
|
||||||
|
ColorAlpha(RAYWHITE, 0.5), ColorAlpha(RAYWHITE, 0.5)
|
||||||
|
};
|
||||||
|
for (uint8_t i = 0; i < MAX_SPAWN_TYPE; ++i)
|
||||||
|
{
|
||||||
|
DrawRectangle(draw_pos.x, draw_pos.y, SELECTION_TILE_SIZE, SELECTION_TILE_SIZE, draw_colour[i]);
|
||||||
|
Vector2 half_size = {SELECTION_TILE_HALFSIZE, SELECTION_TILE_HALFSIZE};
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case TOGGLE_SPIKE:
|
||||||
|
DrawRectangle(draw_pos.x, draw_pos.y + SELECTION_TILE_HALFSIZE, SELECTION_TILE_SIZE, SELECTION_TILE_HALFSIZE, RED);
|
||||||
|
break;
|
||||||
|
case SPAWN_BOULDER:
|
||||||
|
DrawCircleV(Vector2Add(draw_pos, half_size), half_size.x, GRAY);
|
||||||
|
break;
|
||||||
|
case SPAWN_CRATE_ARROW_L:
|
||||||
|
DrawLine(
|
||||||
|
draw_pos.x,
|
||||||
|
draw_pos.y + half_size.y,
|
||||||
|
draw_pos.x + half_size.x,
|
||||||
|
draw_pos.y + half_size.y,
|
||||||
|
BLACK
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case SPAWN_CRATE_ARROW_R:
|
||||||
|
DrawLine(
|
||||||
|
draw_pos.x + half_size.x,
|
||||||
|
draw_pos.y + half_size.y,
|
||||||
|
draw_pos.x + half_size.x * 2,
|
||||||
|
draw_pos.y + half_size.y,
|
||||||
|
BLACK
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case SPAWN_CRATE_ARROW_U:
|
||||||
|
DrawLine(
|
||||||
|
draw_pos.x + half_size.x,
|
||||||
|
draw_pos.y,
|
||||||
|
draw_pos.x + half_size.x,
|
||||||
|
draw_pos.y + half_size.y,
|
||||||
|
BLACK
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case SPAWN_CRATE_ARROW_D:
|
||||||
|
DrawLine(
|
||||||
|
draw_pos.x + half_size.x,
|
||||||
|
draw_pos.y + half_size.y,
|
||||||
|
draw_pos.x + half_size.x,
|
||||||
|
draw_pos.y + half_size.y * 2,
|
||||||
|
BLACK
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case SPAWN_CRATE_BOMB:
|
||||||
|
DrawCircleV(Vector2Add(draw_pos, half_size), half_size.x, BLACK);
|
||||||
|
break;
|
||||||
|
case SPAWN_WATER_RUNNER:
|
||||||
|
DrawCircleV(Vector2Add(draw_pos, half_size), half_size.x, ColorAlpha(BLUE, 0.2));
|
||||||
|
break;
|
||||||
|
case TOGGLE_AIR_POCKET:
|
||||||
|
DrawRectangleLinesEx((Rectangle){draw_pos.x, draw_pos.y, SELECTION_TILE_SIZE, SELECTION_TILE_SIZE}, 2.0, ColorAlpha(BLUE, 0.5));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
draw_pos.x += SELECTION_TILE_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
draw_pos.y += SELECTION_TILE_SIZE + 2;
|
||||||
|
DrawText("R to reset the map, O/P to cycle the selection,\nM to toggle metal crates. T to toggle crate spawn behaviour", 0, draw_pos.y, 14, BLACK);
|
||||||
|
|
||||||
|
|
||||||
|
EndTextureMode();
|
||||||
|
|
||||||
create_player(&scene->scene.ent_manager, &scene->scene.engine->assets);
|
create_player(&scene->scene.ent_manager, &scene->scene.engine->assets);
|
||||||
update_entity_manager(&scene->scene.ent_manager);
|
update_entity_manager(&scene->scene.ent_manager);
|
||||||
|
@ -893,4 +947,5 @@ void free_sandbox_scene(LevelScene_t* scene)
|
||||||
{
|
{
|
||||||
free_scene(&scene->scene);
|
free_scene(&scene->scene);
|
||||||
term_level_scene_data(&scene->data);
|
term_level_scene_data(&scene->data);
|
||||||
|
UnloadRenderTexture(selection_section); // Unload render texture
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue