aboutsummaryrefslogtreecommitdiff
path: root/src/1-2-binary-search-tree-visual.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/1-2-binary-search-tree-visual.c')
-rw-r--r--src/1-2-binary-search-tree-visual.c17
1 files changed, 6 insertions, 11 deletions
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 <SDL2/SDL_ttf.h>
#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 <init.h>
@@ -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);
}