main.h (1733B)
1 /* 2 * physics.c 3 */ 4 enum object_shape { 5 SRECTANGLE, 6 STRIANGLE, 7 SCIRCLE, 8 }; 9 10 struct Point { 11 float x; 12 float y; 13 }; 14 15 struct Rectangle { // origin is top left corner 16 int w, h; 17 }; 18 19 struct Triangle { 20 struct Point v2; 21 struct Point v3; 22 }; 23 24 struct Circle { // origin is center 25 float r; 26 }; 27 28 union Body { 29 struct Circle circle; 30 struct Triangle triangle; 31 struct Rectangle rectangle; 32 }; 33 34 struct Object { 35 enum object_shape shape; 36 struct Point pp; 37 struct Point p; 38 struct Point v; 39 struct Point a; 40 union Body body; 41 int m; 42 }; 43 44 /* 45 struct ObjectCol { 46 struct ObjectCol up; 47 struct ObjectCol down; 48 struct Object obj; 49 }; 50 51 struct ObjectRow { 52 struct ObjectRow left; 53 struct ObjectRow right; 54 struct ObjectCol; 55 }; 56 */ 57 58 struct rect { 59 struct Point pp; 60 struct Point p; 61 struct Point v; 62 struct Point a; 63 int w, h; 64 int m; 65 }; 66 67 struct circle { 68 struct Point pp; 69 struct Point p; 70 struct Point v; 71 struct Point a; 72 int r; 73 int m; 74 }; 75 76 int test_collision(struct Object *, struct Object *); // 1 if collide, 0 if not 77 void next_tick(struct Object *o, long); 78 void handle_collision_mf(struct Object *, struct Object *); 79 int object_is_falling(struct Object *o, struct Object *fb, int num_f); 80 81 /* 82 * x.c 83 */ 84 enum event_type { 85 XKEYPRESS, 86 XKEYRELEASE, 87 XEXPOSE, 88 XWINDEL, 89 NOEVENT, 90 }; 91 92 int x_setup_window(int, int, unsigned int, unsigned int, unsigned long, char *); 93 void x_clear_area(void); 94 void x_draw_string(unsigned long color, int x, int y, const char *str, int length); 95 void x_draw_rectangle(unsigned long color, int x, int y, 96 unsigned int w, unsigned int h); 97 void x_flush(void); 98 void x_clean_up(void); 99 int x_next_event(char *c); 100 int x_pending(void); 101 void x_get_win_wh(int *, int *);