From: Matthew Mondor Date: Tue, 25 Apr 2023 03:42:25 +0000 (+0000) Subject: Improve function prototypes and move globals from header to module. X-Git-Url: http://git.pulsar-zone.net/?a=commitdiff_plain;h=70be64c54665c3ca043e1d7ebaa5df336c744cc1;p=ninvaders.git Improve function prototypes and move globals from header to module. --- diff --git a/aliens.c b/aliens.c index ac1f67e..95f3405 100644 --- a/aliens.c +++ b/aliens.c @@ -30,11 +30,19 @@ Aliens aliens; int shipnum; +// todo: move to structure +static int lowest_ship[ALIENS_MAX_NUMBER_X]; +static int alienshotx[ALIENS_MAX_MISSILES]; +static int alienshoty[ALIENS_MAX_MISSILES]; +static int alienshotnum; +static int alienBlock[ALIENS_MAX_NUMBER_Y][ALIENS_MAX_NUMBER_X]; +static int bunker[BUNKERHEIGHT][BUNKERWIDTH + 1]; + /** * initialize aliens attributes */ -void aliensReset() +void aliensReset(void) { int i,j; @@ -81,7 +89,7 @@ void aliensReset() /** * initialize bunkers attributes */ -void bunkersReset() +void bunkersReset(void) { int a, b; @@ -114,7 +122,7 @@ void bunkersReset() * move aliens and test if they've reached the * bottom of the windows or the bunkers. */ -int aliensMove() +int aliensMove(void) { int cx,cy; @@ -158,7 +166,7 @@ int aliensMove() /** * display alien animation, display remaining parts of aliens and bunker */ -void render() +void render(void) { int k,row; int c=0; @@ -201,7 +209,7 @@ void render() * move aliens' missiles and do player/bunker hit testing * a zero value in alienshotx indicates that the appropriate missile is loaded, but not fired */ -int aliensMissileMove() +int aliensMissileMove(void) { int i, tmp; int fPlayerWasHit = 0; diff --git a/aliens.h b/aliens.h index 592019c..c68e704 100644 --- a/aliens.h +++ b/aliens.h @@ -45,14 +45,6 @@ extern int shipnum; #define ALIENS_MAX_NUMBER_Y 5 #define ALIENS_MAX_MISSILES 10 -// todo: move to structure -int lowest_ship[ALIENS_MAX_NUMBER_X]; -int alienshotx[ALIENS_MAX_MISSILES]; -int alienshoty[ALIENS_MAX_MISSILES]; -int alienshotnum; -int alienBlock[ALIENS_MAX_NUMBER_Y][ALIENS_MAX_NUMBER_X]; - -int bunker[BUNKERHEIGHT][BUNKERWIDTH + 1]; void aliensReset(void); diff --git a/ufo.c b/ufo.c index c2acc0c..9267a5b 100644 --- a/ufo.c +++ b/ufo.c @@ -34,7 +34,7 @@ Ufo ufo; /** * initialize ufo attributes */ -void ufoReset() +void ufoReset(void) { ufoClear(ufo.posX, ufo.posY); // clear old position of player @@ -58,7 +58,7 @@ static void ufoMove(int posX) /** * move ufo and check if it reached the left screen border */ -void ufoMoveLeft() +void ufoMoveLeft(void) { // check if space between ufo and screen border is big enough if (ufo.posX > 1) { @@ -73,7 +73,7 @@ void ufoMoveLeft() * check if the first screen line is free for the ufo and * display it randomly */ -int ufoShowUfo() +int ufoShowUfo(void) { if (aliens.posY > 0 && fShowUfo == 0) { // aliens one line down if ((random() % 200) == 0) {