From a4d2b83d29a78d171deb2c6447369d94e752f2cb Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Tue, 21 May 2013 18:57:11 -0400 Subject: Make balls move. --- (limited to 'src/ball.c') diff --git a/src/ball.c b/src/ball.c index 91c2995..3515b68 100644 --- a/src/ball.c +++ b/src/ball.c @@ -1,10 +1,11 @@ #include +#include #include #include "ball.h" struct ball * -new_ball(float x, float y) +new_ball(float x, float y, float speed, float dir) { struct ball *b; @@ -15,6 +16,8 @@ new_ball(float x, float y) b->x = x; b->y = y; + b->speed = speed; + b->dir = dir; return b; } @@ -34,7 +37,8 @@ clear_ball(struct ball *b) void update_ball(struct ball *b) { - ++b; + b->x += cosf(b->dir) * b->speed; + b->y += sinf(b->dir) * b->speed; } void -- cgit v0.9.1