diff options
| author | kotorifan <kotorifan05@gmail.com> | 2026-04-27 17:02:49 +0200 |
|---|---|---|
| committer | kotorifan <kotorifan05@gmail.com> | 2026-04-27 17:02:49 +0200 |
| commit | 1ff5ed07b840f4f5de81592f7a9b04debf38c447 (patch) | |
| tree | a25b2cccd860522d944f1e19fd186462ff842a9c /src/main.c | |
| parent | c8ec0d2d0c57c42499f9ea95ef0ddd6ef3764f26 (diff) | |
| download | trashbinphysics-1ff5ed07b840f4f5de81592f7a9b04debf38c447.tar.gz | |
SAT works now
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 55 |
1 files changed, 21 insertions, 34 deletions
@@ -1,4 +1,8 @@ -// main.c +/** + * @file main.c + * @brief The main loop and controls + * @date 2026-04-27 + */ #include <math.h> #include <raylib.h> #include <stdbool.h> @@ -20,43 +24,29 @@ int main(void) object_t* grabbed_obj = NULL; bool anti_gravity_toggle = false; - world[0] = (object_t){ - .color = RANDOM_COLOR(), - .elast = 0.9f, - .frict = 0.99f, - .grabbed = true, - .pos_prev = {0}, - .registered = true, - .size_x = 75, - .size_y = 75, - .vel = {200, 200}, - .pos = { GetScreenWidth()/2.0f, GetScreenHeight()/2.0f }, - .obj_type = RANDOM_SHAPE() - }; - objs_count = 1; init_physics(world, MAX_OBJECTS); init_graphics(WINDOW_X, WINDOW_Y, SCREEN_TITLE); while(!WindowShouldClose()) { Vector2 pos_cursor = GetMousePosition(); - if(IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) { - if(objs_count == 0) { - grabbed_obj = NULL; - } else { - for(uint32_t iter = objs_count; iter > 0; iter--) { - object_t* obj = &world[iter - 1]; - float dx = pos_cursor.x - obj->pos.x; - float dy = pos_cursor.y - obj->pos.y; + /* if(IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) { */ + /* if(objs_count == 0) { */ + /* grabbed_obj = NULL; */ + /* } else { */ + /* for(uint32_t iter = objs_count; iter > 0; iter--) { */ + /* object_t* obj = &world[iter - 1]; */ + /* float dx = pos_cursor.x - obj->pos.x; */ + /* float dy = pos_cursor.y - obj->pos.y; */ - if(hypot(dx, dy) <= (obj->size_x && obj->size_y)) { - obj->grabbed = true; - grabbed_obj = obj; - break; - } - } - } - } + /* if(hypot(dx, dy) <= (obj->size_x && obj->size_y)) { */ + /* obj->grabbed = true; */ + /* grabbed_obj = obj; */ + /* break; */ + /* } */ + /* } */ + /* } */ + /* } */ if (IsMouseButtonReleased(MOUSE_BUTTON_RIGHT)) { if(grabbed_obj != NULL) { @@ -80,9 +70,6 @@ int main(void) .grabbed = false, .registered = true, .mass = GetRandomValue(3, 100), // will be done later - .size_x = GetRandomValue(50, 100), //everything smaller than 3 would xbe too small - .size_y = GetRandomValue(50, 100), - .obj_type = RANDOM_SHAPE() }; } } |
