Compare commits
3 Commits
c64ef906e0
...
85e731392a
Author | SHA1 | Date |
---|---|---|
|
85e731392a | |
|
a9939200b7 | |
|
7dd4c8413b |
|
@ -16,5 +16,6 @@ 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
|
||||||
|
|
|
@ -213,14 +213,12 @@ static void render_editor_game_scene(Scene_t* scene)
|
||||||
int y = tile_y * TILE_SIZE;
|
int y = tile_y * TILE_SIZE;
|
||||||
|
|
||||||
|
|
||||||
#if !defined(PLATFORM_WEB)
|
//if (!tilemap.tiles[i].moveable)
|
||||||
if (!tilemap.tiles[i].moveable)
|
//{
|
||||||
{
|
// // Draw water tile
|
||||||
// Draw water tile
|
// Color water_colour = ColorAlpha(RED, 0.2);
|
||||||
Color water_colour = ColorAlpha(RED, 0.2);
|
// DrawRectangle(x, y, TILE_SIZE, TILE_SIZE, water_colour);
|
||||||
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)
|
||||||
|
@ -451,6 +449,8 @@ 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,6 +484,7 @@ 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();
|
||||||
}
|
}
|
||||||
|
@ -770,6 +771,7 @@ 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)
|
||||||
{
|
{
|
||||||
|
@ -875,6 +877,12 @@ 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;
|
||||||
}
|
}
|
||||||
|
@ -894,6 +902,7 @@ 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;
|
||||||
|
@ -1035,6 +1044,7 @@ 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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,10 +67,7 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
tilemap.tiles[tile_idx].tile_type = EMPTY_TILE;
|
change_a_tile(&tilemap, tile_idx, EMPTY_TILE);
|
||||||
tilemap.tiles[tile_idx].solid = NOT_SOLID;
|
|
||||||
tilemap.tiles[tile_idx].moveable = true;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------- Collision functions ------------------------------------
|
// ------------------------- Collision functions ------------------------------------
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -44,6 +44,7 @@ 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)
|
||||||
|
|
Loading…
Reference in New Issue