[Tux4kids-commits] [SCM] tuxhistory - Educational history game branch, master, updated. 048ca1b3bbc082c2506a1a15eedca236b0df747e

julio (none) julio at julio-desktop.
Mon Jun 28 07:15:00 UTC 2010


The following commit has been merged in the master branch:
commit 048ca1b3bbc082c2506a1a15eedca236b0df747e
Author: julio <julio at julio-desktop.(none)>
Date:   Mon Jun 28 02:14:06 2010 -0500

    Minor changes, declaring map_image as a surface...

diff --git a/src/game.c b/src/game.c
index 44de444..5a76ea1 100644
--- a/src/game.c
+++ b/src/game.c
@@ -101,6 +101,13 @@ static int game_init(void)
     SDL_quit_received = 0;
     escape_received = 0;
 
+    
+    if(!map_xml(LoadMap("map")))
+    {
+        DEBUGMSG(debug_game, "Error loading the map file.\n");
+        return 0;
+    }
+
     return 1;
 }
 
diff --git a/src/globals.h b/src/globals.h
index 6fb3ff5..019adf8 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -112,7 +112,8 @@ extern const int debug_all;
 #define DEFAULT_CITY_EXPL_HANDICAP 0
 #define DEFAULT_LAST_SCORE 0
 
-/* MAX definition for the map handling...*/
+/* MAX definition for the map handling...
+ * TODO: This are not the real values*/
 
 #define MAX_X_TILDES 100
 #define MAX_Y_TILDES 100
diff --git a/src/loaders.c b/src/loaders.c
index 2295dd3..c6c6314 100644
--- a/src/loaders.c
+++ b/src/loaders.c
@@ -655,7 +655,7 @@ Mix_Music* LoadMusic(char *datafile )
 }
 
 /* load_map: Load map from a XML datafile */
-FILE* load_map(const char* name)
+FILE* LoadMap(const char* name)
 {
   FILE *fp = NULL;
   char fn[PATH_MAX];
@@ -673,7 +673,7 @@ FILE* load_map(const char* name)
   sprintf(fn, "%s/maps/%s.xml", DATA_PREFIX, name);
   fn_len = strlen(fn);
 
-  if(strcmp(fn + fn_len - 4, ".map"))
+  if(strcmp(fn + fn_len - 4, ".xml"))
   {
     DEBUGMSG(debug_loaders, "load_map(): %s is not an TuxHistory XML Map file\n", fn);
     return NULL;
diff --git a/src/map.h b/src/map.h
index 9236631..2c49b98 100644
--- a/src/map.h
+++ b/src/map.h
@@ -53,6 +53,13 @@ typedef struct {
     //th_obj *obj;// Pointer to object
 }th_map;
 
+int map_xml(FILE *fp);
+
+// generate a map from the basic xml input to a 
+// visual atractive one.
+
+int generate_map(void);
+
 // th_obj represent each object in the field, in 
 // each tilde there can be only one object.
 
diff --git a/src/setup.c b/src/setup.c
index d057968..ba8adfa 100644
--- a/src/setup.c
+++ b/src/setup.c
@@ -73,6 +73,7 @@ th_obj* object = NULL;
 
 
 SDL_Surface* screen;
+SDL_Surface* map_image;
 SDL_Surface* images[NUM_IMAGES];
 sprite* sprites[NUM_SPRITES];
 SDL_Surface* terrain[NUM_TERRAINS];
@@ -562,7 +563,7 @@ void initialize_SDL(void)
 
     seticon();
 
-    SDL_WM_SetCaption("Tux, of Math Command", "TuxMath");
+    SDL_WM_SetCaption("Tu History", "TuxHistory");
   }
 
   /* --- Define the colors we use --- */
@@ -603,7 +604,7 @@ void data_memory_alloc(void)
     object = (th_obj*)malloc(MAX_OBJECTS * sizeof(th_obj));
     if (object == NULL)
     {
-        printf("Allocation of game objects filed!\n");
+        printf("Allocation of game objects faild!\n");
         exit(0);
     }
 
@@ -619,10 +620,20 @@ void data_memory_alloc(void)
         map[i] = (th_map*)malloc(MAX_Y_TILDES * sizeof(th_map));
         if(map[i] == NULL)
         {
-            printf("Error, no hay memoria suficinete\n");
+            printf("Error: Allocation of objects faild!\n");
             exit(0);
         }
     }
+
+    map_image = NULL;
+    map_image = SDL_CreateRGBSurface(SDL_SWSURFACE, MAP_WIDTH, MAP_HEIGHT, 32,
+                           rmask, gmask, bmask, amask); //32 Bits are OK?
+    if(map_image == NULL)
+    {
+        printf("Couldn't Create img_image");
+        exit(0);
+    }
+
 }
 
 
@@ -672,7 +683,7 @@ void cleanup_memory(void)
   }
   FREE(map);
 
-  
+  SDL_FreeSurface(map_image);
 
   /* Free all images and sounds used by SDL: */
   Cleanup_SDL_Text();
diff --git a/src/setup.h b/src/setup.h
index ab0f839..01f8b53 100644
--- a/src/setup.h
+++ b/src/setup.h
@@ -32,6 +32,12 @@
 #ifndef SETUP_H
 #define SETUP_H
 
+#include "fileops.h"
+
+int MAP_HEIGHT = MAX_X_TILDES * terrain[0]->h;
+int MAP_WIDTH = MAX_Y_TILDES * terrain[0]->w;
+
+
 void setup(int argc, char * argv[]);
 void cleanup(void);
 void cleanup_on_error(void);
diff --git a/src/tuxhistory.h b/src/tuxhistory.h
index fd90e81..7ff1cdc 100644
--- a/src/tuxhistory.h
+++ b/src/tuxhistory.h
@@ -62,6 +62,7 @@ extern SDL_Color white;
 extern SDL_Color yellow;
 
 extern SDL_Surface* screen; /* declared in setup.c; also used in game.c, options.c, fileops.c, credits.c, titlescreen.c */
+extern SDL_Surface* map_image;
 extern SDL_Surface* images[];    /* declared in setup.c, used in same files as screen */
 extern sprite* sprites[];
 extern SDL_Surface* flipped_images[];

-- 
tuxhistory - Educational history game



More information about the Tux4kids-commits mailing list