init_camera(&camera);
planet = malloc(sizeof(*planet));
- init_planet(screen, planet);
+ init_planet(planet);
for (i = 1; i < num_of_planets; i++) {
struct planet *new_planet;
new_planet = malloc(sizeof(*planet));
- init_planet(screen, new_planet);
+ init_planet(new_planet);
list_add(&new_planet->list, &planet->list);
}
p->size = pow(p->mass / 100, 1 / 3.0);
}
-void init_planet(const SDL_Surface *screen, struct planet *p)
+void init_planet(struct planet *p)
{
p->speed.x = 0;
p->speed.y = 0;
- p->pos.x = get_random() % screen->w;
- p->pos.y = get_random() % screen->h;
+ p->pos.x = (signed)(get_random() % 1000) - 500;
+ p->pos.y = (signed)(get_random() % 1000) - 500;
p->mass = get_random() % 1000 + 100;
reshape_planet(p);
p->r = get_random() % 256;
#define list_to_planet(list_head) container_of((list_head), struct planet, list)
-void init_planet(const SDL_Surface *screen, struct planet *p);
+void init_planet(struct planet *p);
void draw_planet(SDL_Surface *screen, struct planet *p, const struct camera *);
int gravitize_planets(struct planet *a, struct planet *b, const double time);
struct planet *merge_planets(struct planet *a, struct planet *b);