Put gatebeams in a vector as an experiment.
authorGwyn Ciesla <limburgher@gmail.com>
Fri, 5 Jan 2018 20:47:23 +0000 (14:47 -0600)
committerGwyn Ciesla <limburgher@gmail.com>
Fri, 5 Jan 2018 20:47:23 +0000 (14:47 -0600)
main.cpp

index b0e62c2..0c3e9fd 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -27,6 +27,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <sys/stat.h>
 #include <unistd.h>
 #include <string>
+#include <vector>
 #include "SDL2/SDL.h"
 #include "SDL2/SDL_mixer.h"
 
@@ -170,6 +171,11 @@ int main(int argc, char *argv[]){
   strcpy (gatebeam3.line3, " ] ");
   strcpy (gatebeam3.radar, "|");
 
+  std::vector<game_object> gatebeams;
+  gatebeams.insert(gatebeams.begin(), gatebeam1);
+  gatebeams.insert(gatebeams.begin(), gatebeam2);
+  gatebeams.insert(gatebeams.begin(), gatebeam3);
+
   //pods
   game_object pods[podmax] = {
     { 2, 1, 18, rand()%620, 0, 0, 1, 0, 0 },
@@ -709,9 +715,9 @@ int main(int argc, char *argv[]){
       };
     };
 
-    gatebeam1 = process_motion(gatebeam1, player);
-    gatebeam2 = process_motion(gatebeam2, player);
-    gatebeam3 = process_motion(gatebeam3, player);
+    for (std::vector<game_object>::iterator it=gatebeams.begin(); it<gatebeams.end(); ++it){
+      *it = process_motion(*it, player);
+    };
     
     for(int bulletloop = 0; bulletloop<bulletmax; bulletloop++){ 
       if(bullets[bulletloop].active==1){ 
@@ -817,9 +823,9 @@ int main(int argc, char *argv[]){
 
     // Draw gate object 10
     drawlocation = draw_object(gate, drawlocation);
-    drawlocation = draw_object(gatebeam1, drawlocation);
-    drawlocation = draw_object(gatebeam2, drawlocation);
-    drawlocation = draw_object(gatebeam3, drawlocation);
+    for (std::vector<game_object>::iterator it=gatebeams.begin(); it<gatebeams.end(); ++it){
+      drawlocation = draw_object(*it, drawlocation);
+    };
 
     // Draw landers objects 60-71
     for(int landerloop = 0; landerloop<landermax; landerloop++){ 
@@ -899,9 +905,9 @@ int main(int argc, char *argv[]){
 
     //Radar plot 18x620 represented in 4x62
     radar_plot(gate, drawlocation);
-    radar_plot(gatebeam1, drawlocation);
-    radar_plot(gatebeam2, drawlocation);
-    radar_plot(gatebeam3, drawlocation);
+    for (std::vector<game_object>::iterator it=gatebeams.begin(); it<gatebeams.end(); ++it){
+      radar_plot(*it, drawlocation);
+    };
     for(int podloop = 0; podloop<podmax; podloop++){ radar_plot(pods[podloop], drawlocation); };
     for(int landerloop = 0; landerloop<landermax; landerloop++){ radar_plot(landers[landerloop], drawlocation); };
     for(int crazyloop = 0; crazyloop<landermax; crazyloop++){ radar_plot(crazies[crazyloop], drawlocation); };