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
23
rope.c
23
rope.c
|
@ -16,7 +16,7 @@ typedef struct point {
|
|||
int next;
|
||||
} Point;
|
||||
|
||||
Point points[64];
|
||||
Point points[8];
|
||||
|
||||
int populatePoints() {
|
||||
int count = sizeof(points) / sizeof(Point);
|
||||
|
@ -69,14 +69,18 @@ int draw(void) {
|
|||
|
||||
for (int i = 0; i < count; i++) {
|
||||
Point *p = &points[i];
|
||||
Point *n = &points[(i+1)% count];
|
||||
Point *m = &points[(i-1)% count];
|
||||
|
||||
p->vel.x = 0;
|
||||
p->vel.y = 0;
|
||||
|
||||
physics(p, n);
|
||||
physics(p, m);
|
||||
if (i+1 < count) {
|
||||
Point *n = &points[(i+1)];
|
||||
physics(p, n);
|
||||
}
|
||||
|
||||
if (i-1 > -1) {
|
||||
Point *m = &points[(i-1)];
|
||||
physics(p, m);
|
||||
}
|
||||
|
||||
p->pos.x += p->vel.x;
|
||||
p->pos.y += p->vel.y;
|
||||
|
@ -96,9 +100,12 @@ int draw(void) {
|
|||
|
||||
for (int i = 0; i < count; i++) {
|
||||
Point *p = &points[i];
|
||||
Point *n = &points[(i+1)% count];
|
||||
if (i+1 < count) {
|
||||
Point *n = &points[(i+1)];
|
||||
DrawLineEx(p->pos, n->pos, radius / 2, DARKGRAY);
|
||||
}
|
||||
|
||||
DrawCircle(p->pos.x, p->pos.y, radius, DARKGRAY);
|
||||
DrawLineEx(p->pos, n->pos, radius / 2, DARKGRAY);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue