diff --git a/scenes/editor_scene.c b/scenes/editor_scene.c index 98d6c4a..1339cf6 100644 --- a/scenes/editor_scene.c +++ b/scenes/editor_scene.c @@ -19,10 +19,13 @@ enum EntitySpawnSelection { SPAWN_CRATE, SPAWN_METAL_CRATE, SPAWN_CRATE_ARROW_L, + SPAWN_CRATE_ARROW_R, + SPAWN_CRATE_ARROW_U, + SPAWN_CRATE_ARROW_D, SPAWN_BOULDER, }; -#define MAX_SPAWN_TYPE 9 +#define MAX_SPAWN_TYPE 12 static unsigned int current_spawn_selection = 0; #define SELECTION_TILE_SIZE 32 @@ -158,6 +161,15 @@ static void level_scene_render_func(Scene_t* scene) switch (p_container->item) { case CONTAINER_LEFT_ARROW: + DrawLine( + p_ct->position.x, + p_ct->position.y + p_bbox->half_size.y, + p_ct->position.x + p_bbox->half_size.x, + p_ct->position.y + p_bbox->half_size.y, + BLACK + ); + break; + case CONTAINER_RIGHT_ARROW: DrawLine( p_ct->position.x + p_bbox->half_size.x, p_ct->position.y + p_bbox->half_size.y, @@ -166,22 +178,29 @@ static void level_scene_render_func(Scene_t* scene) BLACK ); break; + case CONTAINER_UP_ARROW: + DrawLine( + p_ct->position.x + p_bbox->half_size.x, + p_ct->position.y, + p_ct->position.x + p_bbox->half_size.x, + p_ct->position.y + p_bbox->half_size.y, + BLACK + ); + break; + case CONTAINER_DOWN_ARROW: + DrawLine( + p_ct->position.x + p_bbox->half_size.x, + p_ct->position.y + p_bbox->half_size.y, + p_ct->position.x + p_bbox->half_size.x, + p_ct->position.y + p_bbox->size.y, + BLACK + ); + break; default: break; } } } - - //if (p_ent->m_tag == ARROW_ENT_TAG) - //{ - // DrawLine( - // p_ct->position.x + 10, - // p_ct->position.y + p_bbox->half_size.y, - // p_ct->position.x + p_bbox->size.x, - // p_ct->position.y + p_bbox->half_size.y, - // colour - // ); - //} } CHurtbox_t* p_hurtbox = get_component(p_ent, CHURTBOX_T); @@ -266,7 +285,11 @@ static void level_scene_render_func(Scene_t* scene) ); Vector2 draw_pos = {data->game_rec.x, data->game_rec.y + data->game_rec.height + SELECTION_GAP}; - const Color draw_colour[MAX_SPAWN_TYPE] = {BLACK, MAROON, ORANGE, ColorAlpha(RAYWHITE, 0.5), ColorAlpha(BLUE, 0.5), BROWN, GRAY, BROWN, ColorAlpha(RAYWHITE, 0.5)}; + const Color draw_colour[MAX_SPAWN_TYPE] = { + BLACK, MAROON, ORANGE, ColorAlpha(RAYWHITE, 0.5), ColorAlpha(BLUE, 0.5), + BROWN, GRAY, BROWN, BROWN, BROWN, + BROWN, ColorAlpha(RAYWHITE, 0.5) + }; for (uint8_t i = 0; i < MAX_SPAWN_TYPE; ++i) { if (i != current_spawn_selection) @@ -282,6 +305,15 @@ static void level_scene_render_func(Scene_t* scene) 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, @@ -290,6 +322,24 @@ static void level_scene_render_func(Scene_t* scene) 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; } } draw_pos.x += SELECTION_TILE_SIZE; @@ -311,6 +361,15 @@ static void level_scene_render_func(Scene_t* scene) 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, @@ -319,6 +378,24 @@ static void level_scene_render_func(Scene_t* scene) 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; } // For DEBUG @@ -437,6 +514,15 @@ static void toggle_block_system(Scene_t* scene) case SPAWN_CRATE_ARROW_L: spawn_crate(scene, tile_idx, false, CONTAINER_LEFT_ARROW); break; + case SPAWN_CRATE_ARROW_R: + spawn_crate(scene, tile_idx, false, CONTAINER_RIGHT_ARROW); + break; + case SPAWN_CRATE_ARROW_U: + spawn_crate(scene, tile_idx, false, CONTAINER_UP_ARROW); + break; + case SPAWN_CRATE_ARROW_D: + spawn_crate(scene, tile_idx, false, CONTAINER_DOWN_ARROW); + break; } change_a_tile(&tilemap, tile_idx, new_type); last_tile_idx = tile_idx; diff --git a/scenes/game_systems.c b/scenes/game_systems.c index fd1e579..7b7fab2 100644 --- a/scenes/game_systems.c +++ b/scenes/game_systems.c @@ -1805,16 +1805,27 @@ void container_destroy_system(Scene_t* scene) switch (p_container->item) { case CONTAINER_LEFT_ARROW: - { new_ent = create_arrow(&scene->ent_manager, &scene->engine->assets, 0); - CTransform_t* new_p_ct = get_component(new_ent, CTRANSFORM_COMP_T); - CTransform_t* p_ct = get_component(p_ent, CTRANSFORM_COMP_T); - memcpy(&new_p_ct->position, &p_ct->position, sizeof(Vector2)); - } + break; + case CONTAINER_RIGHT_ARROW: + new_ent = create_arrow(&scene->ent_manager, &scene->engine->assets, 1); + break; + case CONTAINER_UP_ARROW: + new_ent = create_arrow(&scene->ent_manager, &scene->engine->assets, 2); + break; + case CONTAINER_DOWN_ARROW: + new_ent = create_arrow(&scene->ent_manager, &scene->engine->assets, 3); break; default: + new_ent = NULL; break; } + if (new_ent != NULL) + { + CTransform_t* new_p_ct = get_component(new_ent, CTRANSFORM_COMP_T); + CTransform_t* p_ct = get_component(p_ent, CTRANSFORM_COMP_T); + memcpy(&new_p_ct->position, &p_ct->position, sizeof(Vector2)); + } } } } diff --git a/scenes/items_ent.c b/scenes/items_ent.c index b5e1811..d540bb1 100644 --- a/scenes/items_ent.c +++ b/scenes/items_ent.c @@ -55,14 +55,34 @@ Entity_t* create_arrow(EntityManager_t* ent_manager, Assets_t* assets, uint8_t d add_component(p_arrow, CTILECOORD_COMP_T); CHitBoxes_t* p_hitbox = add_component(p_arrow, CHITBOXES_T); p_hitbox->n_boxes = 1; - p_hitbox->boxes[0] = (Rectangle){TILE_SIZE - 5, TILE_SIZE / 2 - 5, 5, 5}; + p_hitbox->atk = 3; p_hitbox->one_hit = true; CTransform_t* p_ctransform = add_component(p_arrow, CTRANSFORM_COMP_T); p_ctransform->movement_mode = KINEMATIC_MOVEMENT; - p_ctransform->velocity.x = 500; p_ctransform->active = true; + //p_hitbox->boxes[0] = (Rectangle){TILE_SIZE - 5, TILE_SIZE / 2 - 5, 5, 5}; + switch(dir) + { + case 0: + p_hitbox->boxes[0] = (Rectangle){10, TILE_SIZE / 2 - 5, 10, 5}; + p_ctransform->velocity.x = -250; + break; + case 2: + p_hitbox->boxes[0] = (Rectangle){TILE_SIZE / 2 - 5, 10, 5, 10}; + p_ctransform->velocity.y = -250; + break; + case 3: + p_hitbox->boxes[0] = (Rectangle){TILE_SIZE / 2 - 5, 10, 5, 10}; + p_ctransform->velocity.y = 250; + break; + default: + p_hitbox->boxes[0] = (Rectangle){10, TILE_SIZE / 2 - 5, 10, 5}; + p_ctransform->velocity.x = 250; + break; + } + return p_arrow; }