aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c55
1 files changed, 21 insertions, 34 deletions
diff --git a/src/main.c b/src/main.c
index 4d69c1b..f6a1de3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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()
};
}
}