]> git.itanic.dy.fi Git - sdl-planets/blob - planet.h
22bfd070cb91f699ae8ff24ce1509594b4caaa11
[sdl-planets] / planet.h
1 #ifndef _PLANET_H
2 #define _PLANET_H
3
4 #include <SDL.h>
5
6 #include "vector.h"
7 #include "list.h"
8 #include "utils.h"
9 #include "camera.h"
10 #include "quadtree.h"
11
12 struct planet {
13         struct vector speed;
14         struct vector pos;
15         struct list_head list;
16         struct quadtree tree;
17         double mass;
18         float radius;
19         unsigned char r, g, b;
20 };
21
22 #define list_to_planet(list_head) container_of((list_head), struct planet, list)
23
24 #define tree_to_planet(qt) container_of((qt), struct planet, tree)
25
26 void init_planet(struct planet *p);
27 void create_planets(struct planet *p, int num, double total_mass,
28                     double radius);
29 void draw_planet(SDL_Surface *screen, struct planet *p, const struct camera *);
30 int gravitize_planets(struct planet *a, struct planet *b, const double time);
31 struct planet *merge_planets(struct planet *a, struct planet *b);
32 struct planet *move_planet(struct planet *p, const double time);
33 void print_planet(const struct planet *p);
34
35 int planet_spatial_compare(struct quadtree *a, struct quadtree *b);
36 #endif