Skip to content

Commit

Permalink
Drawing an item has been a lot optimized, and the limit for simplifie…
Browse files Browse the repository at this point in the history
…d drawing removed
  • Loading branch information
Samuel Corno committed May 23, 2018
1 parent 8df5c54 commit 85db1a2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 39 deletions.
47 changes: 10 additions & 37 deletions gui/draw_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,51 +125,24 @@ void DrawProj(struct projection *proj, SDL_Renderer *renderer, float offset_X, f
size = MAXSIZEITEM;


int new_x = x;
int new_y = y;
int old_x = x + size / 2;
int old_y = y;
//int new_x = x;
//int new_y = y;
//int old_x = x + size / 2;
//int old_y = y;

/* SETS COLOR*/


SDL_SetRenderDrawColor(renderer, item->color[0], item->color[1], item->color[2],item->color[3]);

if(size < SIZESIMPLE)
float square = size * size / 4;

for(int i = -size / 2; i < size / 2; i++)
{
float square = size * size / 4;
float j = sqrt(square - i * i);

SDL_RenderDrawLine(renderer, x - j, y + i, x + j, y + i);

for(int i = -size / 2; i < size / 2; i++)
{
for(int j = -size / 2; j < size / 2; j++)
{
new_x = x + i;
new_y = y +j;
if(i * i + j * j <= square)
{
SDL_RenderDrawLine(renderer, old_x, old_y, new_x, new_y);
}
old_x = new_x;
old_y = new_y;
}
}

new_x = x + (item->size / 2 * cos(0));
new_y = y - (item->size / 2 * sin(0));

//SDL_RenderDrawLine(renderer, old_x, old_y, new_x, new_y);
}
else
{
for(int i = -size / 2; i < size / 2; i++)
{
SDL_RenderDrawLine(renderer, -size/2 + x, y + i, size/2 + x, y + i);
}

new_x = x + (item->size / 2 * cos(0));
new_y = y - (item->size / 2 * sin(0));

//SDL_RenderDrawLine(renderer, old_x, old_y, new_x, new_y);
}

SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
Expand Down
4 changes: 2 additions & 2 deletions gui/draw_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# define SCR_CEN_X SCR_WDT / 2
# define SCR_CEN_Y SCR_HGT / 2

# define MAXSIZEITEM 10000
# define SIZESIMPLE 500
# define MAXSIZEITEM 100000
# define SIZESIMPLE 5000



Expand Down

0 comments on commit 85db1a2

Please sign in to comment.