Compare commits

..

No commits in common. "8a39f85c45e342006da577cd47c83020b530b2c0" and "05e58677a5d49f1c712bced1461e247bb2ce366b" have entirely different histories.

4 changed files with 13 additions and 33 deletions

View File

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

View File

@ -79,9 +79,7 @@ static inline unsigned int get_tile_idx(int x, int y, const TileGrid_t* tilemap)
return MAX_N_TILES;
}
// This means you might be able to have two editor scene without running into problems
static RenderTexture2D selection_section;
#define SELECTION_RENDER_HEIGHT (SELECTION_REGION_HEIGHT * 3)
static void level_scene_render_func(Scene_t* scene)
{
LevelSceneData_t* data = &(CONTAINER_OF(scene, LevelScene_t, scene)->data);
@ -100,7 +98,7 @@ static void level_scene_render_func(Scene_t* scene)
WHITE
);
draw_rec.width = SELECTION_REGION_WIDTH;
draw_rec.height = -SELECTION_RENDER_HEIGHT;
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};
@ -292,12 +290,6 @@ static void render_editor_game_scene(Scene_t* scene)
{
CTransform_t* p_ct = get_component(p_ent, CTRANSFORM_COMP_T);
CBBox_t* p_bbox = get_component(p_ent, CBBOX_COMP_T);
// Draw the spawn point
if (p_ent->m_tag == PLAYER_ENT_TAG)
{
DrawCircleV(p_ent->spawn_pos, 6, PURPLE);
}
// Entity culling
Vector2 box_size = {0};
@ -795,11 +787,9 @@ 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);
Entity_t* p_player;
//sc_map_foreach_value(&scene->ent_manager.component_map[CPLAYERSTATE_T], p_playerstate)
sc_map_foreach_value(&scene->ent_manager.entities_map[PLAYER_ENT_TAG], p_player)
CPlayerState_t* p_playerstate;
sc_map_foreach_value(&scene->ent_manager.component_map[CPLAYERSTATE_T], p_playerstate)
{
CPlayerState_t* p_playerstate = get_component(p_player, CPLAYERSTATE_T);
switch(action)
{
case ACTION_UP:
@ -908,12 +898,6 @@ static void level_do_action(Scene_t* scene, ActionType_t action, bool pressed)
data->show_grid = !data->show_grid;
}
break;
case ACTION_SET_SPAWNPOINT:
{
CTransform_t* p_ct = get_component(p_player, CTRANSFORM_COMP_T);
p_player->spawn_pos = p_ct->position;
}
break;
default:
break;
}
@ -939,7 +923,7 @@ void init_sandbox_scene(LevelScene_t* scene)
unsigned int tile_idx = (scene->data.tilemap.height - 1) * scene->data.tilemap.width + i;
change_a_tile(&scene->data.tilemap, tile_idx, SOLID_TILE);
}
selection_section = LoadRenderTexture(SELECTION_REGION_WIDTH, SELECTION_RENDER_HEIGHT);
selection_section = LoadRenderTexture(SELECTION_REGION_WIDTH, SELECTION_REGION_HEIGHT * 2 + 10);
BeginTextureMode(selection_section);
ClearBackground(LIGHTGRAY);
@ -1016,7 +1000,7 @@ void init_sandbox_scene(LevelScene_t* scene)
}
draw_pos.y += SELECTION_TILE_SIZE + 2;
DrawText("R to reset the map, Q/E to cycle the selection,\nF to toggle metal crates. T to toggle crate spawn behaviour\nB to toggle grid, V to set spawn point", 0, draw_pos.y, 14, BLACK);
DrawText("R to reset the map, Q/E to cycle the selection,\nF to toggle metal crates. T to toggle crate spawn behaviour", 0, draw_pos.y, 14, BLACK);
EndTextureMode();
@ -1076,8 +1060,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_L, ACTION_EXIT);
sc_map_put_64(&scene->scene.action_map, KEY_R, ACTION_RESTART);
sc_map_put_64(&scene->scene.action_map, KEY_B, ACTION_TOGGLE_GRID);
sc_map_put_64(&scene->scene.action_map, KEY_V, ACTION_SET_SPAWNPOINT);
sc_map_put_64(&scene->scene.action_map, KEY_H, ACTION_TOGGLE_GRID);
}

View File

@ -1504,9 +1504,9 @@ void update_entity_emitter_system(Scene_t* scene)
{
Entity_t* p_ent = get_entity(&scene->ent_manager, ent_idx);
CTransform_t* p_ctransform = get_component(p_ent, CTRANSFORM_COMP_T);
//CBBox_t* p_bbox = get_component(p_ent, CBBOX_COMP_T);
Vector2 new_pos = Vector2Add(p_ctransform->position,p_emitter->offset);
//new_pos.y += p_bbox->half_size.y;
CBBox_t* p_bbox = get_component(p_ent, CBBOX_COMP_T);
Vector2 new_pos = p_ctransform->position;
new_pos.y += p_bbox->half_size.y;
if (is_emitter_handle_alive(&scene->part_sys, p_emitter->handle))
{
update_emitter_handle_position(&scene->part_sys, p_emitter->handle, new_pos);
@ -1936,14 +1936,13 @@ void airtimer_update_system(Scene_t* scene)
{
if (!is_emitter_handle_alive(&scene->part_sys, p_emitter->handle))
{
//Vector2 new_pos = p_ctransform->position;
//new_pos.y += p_bbox->half_size.y;
Vector2 new_pos = p_ctransform->position;
new_pos.y += p_bbox->half_size.y;
ParticleEmitter_t emitter = {
.spr = get_sprite(&scene->engine->assets, "p_water"),
.config = get_emitter_conf(&scene->engine->assets, "pe_bubbling"),
//.position = new_pos,
.position = p_ctransform->position,
.position = new_pos,
.n_particles = 5,
.user_data = &(CONTAINER_OF(scene, LevelScene_t, scene)->data),
.update_func = &floating_particle_system_update,

View File

@ -105,8 +105,7 @@ Entity_t* create_player(EntityManager_t* ent_manager)
p_cspr->sprites = player_sprite_map;
p_cspr->transition_func = &player_sprite_transition_func;
CEmitter_t* p_emitter = add_component(p_ent, CEMITTER_T);
p_emitter->offset = (Vector2){7,0};
add_component(p_ent, CEMITTER_T);
return p_ent;
}