From e82bf059815a58594e14045b35df5d267c5ffe23 Mon Sep 17 00:00:00 2001 From: iceyrazor Date: Fri, 26 Jun 2026 23:42:10 -0500 Subject: a* and removed subobjects --- src/1-2-binary-search-tree-visual.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'src/1-2-binary-search-tree-visual.c') diff --git a/src/1-2-binary-search-tree-visual.c b/src/1-2-binary-search-tree-visual.c index 633dc7b..26b2990 100644 --- a/src/1-2-binary-search-tree-visual.c +++ b/src/1-2-binary-search-tree-visual.c @@ -10,15 +10,10 @@ #include #define PROJECT_NAME "algorithms-binary search tree visual" -#define obj_n 1 -typedef struct OBJECT_INER { +typedef struct OBJECT { BS_Node *root; BS_Node *found_node; -} OBJECT_INER; - -typedef struct OBJECT { - OBJECT_INER *objs[obj_n]; } OBJECT; #include @@ -77,8 +72,8 @@ void add_text(BS_Node **node, STUFFS *stuff){ } } -void init_stuffs(int w, int h, OBJECT_INER *objs,STUFFS *stuff){ - OBJECT_INER *tree = &objs[0]; +void init_stuffs(int w, int h, STUFFS *stuff){ + OBJECT *tree = &stuff->obj; for(int i=0; i <100; i++){ BSAddValue(&tree->root,(int)RandomFloat(0,100)); } @@ -108,7 +103,7 @@ void draw_node(BS_Node **node, STUFFS *stuff){ } SDL_RenderCopy(stuff->renderer,(*node)->text->texture,NULL, &(*node)->text->textRect); circleRGBA(stuff->renderer,(*node)->pos.x,(*node)->pos.y,10,255,0,255,255); - if(stuff->obj.objs[0]->found_node != NULL && stuff->obj.objs[0]->found_node == *node){ + if(stuff->obj.found_node != NULL && stuff->obj.found_node == *node){ circleRGBA(stuff->renderer,(*node)->pos.x,(*node)->pos.y,10,0,255,255,255); SDL_SetRenderDrawColor(stuff->renderer,255,0,255,255); } @@ -128,7 +123,7 @@ void draw(SDL_Window* window, STUFFS *stuff){ //} SDL_SetRenderDrawColor(stuff->renderer,255,0,255,255); - draw_node(&stuff->obj.objs[0]->root,stuff); + draw_node(&stuff->obj.root,stuff); SDL_RenderPresent(stuff->renderer); } @@ -145,7 +140,7 @@ void BSFreeText(BS_Node **node){ } void on_end(STUFFS *stuff){ - OBJECT_INER *tree = stuff->obj.objs[0]; + OBJECT *tree = &stuff->obj; BSFreeText(&tree->root); BSFreeTree(&tree->root); } -- cgit v1.3