From 808faafc08b70b4b655499a9505a2ed06f1c4789 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Fri, 6 Jun 2008 19:57:22 +0000 Subject: whitespace fixes, 'd' deletes last ball created git-svn-id: svn://mattst88.com/svn/glpong/trunk@18 449aeecc-241a-0410-943f-e2f883e2d7a2 --- ball.h | 1 - glpong.c | 16 ++++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ball.h b/ball.h index 2ff0221..d15e8de 100644 --- a/ball.h +++ b/ball.h @@ -16,7 +16,6 @@ typedef struct Ball_t { void GLPong_BallInit(void); void GLPong_BallDeinit(void); void GLPong_BallAdd(Ball_t ** balls); -void GLPong_BallDelete(Ball_t * from, Ball_t * ball); void GLPong_BallDeleteAll(Ball_t * list); int GLPong_BallCollide(const Ball_t * a, const Ball_t * b); void GLPong_BallMoveAll(Ball_t ** balls); diff --git a/glpong.c b/glpong.c index a31829e..1f12ccf 100644 --- a/glpong.c +++ b/glpong.c @@ -20,6 +20,7 @@ static GLuint SDL_GL_NPOTSurfaceToTexture(SDL_Surface * surface, GLfloat * wrati int main(int argc, char * argv[]) { + Ball_t * temp; GLPong_t GLPong = { NULL, NULL, @@ -60,7 +61,12 @@ int main(int argc, char * argv[]) { GLPong_BallAdd(&GLPong.balls); break; case GLPONG_DELETEBALL: -/* GLPong_BallDelete(GLPong.balls, GLPong.balls);*/ + if (GLPong.balls) { + temp = GLPong.balls; + GLPong.balls = GLPong.balls->next; + free(temp); + } + printf("%d balls\n", length(GLPong.balls)); break; } GLPong_BallMoveAll(&GLPong.balls); @@ -78,15 +84,13 @@ int main(int argc, char * argv[]) { SDL_GL_SwapBuffers(); /* end drawing */ - - - + SDL_Delay(10); } - + /* clean up */ GLPong_Deinit(&GLPong); - + return 0; } -- cgit v1.2.3