Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.associations": {
"xstring": "cpp"
}
}
3 changes: 3 additions & 0 deletions clang++/include/circle_geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ point_2d center_point(const circle &c);
circle circle_at(const point_2d &pt, double radius);
circle circle_at(double x, double y, double radius);
float circle_radius(const circle c);
bool circle_triangle_intersect(const circle &c, const triangle &tri);
bool circle_triangle_intersect(const circle &c, const triangle &tri, point_2d &p);
float circle_x(const circle &c);
float circle_y(const circle &c);
bool circles_intersect(circle c1, circle c2);
bool circles_intersect(double c1_x, double c1_y, double c1_radius, double c2_x, double c2_y, double c2_radius);
point_2d closest_point_on_circle(const point_2d &from_pt, const circle &c);
point_2d closest_point_on_line_from_circle(const circle &c, const line &l);
point_2d closest_point_on_rect_from_circle(const circle &c, const rectangle &rect);
point_2d closest_point_on_triangle_from_circle(const circle &c, const triangle &tri);
point_2d distant_point_on_circle(const point_2d &pt, const circle &c);
bool distant_point_on_circle_heading(const point_2d &pt, const circle &c, const vector_2d &heading, point_2d &opposite_pt);
float ray_circle_intersect_distance(const point_2d &ray_origin, const vector_2d &ray_heading, const circle &c);
Expand Down
28 changes: 14 additions & 14 deletions clang++/include/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,40 @@ bool bitmap_button(bitmap bmp);
bool bitmap_button(bitmap bmp, const rectangle &rect);
bool bitmap_button(bitmap bmp, const rectangle &rect, drawing_options opts);
bool bitmap_button(bitmap bmp, drawing_options opts);
bool bitmap_button(const string &label, bitmap bmp);
bool bitmap_button(const string &label, bitmap bmp, drawing_options opts);
bool bitmap_button(const string &label_text, bitmap bmp);
bool bitmap_button(const string &label_text, bitmap bmp, drawing_options opts);
bool button(const string &text, const rectangle &rect);
bool button(const string &text);
bool button(const string &label, const string &text);
bool button(const string &label_text, const string &text);
bool checkbox(const string &text, const bool &value, const rectangle &rect);
bool checkbox(const string &text, const bool &value);
bool checkbox(const string &label, const string &text, const bool &value);
bool checkbox(const string &label_text, const string &text, const bool &value);
color color_slider(const color &clr, const rectangle &rect);
color color_slider(const color &clr);
color color_slider(const string &label, const color &clr);
color color_slider(const string &label_text, const color &clr);
void disable_interface();
void draw_interface();
void enable_interface();
void end_inset(const string &name);
void end_panel(const string &name);
void end_popup(const string &name);
void end_treenode(const string &label);
void end_treenode(const string &label_text);
void enter_column();
int get_interface_label_width();
bool header(const string &label);
bool header(const string &label_text);
color hsb_color_slider(const color &clr, const rectangle &rect);
color hsb_color_slider(const color &clr);
color hsb_color_slider(const string &label, const color &clr);
color hsb_color_slider(const string &label_text, const color &clr);
bool interface_enabled();
void interface_style_panel(const rectangle &initial_rectangle);
void label(const string &text);
void label(const string &text, const rectangle &rect);
void label_element(const string &text);
void label_element(const string &text, const rectangle &rect);
bool last_element_changed();
bool last_element_confirmed();
void leave_column();
float number_box(const float &value, float step, const rectangle &rect);
float number_box(const float &value, float step);
float number_box(const string &label, const float &value, float step);
float number_box(const string &label_text, const float &value, float step);
void open_popup(const string &name);
void paragraph(const string &text);
void paragraph(const string &text, const rectangle &rect);
Expand All @@ -77,7 +77,7 @@ void set_layout_height(int height);
void single_line_layout();
float slider(const float &value, float min_value, float max_value, const rectangle &rect);
float slider(const float &value, float min_value, float max_value);
float slider(const string &label, const float &value, float min_value, float max_value);
float slider(const string &label_text, const float &value, float min_value, float max_value);
void split_into_columns(int count);
void split_into_columns(int count, int last_width);
void split_into_columns_relative(int count, double last_width);
Expand All @@ -86,9 +86,9 @@ void start_inset(const string &name, const rectangle &rect);
void start_inset(const string &name, int height);
bool start_panel(const string &name, rectangle initial_rectangle);
bool start_popup(const string &name);
bool start_treenode(const string &label);
bool start_treenode(const string &label_text);
string text_box(const string &value);
string text_box(const string &value, const rectangle &rect);
string text_box(const string &label, const string &value);
string text_box(const string &label_text, const string &value);

#endif /* __interface_h */
6 changes: 3 additions & 3 deletions clang++/include/music.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ string music_name(music data);
music music_named(const string &name);
bool music_playing();
bool music_valid(music m);
float music_volume();
double music_volume();
void pause_music();
void play_music(const string &name);
void play_music(const string &name, int times);
void play_music(music data);
void play_music(music data, int times);
void play_music(music data, int times, float volume);
void play_music(music data, int times, double volume);
void resume_music();
void set_music_volume(float volume);
void set_music_volume(double volume);
void stop_music();

#endif /* __music_h */
8 changes: 4 additions & 4 deletions clang++/include/sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ void free_sound_effect(sound_effect effect);
bool has_sound_effect(const string &name);
sound_effect load_sound_effect(const string &name, const string &filename);
void play_sound_effect(const string &name);
void play_sound_effect(const string &name, float volume);
void play_sound_effect(const string &name, double volume);
void play_sound_effect(const string &name, int times);
void play_sound_effect(const string &name, int times, float volume);
void play_sound_effect(const string &name, int times, double volume);
void play_sound_effect(sound_effect effect);
void play_sound_effect(sound_effect effect, float volume);
void play_sound_effect(sound_effect effect, double volume);
void play_sound_effect(sound_effect effect, int times);
void play_sound_effect(sound_effect effect, int times, float volume);
void play_sound_effect(sound_effect effect, int times, double volume);
string sound_effect_filename(sound_effect effect);
string sound_effect_name(sound_effect effect);
sound_effect sound_effect_named(const string &name);
Expand Down
111 changes: 111 additions & 0 deletions clang++/include/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,22 +126,70 @@ typedef struct {
double x;
double y;
} point_2d;

inline bool operator==(const point_2d& lhs, const point_2d& rhs) {
return
lhs.x == rhs.x &&
lhs.y == rhs.y;
}

inline bool operator!=(const point_2d& lhs, const point_2d& rhs) {
return !(lhs == rhs);
}

typedef struct {
point_2d center;
double radius;
} circle;

inline bool operator==(const circle& lhs, const circle& rhs) {
return
lhs.center == rhs.center &&
lhs.radius == rhs.radius;
}

inline bool operator!=(const circle& lhs, const circle& rhs) {
return !(lhs == rhs);
}

typedef struct {
float r;
float g;
float b;
float a;
} color;

inline bool operator==(const color& lhs, const color& rhs) {
return
lhs.r == rhs.r &&
lhs.g == rhs.g &&
lhs.b == rhs.b &&
lhs.a == rhs.a;
}

inline bool operator!=(const color& lhs, const color& rhs) {
return !(lhs == rhs);
}

typedef struct {
double x;
double y;
double width;
double height;
} rectangle;

inline bool operator==(const rectangle& lhs, const rectangle& rhs) {
return
lhs.x == rhs.x &&
lhs.y == rhs.y &&
lhs.width == rhs.width &&
lhs.height == rhs.height;
}

inline bool operator!=(const rectangle& lhs, const rectangle& rhs) {
return !(lhs == rhs);
}

typedef struct {
void *dest;
float scale_x;
Expand All @@ -158,19 +206,82 @@ typedef struct {
int line_width;
animation anim;
} drawing_options;

inline bool operator==(const drawing_options& lhs, const drawing_options& rhs) {
return
lhs.dest == rhs.dest &&
lhs.scale_x == rhs.scale_x &&
lhs.scale_y == rhs.scale_y &&
lhs.angle == rhs.angle &&
lhs.anchor_offset_x == rhs.anchor_offset_x &&
lhs.anchor_offset_y == rhs.anchor_offset_y &&
lhs.flip_x == rhs.flip_x &&
lhs.flip_y == rhs.flip_y &&
lhs.is_part == rhs.is_part &&
lhs.part == rhs.part &&
lhs.draw_cell == rhs.draw_cell &&
lhs.camera == rhs.camera &&
lhs.line_width == rhs.line_width &&
lhs.anim == rhs.anim;
}

inline bool operator!=(const drawing_options& lhs, const drawing_options& rhs) {
return !(lhs == rhs);
}

typedef struct {
point_2d start_point;
point_2d end_point;
} line;

inline bool operator==(const line& lhs, const line& rhs) {
return
lhs.start_point == rhs.start_point &&
lhs.end_point == rhs.end_point;
}

inline bool operator!=(const line& lhs, const line& rhs) {
return !(lhs == rhs);
}

typedef struct {
point_2d points[4];
} quad;

inline bool operator==(const quad& lhs, const quad& rhs) {
return
lhs.points[0] == rhs.points[0] && lhs.points[1] == rhs.points[1] && lhs.points[2] == rhs.points[2] && lhs.points[3] == rhs.points[3];}

inline bool operator!=(const quad& lhs, const quad& rhs) {
return !(lhs == rhs);
}

typedef struct {
point_2d points[3];
} triangle;

inline bool operator==(const triangle& lhs, const triangle& rhs) {
return
lhs.points[0] == rhs.points[0] && lhs.points[1] == rhs.points[1] && lhs.points[2] == rhs.points[2];}

inline bool operator!=(const triangle& lhs, const triangle& rhs) {
return !(lhs == rhs);
}

typedef struct {
double x;
double y;
} vector_2d;

inline bool operator==(const vector_2d& lhs, const vector_2d& rhs) {
return
lhs.x == rhs.x &&
lhs.y == rhs.y;
}

inline bool operator!=(const vector_2d& lhs, const vector_2d& rhs) {
return !(lhs == rhs);
}


#endif /* __types_h */
2 changes: 1 addition & 1 deletion clang++/include/vector_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ bool vector_in_rect(const vector_2d &v, const rectangle &rect);
vector_2d vector_invert(const vector_2d &v);
vector_2d vector_limit(const vector_2d &v, double limit);
double vector_magnitude(const vector_2d &v);
double vector_magnitude_sqared(const vector_2d &v);
double vector_magnitude_squared(const vector_2d &v);
vector_2d vector_multiply(const vector_2d &v1, double s);
vector_2d vector_normal(const vector_2d &v);
vector_2d vector_out_of_circle_from_circle(const circle &src, const circle &bounds, const vector_2d &velocity);
Expand Down
Loading