30 lines
702 B
C
30 lines
702 B
C
#include "raylib.h"
|
|
|
|
typedef struct _Joint {
|
|
Vector2 pos;
|
|
} Joint;
|
|
|
|
typedef struct _Body {
|
|
Vector2 final_target;
|
|
int N;
|
|
float total_length;
|
|
float angle_limit;
|
|
Vector2 target;
|
|
Vector2 root_pos;
|
|
float link_length;
|
|
float* links_lengths;
|
|
float current_length;
|
|
float target_length;
|
|
Joint* joints;
|
|
} Body;
|
|
|
|
|
|
Body* init_body(int N, float link_length, float root_x, float root_y);
|
|
void set_body_root(Body* body, Vector2 new_pos);
|
|
void set_body_target(Body* body, Vector2 new_target);
|
|
void set_length_target(Body* body, float new_length);
|
|
void _update_body_length(Body* body);
|
|
void update_body(Body* body);
|
|
void draw_body(Body* body);
|
|
void free_body(Body* body);
|