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_RESTART,
ACTION_NEXTLEVEL, ACTION_NEXTLEVEL,
ACTION_PREVLEVEL, ACTION_PREVLEVEL,
ACTION_TOGGLE_GRID,
}ActionType_t; }ActionType_t;
#endif // __ACTIONS_H #endif // __ACTIONS_H

View File

@ -213,12 +213,14 @@ static void render_editor_game_scene(Scene_t* scene)
int y = tile_y * TILE_SIZE; int y = tile_y * TILE_SIZE;
//if (!tilemap.tiles[i].moveable) #if !defined(PLATFORM_WEB)
//{ if (!tilemap.tiles[i].moveable)
// // Draw water tile {
// Color water_colour = ColorAlpha(RED, 0.2); // Draw water tile
// DrawRectangle(x, y, TILE_SIZE, TILE_SIZE, water_colour); 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; uint8_t tile_sprite_idx = tilemap.tiles[i].tile_type + tilemap.tiles[i].rotation;
if (data->tile_sprites[tile_sprite_idx] != NULL) if (data->tile_sprites[tile_sprite_idx] != NULL)
@ -449,8 +451,6 @@ static void render_editor_game_scene(Scene_t* scene)
draw_particle_system(&scene->part_sys); 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++)
@ -484,7 +484,6 @@ static void render_editor_game_scene(Scene_t* scene)
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);
} }
}
EndMode2D(); EndMode2D();
EndTextureMode(); 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) 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; CPlayerState_t* p_playerstate;
sc_map_foreach_value(&scene->ent_manager.component_map[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: case ACTION_RESTART:
restart_editor_level(scene); restart_editor_level(scene);
break; break;
case ACTION_TOGGLE_GRID:
if (!pressed)
{
data->show_grid = !data->show_grid;
}
break;
default: default:
break; break;
} }
@ -902,7 +894,6 @@ void init_sandbox_scene(LevelScene_t* scene)
&scene->data, MAX_N_TILES, all_tiles, &scene->data, MAX_N_TILES, all_tiles,
(Rectangle){25, 25, VIEWABLE_MAP_WIDTH*TILE_SIZE, VIEWABLE_MAP_HEIGHT*TILE_SIZE} (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) 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; 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_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_L, ACTION_EXIT);
sc_map_put_64(&scene->scene.action_map, KEY_R, ACTION_RESTART); 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); 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 ------------------------------------ // ------------------------- Collision functions ------------------------------------

View File

@ -42,12 +42,12 @@ typedef struct LevelSceneData {
TileGrid_t tilemap; TileGrid_t tilemap;
RenderTexture2D game_viewport; RenderTexture2D game_viewport;
Rectangle game_rec; Rectangle game_rec;
//Camera2D cam;
LevelCamera_t camera; LevelCamera_t camera;
Sprite_t* tile_sprites[MAX_TILE_SPRITES]; Sprite_t* tile_sprites[MAX_TILE_SPRITES];
LevelPack_t* level_pack; LevelPack_t* level_pack;
unsigned int current_level; unsigned int current_level;
CoinCounter_t coins; CoinCounter_t coins;
bool show_grid;
}LevelSceneData_t; }LevelSceneData_t;
typedef struct LevelScene { 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}; data->tilemap.tiles[i].size = (Vector2){TILE_SIZE, TILE_SIZE};
} }
memset(&data->coins, 0, sizeof(data->coins)); memset(&data->coins, 0, sizeof(data->coins));
data->show_grid = false;
} }
void term_level_scene_data(LevelSceneData_t* data) void term_level_scene_data(LevelSceneData_t* data)