Skip to content

Commit

Permalink
Merge branch 'GUI' of github.com:eliehalimi/StarDwarf into GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
ngocphuonganhduong committed May 23, 2018
2 parents c5606f7 + 85db1a2 commit deaefdd
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 43 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
20 changes: 17 additions & 3 deletions gui/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,25 @@ int main()
{
struct item *i = new_item(v);
free_vector(v);

i->size = 100;
i->mass = 100000000000000.0f;

float x = i->position.values[0];
float y = i->position.values[1];
float z = i->position.values[2];

input_to_item(text_list, p, i);

i->position.values[0] = x;
i->position.values[1] = y;
i->position.values[2] = z;

if(i->size <= 1)
i->size = 100;
if(i->mass <= 1)
i->mass = 100000000000000.0f;

push_item(sys, i);

//sys->selected = i;
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion gui/textinput.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,13 @@ void input_to_item(struct htable *text_list, struct palette *p, struct item *ite

item->mass = atof(get_text(text_list, "item_mass")->text);
item->size = atof(get_text(text_list, "item_radius")->text);


if(item->mass < 0)
item->mass = 1;

if(item->size < 0)
item->size = 1;

float x = atof(get_text(text_list, "item_x") -> text);
float y = atof(get_text(text_list, "item_y") -> text);
float z = atof(get_text(text_list, "item_z") -> text);
Expand Down

0 comments on commit deaefdd

Please sign in to comment.