Improve function prototypes and move globals from header to module.
authorMatthew Mondor <mmondor@pulsar-zone.net>
Tue, 25 Apr 2023 03:42:25 +0000 (03:42 +0000)
committerMatthew Mondor <mmondor@pulsar-zone.net>
Tue, 25 Apr 2023 03:42:25 +0000 (03:42 +0000)
aliens.c
aliens.h
ufo.c

index ac1f67e..95f3405 100644 (file)
--- a/aliens.c
+++ b/aliens.c
 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;
index 592019c..c68e704 100644 (file)
--- 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 (file)
--- 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) {