Compare commits

..

No commits in common. "85e731392a9edbe9f0bcab631a86f1a225717dbf" and "c64ef906e03c2a76e9e7853248fe025055ff5216" have entirely different histories.

5 changed files with 39 additions and 48 deletions

View File

@ -16,6 +16,5 @@ typedef enum ActionType
ACTION_RESTART,
ACTION_NEXTLEVEL,
ACTION_PREVLEVEL,
ACTION_TOGGLE_GRID,
}ActionType_t;
#endif // __ACTIONS_H

View File

@ -213,12 +213,14 @@ static void render_editor_game_scene(Scene_t* scene)
int y = tile_y * TILE_SIZE;
//if (!tilemap.tiles[i].moveable)
//{
// // Draw water tile
// Color water_colour = ColorAlpha(RED, 0.2);
// DrawRectangle(x, y, TILE_SIZE, TILE_SIZE, water_colour);
//}
#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)
@ -449,41 +451,38 @@ static void render_editor_game_scene(Scene_t* scene)
draw_particle_system(&scene->part_sys);
if (data->show_grid)
for (int tile_y = min.y; tile_y < max.y; tile_y++)
{
for (int tile_y = min.y; tile_y < max.y; tile_y++)
for (int tile_x = min.x; tile_x < max.x; tile_x++)
{
for (int tile_x = min.x; tile_x < max.x; tile_x++)
int i = tile_x + tile_y * tilemap.width;
int x = tile_x * TILE_SIZE;
int y = tile_y * TILE_SIZE;
sprintf(buffer, "%u", sc_map_size_64v(&tilemap.tiles[i].entities_set));
if (tilemap.tiles[i].solid > 0)
{
int i = tile_x + tile_y * tilemap.width;
int x = tile_x * TILE_SIZE;
int y = tile_y * TILE_SIZE;
sprintf(buffer, "%u", sc_map_size_64v(&tilemap.tiles[i].entities_set));
if (tilemap.tiles[i].solid > 0)
{
DrawText(buffer, x, y, 10, WHITE);
}
else
{
// Draw water tile
DrawText(buffer, x, y, 10, BLACK);
}
DrawText(buffer, x, y, 10, WHITE);
}
else
{
// Draw water tile
DrawText(buffer, x, y, 10, BLACK);
}
}
}
// Draw tile grid
for (size_t i = min.x; i < max.x; ++i)
{
int x = (i+1)*TILE_SIZE;
DrawLine(x, 0, x, tilemap.height * TILE_SIZE, BLACK);
}
for (size_t i = min.y; i < max.y;++i)
{
int y = (i+1)*TILE_SIZE;
DrawLine(0, y, tilemap.width * TILE_SIZE, y, BLACK);
}
// Draw tile grid
for (size_t i = min.x; i < max.x; ++i)
{
int x = (i+1)*TILE_SIZE;
DrawLine(x, 0, x, tilemap.height * TILE_SIZE, BLACK);
}
for (size_t i = min.y; i < max.y;++i)
{
int y = (i+1)*TILE_SIZE;
DrawLine(0, y, tilemap.width * TILE_SIZE, y, BLACK);
}
EndMode2D();
EndTextureMode();
@ -771,7 +770,6 @@ static void restart_editor_level(Scene_t* scene)
static void level_do_action(Scene_t* scene, ActionType_t action, bool pressed)
{
LevelSceneData_t* data = &(CONTAINER_OF(scene, LevelScene_t, scene)->data);
CPlayerState_t* p_playerstate;
sc_map_foreach_value(&scene->ent_manager.component_map[CPLAYERSTATE_T], p_playerstate)
{
@ -877,12 +875,6 @@ static void level_do_action(Scene_t* scene, ActionType_t action, bool pressed)
case ACTION_RESTART:
restart_editor_level(scene);
break;
case ACTION_TOGGLE_GRID:
if (!pressed)
{
data->show_grid = !data->show_grid;
}
break;
default:
break;
}
@ -902,7 +894,6 @@ void init_sandbox_scene(LevelScene_t* scene)
&scene->data, MAX_N_TILES, all_tiles,
(Rectangle){25, 25, VIEWABLE_MAP_WIDTH*TILE_SIZE, VIEWABLE_MAP_HEIGHT*TILE_SIZE}
);
scene->data.show_grid = true;
for (size_t i = 0; i < scene->data.tilemap.width; ++i)
{
unsigned int tile_idx = (scene->data.tilemap.height - 1) * scene->data.tilemap.width + i;
@ -1044,7 +1035,6 @@ void init_sandbox_scene(LevelScene_t* scene)
sc_map_put_64(&scene->scene.action_map, KEY_T, ACTION_CRATE_ACTIVATION);
sc_map_put_64(&scene->scene.action_map, KEY_L, ACTION_EXIT);
sc_map_put_64(&scene->scene.action_map, KEY_R, ACTION_RESTART);
sc_map_put_64(&scene->scene.action_map, KEY_H, ACTION_TOGGLE_GRID);
}

View File

@ -67,7 +67,10 @@ static inline void destroy_tile(LevelSceneData_t* lvl_data, unsigned int tile_id
play_particle_emitter(&scene->part_sys, &emitter);
}
change_a_tile(&tilemap, tile_idx, EMPTY_TILE);
tilemap.tiles[tile_idx].tile_type = EMPTY_TILE;
tilemap.tiles[tile_idx].solid = NOT_SOLID;
tilemap.tiles[tile_idx].moveable = true;
}
// ------------------------- Collision functions ------------------------------------

View File

@ -42,12 +42,12 @@ typedef struct LevelSceneData {
TileGrid_t tilemap;
RenderTexture2D game_viewport;
Rectangle game_rec;
//Camera2D cam;
LevelCamera_t camera;
Sprite_t* tile_sprites[MAX_TILE_SPRITES];
LevelPack_t* level_pack;
unsigned int current_level;
CoinCounter_t coins;
bool show_grid;
}LevelSceneData_t;
typedef struct LevelScene {

View File

@ -44,7 +44,6 @@ void init_level_scene_data(LevelSceneData_t* data, uint32_t max_tiles, Tile_t* t
data->tilemap.tiles[i].size = (Vector2){TILE_SIZE, TILE_SIZE};
}
memset(&data->coins, 0, sizeof(data->coins));
data->show_grid = false;
}
void term_level_scene_data(LevelSceneData_t* data)