mirror of
http://git.davidovski.xyz/rope
synced 2024-08-15 00:43:42 +00:00
disconnected the loop
This commit is contained in:
parent
d96305c012
commit
2fb42ea102
1 changed files with 15 additions and 8 deletions
19
rope.c
19
rope.c
|
@ -16,7 +16,7 @@ typedef struct point {
|
||||||
int next;
|
int next;
|
||||||
} Point;
|
} Point;
|
||||||
|
|
||||||
Point points[64];
|
Point points[8];
|
||||||
|
|
||||||
int populatePoints() {
|
int populatePoints() {
|
||||||
int count = sizeof(points) / sizeof(Point);
|
int count = sizeof(points) / sizeof(Point);
|
||||||
|
@ -69,14 +69,18 @@ int draw(void) {
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
Point *p = &points[i];
|
Point *p = &points[i];
|
||||||
Point *n = &points[(i+1)% count];
|
|
||||||
Point *m = &points[(i-1)% count];
|
|
||||||
|
|
||||||
p->vel.x = 0;
|
p->vel.x = 0;
|
||||||
p->vel.y = 0;
|
p->vel.y = 0;
|
||||||
|
|
||||||
|
if (i+1 < count) {
|
||||||
|
Point *n = &points[(i+1)];
|
||||||
physics(p, n);
|
physics(p, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i-1 > -1) {
|
||||||
|
Point *m = &points[(i-1)];
|
||||||
physics(p, m);
|
physics(p, m);
|
||||||
|
}
|
||||||
|
|
||||||
p->pos.x += p->vel.x;
|
p->pos.x += p->vel.x;
|
||||||
p->pos.y += p->vel.y;
|
p->pos.y += p->vel.y;
|
||||||
|
@ -96,11 +100,14 @@ int draw(void) {
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
Point *p = &points[i];
|
Point *p = &points[i];
|
||||||
Point *n = &points[(i+1)% count];
|
if (i+1 < count) {
|
||||||
DrawCircle(p->pos.x, p->pos.y, radius, DARKGRAY);
|
Point *n = &points[(i+1)];
|
||||||
DrawLineEx(p->pos, n->pos, radius / 2, DARKGRAY);
|
DrawLineEx(p->pos, n->pos, radius / 2, DARKGRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DrawCircle(p->pos.x, p->pos.y, radius, DARKGRAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue