diff --git a/Makefile b/Makefile index 7de7005..da1c3a0 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,8 @@ GTK_PACKAGES=gdk-pixbuf-2.0 gtk+-2.0 GTK_CFLAGS=$(shell pkg-config --cflags $(GTK_PACKAGES)) GTK_LIBS=$(shell pkg-config --libs $(GTK_PACKAGES)) -CFLAGS=-Wall -g -O2 $(GTK_CFLAGS) +# PROFILING_CFLAGS=-pg +CFLAGS=-Wall -g -O2 $(PROFILING_CFLAGS) $(GTK_CFLAGS) LIBS=$(GTK_LIBS) diff --git a/balls.c b/balls.c index 651cfcb..48bf475 100644 --- a/balls.c +++ b/balls.c @@ -97,7 +97,7 @@ static void ball_collision (struct ball * p, struct ball * q) { } } -static void ball_update_state (struct ball * p) { +void ball_update_state (struct ball * p) { p->x += delta*p->v_x + delta*delta*g_x/2.0; p->v_x += delta*g_x; @@ -129,16 +129,23 @@ static void ball_update_state (struct ball * p) { } } -static void update_state () { - if (collisions) { - for(int i = 0; i < n_balls; ++i) - for(int j = i + 1; j < n_balls; ++j) - ball_collision(balls + i, balls + j); - } +void movement_and_borders () { for(int i = 0; i < n_balls; ++i) ball_update_state(balls + i); } +void check_collisions () { + for(int i = 0; i < n_balls; ++i) + for(int j = i + 1; j < n_balls; ++j) + ball_collision(balls + i, balls + j); +} + +static void update_state () { + if (collisions) + check_collisions(); + movement_and_borders(); +} + /* Graphics System */