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

julio (none) julio at julio-desktop.
Sat Jun 26 02:51:33 UTC 2010


The following commit has been merged in the master branch:
commit ad5065648c8bac1e1877fdd6aaeed7482f080327
Author: julio <julio at julio-desktop.(none)>
Date:   Fri Jun 25 21:50:40 2010 -0500

    Declaring globlar vars

diff --git a/data/Makefile.am b/data/Makefile.am
index 01aeaf0..c197dd7 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -4,6 +4,7 @@
 SUBDIRS = fonts	\
 	images	\
 	menus \
-	sounds
+	sounds \
+	maps
 
 #EXTRA_DIST = options
diff --git a/data/maps/Makefile.am b/data/maps/Makefile.am
index 93136df..8aaf57f 100644
--- a/data/maps/Makefile.am
+++ b/data/maps/Makefile.am
@@ -1,9 +1,6 @@
-## Makefile.am for tuxmath - data:
-## Process with Automake to create Makefile.in
+## Makefile.am for tuxhistory data/maps:
 
-#SUBDIRS = fonts	\
-#	images	\
-#	menus \
-#	maps \
-#	sounds
+## Process with AutoMake:
+mapsdir = $(pkgdatadir)/maps
 
+dist_grassland_DATA = map.xml
diff --git a/data/maps/map.xml b/data/maps/map.xml
new file mode 100644
index 0000000..d777dc2
--- /dev/null
+++ b/data/maps/map.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0"?>
+
+<data>
+    <size>
+        <height></height>
+        <width></width>
+    </size>
+
+    <row>
+        <tilde>
+            <height>1</height>
+            <terrain>grassland</terrain>
+            <object></object>
+            <unit></unit>
+            <building></building>
+        </tilde>
+        <tilde>
+            <height>1</height>
+            <terrain>GRASSLAND</terrain>
+            <object></object>
+            <unit></unit>
+            <building></building>
+        </tilde>
+        <tilde>
+            <height>1</height>
+            <terrain>GRASSLAND</terrain>
+            <object></object>
+            <unit></unit>
+            <building></building>
+        </tilde>
+    </row>
+    <row>
+        <tilde>
+            <height>1</height>
+            <terrain>GRASSLAND</terrain>
+            <object></object>
+            <unit></unit>
+            <building></building>
+        </tilde>
+        <tilde>
+            <height>1</height>
+            <terrain>GRASSLAND</terrain>
+            <object></object>
+            <unit></unit>
+            <building></building>
+        </tilde>
+        <tilde>
+            <height>1</height>
+            <terrain>GRASSLAND</terrain>
+            <object></object>
+            <unit></unit>
+            <building></building>
+        </tilde>
+    </row>
+    <row>
+        <tilde>
+            <height>1</height>
+            <terrain>GRASSLAND</terrain>
+            <object></object>
+            <unit></unit>
+            <building></building>
+        </tilde>
+        <tilde>
+            <height>1</height>
+            <terrain>GRASSLAND</terrain>
+            <object></object>
+            <unit></unit>
+            <building></building>
+        </tilde>
+        <tilde>
+            <height>1</height>
+            <terrain>GRASSLAND</terrain>
+            <object></object>
+            <unit></unit>
+            <building></building>
+        </tilde>
+    </row>
+</data>
+
+    
diff --git a/src/globals.h b/src/globals.h
index 238355e..8dea453 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -1,23 +1,20 @@
 /*
   globals.h
 
-  For TuxMath
+  For TuxHistory (stolen from TuxMath) 
 
   Contains global data for configuration of math questions and for
   general game options, as well as constants and defaults.  Nothing
   depending on SDL should be in here; put any SDL-related items into
-  tuxmath.h.
+  tuxhistory.h.
 
   Author: David Bruce <davidstuartbruce at gmail.com>, (C) 2006
 
-
   Part of "Tux4Kids" Project
   http://www.tux4kids.org/
 
-  Added March 2, 2006
-
   Copyright: See COPYING file that comes with this distribution
-  (briefly - GNU GPL v2 or later)
+  (briefly - GNU GPL v3 or later)
 */
 
 
@@ -112,6 +109,13 @@ extern const int debug_all;
 #define DEFAULT_CITY_EXPL_HANDICAP 0
 #define DEFAULT_LAST_SCORE 0
 
+/* MAX definition for the map handling...*/
+
+#define MAX_X_TILDES
+#define MAX_Y_TILDES
+
+#define MAX_OBJECTS
+
 /* These values are hard-coded and used 'as is' by the program */
 /* (i.e. these behaviors require recompilation to change)   */ 
 #define DEFAULT_NUM_CITIES 4   /* MUST BE AN EVEN NUMBER! */
@@ -140,29 +144,7 @@ extern const int debug_all;
 
 #define PIXEL_BITS 32
 
-enum {
-  CADET_HIGH_SCORE,
-  SCOUT_HIGH_SCORE,
-  RANGER_HIGH_SCORE,
-  ACE_HIGH_SCORE,
-  COMMANDO_HIGH_SCORE,
-  NUM_MATH_COMMAND_LEVELS
-};
-
-enum {
-  FACTORS_HIGH_SCORE = NUM_MATH_COMMAND_LEVELS,
-  FRACTIONS_HIGH_SCORE,
-  NUM_HIGH_SCORE_LEVELS
-};
-
-
 
 #define NAME_BUF_SIZE 200
 
-/* data for 'Training Academy' lessons: */
-extern char **lesson_list_titles;
-extern char **lesson_list_filenames;
-extern int* lesson_list_goldstars;
-extern int num_lessons;
-
 #endif
diff --git a/src/loaders.c b/src/loaders.c
index 3edf064..2295dd3 100644
--- a/src/loaders.c
+++ b/src/loaders.c
@@ -47,7 +47,7 @@ void            fit_in_rectangle(int* width, int* height, int max_width, int max
 SDL_Surface*    set_format(SDL_Surface* img, int mode);
 sprite*         load_sprite(const char* name, int mode, int w, int h, bool proportional);
 
-FILE*           load_map(const char* file_name);
+FILE*           LoadMap(const char* file_name);
 
 /* check to see if file exists, if so return true */
 // int checkFile( const char *file ) {
@@ -670,7 +670,7 @@ FILE* load_map(const char* name)
 
 
   /* check if map file is present */
-  sprintf(fn, "%s/maps/%s.map", DATA_PREFIX, name);
+  sprintf(fn, "%s/maps/%s.xml", DATA_PREFIX, name);
   fn_len = strlen(fn);
 
   if(strcmp(fn + fn_len - 4, ".map"))
diff --git a/src/loaders.h b/src/loaders.h
index e5df094..c7f8b4e 100644
--- a/src/loaders.h
+++ b/src/loaders.h
@@ -53,4 +53,6 @@ void         NextFrame(sprite* s);
 Mix_Chunk*   LoadSound(char* datafile);
 Mix_Music*   LoadMusic(char *datafile);
 
+FILE*        LoadMap(const char* file_name);
+
 #endif /* LOADERS_H */
diff --git a/src/map.h b/src/map.h
index 398f594..a30762a 100644
--- a/src/map.h
+++ b/src/map.h
@@ -5,9 +5,8 @@
  *  This data structure shoultn't be accesed
  *  directly.
  */
-
-#define MAX_X_TILDES
-#define MAX_Y_TILDES
+#ifndef MAP_H
+#define MAP_H
 
 // List of objects that can be used
 // in create_object. 
@@ -44,8 +43,6 @@ typedef struct th_obj{
     int move; 
 }th_obj;
 
-//The map array.
-th_map map[MAX_X_TILDES][MAX_Y_TILDES];
     
 void th_draw_map(void);
 
@@ -54,3 +51,4 @@ void th_draw_map(void);
 
 char* th_serialize_map(th_map **);
 
+#endif
diff --git a/src/setup.c b/src/setup.c
index a364b43..ec8af50 100644
--- a/src/setup.c
+++ b/src/setup.c
@@ -1,7 +1,7 @@
 /*
   setup.c
 
-  For TuxHistory
+  For TuxHistory (stolen from tuxmath)
   Contains some globals (screen surface, images, some option flags, etc.)
   as well as the function to load data files (images, sounds, music)
   and display a "Loading..." screen.
@@ -44,6 +44,7 @@
 #include "setup.h"
 #include "fileops.h"
 #include "loaders.h"
+#include "map.h"
 #include "game.h"
 #include "menu.h"
 #include "titlescreen.h"
@@ -56,7 +57,7 @@
 //#endif
 
 /* Global data used in setup.c:              */
-/* (These are now 'extern'd in "tuxmath.h") */
+/* (These are now 'extern'd in "tuxhsitory.h") */
 
 /* window size */
 int win_res_x = 640;
@@ -66,6 +67,12 @@ int win_res_y = 480;
 int fs_res_x = 0;
 int fs_res_y = 0;
 
+/*Global tuxhistory vars*/
+
+th_map map[MAX_X_TILDES][MAX_Y_TILDES]; //The map array.
+th_obj* object = NULL;
+
+
 SDL_Surface* screen;
 SDL_Surface* images[NUM_IMAGES];
 sprite* sprites[NUM_SPRITES];
@@ -88,6 +95,7 @@ void initialize_options(void);
 void handle_command_args(int argc, char* argv[]);
 void initialize_SDL(void);
 void load_data_files(void);
+void data_memory_alloc(void);
 
 //int initialize_game_options(void);
 void seticon(void);
@@ -97,6 +105,7 @@ void cleanup_memory(void);
 
 
 
+
 /* --- Set-up function - now in four easier-to-digest courses! --- */
 /* --- Er - make that six courses! --- */
 /* --- Six is right out. Seven is much better. --- */
@@ -587,6 +596,19 @@ void load_data_files(void)
   }
 }
 
+void data_memory_alloc(void)
+{
+    object = NULL;
+    object = (th_obj *)malloc(MAX_OBJECTS * sizeof(th_obj));
+    if object = NULL;
+    {
+        printf("Allocation of game objects filed!\n");
+        exit(0);
+    }
+}
+
+
+
 /* save options and free heap */
 /* use for successful exit */
 void cleanup(void)
@@ -623,6 +645,9 @@ void cleanup_memory(void)
   int frequency,channels,n_timesopened;
   Uint16 format;
 
+  /* Free global memory allocation ( from memory_data_alloc() )*/
+  free(object);
+
   /* Free all images and sounds used by SDL: */
   Cleanup_SDL_Text();
 
@@ -633,6 +658,20 @@ void cleanup_memory(void)
     images[i] = NULL;
   }
 
+  for (i = 0; i < NUM_TERRAINS; i++)
+  {
+    if (terrain[i])
+      SDL_FreeSurface(terrain[i]);
+    terrain[i] = NULL;
+  }
+
+  for (i = 0; i < NUM_OBJECTS; i++)
+  {
+    if (objects[i])
+      SDL_FreeSurface(objects[i]);
+    objects[i] = NULL;
+  }
+
   for (i = 0; i < NUM_SOUNDS; i++)
   {
     if (sounds[i])
diff --git a/src/titlescreen.c b/src/titlescreen.c
index e36e859..420b58c 100644
--- a/src/titlescreen.c
+++ b/src/titlescreen.c
@@ -8,9 +8,8 @@
                        : (C) 2003 by Jesse Andrews
   email                : tuxtype-dev at tux4kids.net
 
-  Modified for use in tuxmath by David Bruce - 2006-2007.
-  email                : <davidstuartbruce at gmail.com>
-                         <tuxmath-devel at lists.sourceforge.net>
+  Modified for use in tuxhistory by Jesus Mager
+  from tuxmath version (by David Bruce - 2006-2007)
 
   Also significantly enhanced by Tim Holy - 2007
 
diff --git a/src/titlescreen.h b/src/titlescreen.h
index 6058f53..8e42ce7 100644
--- a/src/titlescreen.h
+++ b/src/titlescreen.h
@@ -9,9 +9,8 @@
                        : (C) 2003 by Jesse Andrews
   email                : tuxtype-dev at tux4kids.net
 
-  Modified for use in tuxmath by David Bruce - 2006-2007.
-  email                : <davidstuartbruce at gmail.com>
-                         <tuxmath-devel at lists.sourceforge.net>
+  Modified for use in tuxhistory by Jesus Mager
+  from tuxmath version (by David Bruce - 2006-2007)
 
   Also significantly enhanced by Tim Holy - 2007
 
diff --git a/src/tuxhistory.h b/src/tuxhistory.h
index dd4fe14..914e0f1 100644
--- a/src/tuxhistory.h
+++ b/src/tuxhistory.h
@@ -66,6 +66,8 @@ extern sprite* sprites[];
 extern SDL_Surface* flipped_images[];
 extern SDL_Surface* terrain[];
 extern SDL_Surface* objects[];
+extern th_map map[][];
+extern th_obj* object;
 
 #define NUM_BLENDED_IGLOOS 15
 extern SDL_Surface* blended_igloos[];

-- 
tuxhistory - Educational history game



More information about the Tux4kids-commits mailing list