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

julio (none) julio at julio-desktop.
Fri Aug 13 06:21:23 UTC 2010


The following commit has been merged in the master branch:
commit 871ac67a9e4b6aa1ea8eb9df2313085213e26481
Author: julio <julio at julio-desktop.(none)>
Date:   Fri Aug 13 01:19:35 2010 -0500

    TuxHistory reads game propieties from map xml file

diff --git a/data/maps/map.xml b/data/maps/map.xml
index ee233b9..b3d32f1 100644
--- a/data/maps/map.xml
+++ b/data/maps/map.xml
@@ -1,6 +1,19 @@
 <?xml version="1.0"?>
 
 <data>
+    <info>
+        <message1>Welcome to TuxHistory</message1>
+        <message2>Try out the game, recollect 500 food</message2>
+        <message2>to win!</message2>
+        <players>2</players>
+        <conquest>NO</conquest>
+        <population>NO</population>
+        <goal_food>500</goal_food>
+        <goal_wood>NO</goal_wood>
+        <goal_gold>NO</goal_gold>
+        <goal_stone>NO</goal_stone>
+    </info>
+
     <size>
         <height></height>
         <width></width>
diff --git a/doc/TODO.txt b/doc/TODO.txt
index 7246138..42ddb54 100644
--- a/doc/TODO.txt
+++ b/doc/TODO.txt
@@ -1,86 +1,13 @@
-TODO.txt for "tuxmath"
+TODO.txt for "tuxhistory"
 
-2010.Mar.12
+2010.August
 These are the main (difficult) issues we would like to tackle
 at some point:
 
-1. Completion of SVG support - still have many images in gameplay to be
-migrated to SVG.  Also, we should investigate whether the lengthy start-up time
-imposed by scaling calculations can be optimized, perhaps by saving the
-properly scaled images to disk on installation or first-time execution.
-
-2. The admin program needs to be finished, documented, and packaged.
-
-3. LAN mode could use some further work.  We need to properly handle server
-detection if the LAN has more than one server instance running.  Also, the
-server program could be made more robust and functional, with ability to handle
-multiple simultaneous games, and more configurability.  One prerequisite will
-be to make mathcards.c/h thread-safe.
-
-4. Completion of libt4k-common and "porting" of tuxmath to use the common lib.
-
-5. Fix of bugs in new Windows crossbuild (using mingw-cross-env) that prevent
-it from working.  As of this writing, these consist of detection of SDL_net,
-fix of crashing SDL_mixer bug, and errors generated by use of libtool.
-
-6. Dependable creation of dmg installer builds for Mac OS-X.
-
-7. Remove ".txt" extensions from text files, with renaming of them to "*.txt"
-at the time of building for Windows.
-
-Older stuff:
-2007.Oct.08
-Build:
-  * Make a relocatable binary for Linux (klik package?)
-
-Older stuff:
-2007.Oct.08
-Build:
-  * Make a relocatable binary for Linux (klik package?)
-  * Refine NSIS installer for Windows (or perhaps executable
-    itself) to create Start Menu link to options.txt file
-
-Graphics:
-  * Make game more "themable" (there is a pending request for an
-    "Egyptian" theme with pyramids and an "Islands" theme with
-    palm trees, etc.)
-  * svg support - allow game to draw correctly at any resolution.
-
-Interface:
-  * Add more sound effects and music files
-  * Speech mode
-  * Add option for number-keys to control main menu and possible options
-    (for mouseless scenarios where arrow keys might not be the available...
-    is there such a thing as numeric-only keyboards for PCs???)
-  * Implement lockfile to prevent multiple invocations.
-
-Game Play:
-  * More entertaining "victory" and "defeat" screens
-  * Add option to review missed questions to end-of-game screens
-  * Add option to play next game using missed questions from current game
-  * End-of-level calculations, bonuses and animations
-  * "Lesson server" with login - keep track of lessons completed, percent
-    correct, etc. on a per-user basis, even if installation doesn't have 
-    students log into computers individually.
-  * Multiplayer mode - points go to whoever shoots the comet first.
-  * Re-examine algorithm for spacing of comets (allow game to deliver
-    problems faster even if the comet speed limit is not raised).
-
-Documentation:
-  * Finish README.txt
-  * Finish INSTALL.txt
-
-Options:
-  * Make use of some of function keys(F1-F12) to toggle settings in-game
-    (perhaps speed control, muting of music)
-  * Save options.
-  * Admin options screen / files
-  * Command-line options based on grade-level (?)
-  * Internationalization - use gettext() for all strings
-  * Install some kind of security on --homedir, to make sure that
-    tuxmath can write but that students can't edit the files by hand?
-
-Code:
-  * Optimize graphics blitting!!!
-  * Abstract SDL_BlitSurface() calls
-
+* Make AI costumizable with Lua scripts
+* Write a complete flexible GUI for tuxhistory. We need a panel that 
+    chenges automaticly from the input from the objects xml file.
+* Better rendering of terrain. 
+* Anime the trasnitions of units when moving, working and combating.
+* Load images from files on the fly, with a reference from the xml file.
+* Improve the game performance.
diff --git a/src/game.c b/src/game.c
index d89db80..fb16fa7 100644
--- a/src/game.c
+++ b/src/game.c
@@ -41,6 +41,7 @@
 #include "tuxrts.h"
 #include "ai.h"
 #include "panel.h"
+#include "players.h"
 
 
 #define FPS 40 /* 15 frames per second */
@@ -74,8 +75,8 @@ static SDL_Surface* scaled_bkgd = NULL; //native resolution (fullscreen)
 
 // Game vars
 static SDL_Rect origin;
-static int screen_x;
-static int screen_y;
+//static int screen_x;
+//static int screen_y;
 static rts_vars selection;
 
 static th_point Pscreen;
@@ -119,7 +120,7 @@ static int check_exit_conditions(void);
 static int game_over(int);
 static int pause_game(void);
 
-static void get_mouse_pos(int, int);
+//static void get_mouse_pos(int, int);
 /************** Implementation *******************/
 
 static SDL_Surface* current_bkgd()
@@ -330,13 +331,9 @@ static void draw_unexplored(int player, th_point point)
 static void game_draw(int player)
 {
     SDL_Rect dest;
-    SDL_Rect dest2;
     list_node *obj_node;
-    char tmp_text[100];
     th_point point;
     th_point dest_point;
-    th_point tmp_point;
-    int temp1, temp2, i, j;
 
     origin.x = Pscreen.x;
     origin.y = Pscreen.y;
@@ -496,9 +493,6 @@ static void game_handle_mouse(void)
 {
     th_point Pmousemap;
     th_point Pdtmap;
-    th_point *path;
-    int i, j;
-    int tmp;
     
     Pmousemap = mouse_map(io.Pmouse, Pscreen);
     Pdtmap = Pscreen;
@@ -1027,6 +1021,10 @@ static int check_exit_conditions(void)
   }
   // TODO: Loose or win...
   return GAME_IN_PROGRESS;
+  if(thegame.goal_food < player_vars[0].food)
+  {
+    return GAME_OVER_WON;
+  }
 }
 
 
diff --git a/src/loaders.c b/src/loaders.c
index 3bf7fa4..4b2815e 100644
--- a/src/loaders.c
+++ b/src/loaders.c
@@ -660,7 +660,6 @@ FILE *LoadMap(const char* name)
   FILE *fp = NULL;
   char fn[PATH_MAX];
   int fn_len;
-  int i;
 
   /* check if map file is present */
   sprintf(fn, "%s/maps/%s.xml", DATA_PREFIX, name);
@@ -689,7 +688,6 @@ FILE *LoadObj(const char* name)
   FILE *fp = NULL;
   char fn[PATH_MAX];
   int fn_len;
-  int i;
 
   /* check if objects file is present */
   sprintf(fn, "%s/objects/%s.xml", DATA_PREFIX, name);
diff --git a/src/map.c b/src/map.c
index 46c2478..ae86734 100644
--- a/src/map.c
+++ b/src/map.c
@@ -105,6 +105,191 @@ int map_xml(FILE *fp)
     x_tildes = -1;
     y_tildes = -1;
 
+    // Get the game vars
+    
+    node = mxmlFindElement(tree, tree, "message1", 
+                NULL, NULL, MXML_DESCEND);
+    if(node)
+    {
+        if(node->child)
+        {
+            strcpy(thegame.message1, node->child->value.text.string);
+        }
+    }
+    else
+    {
+        strcpy(thegame.message1, "");
+    }
+
+    node = mxmlFindElement(tree, tree, "message2", 
+                NULL, NULL, MXML_DESCEND);
+    if(node)
+    {
+        if(node->child)
+        {
+            strcpy(thegame.message2, node->child->value.text.string);
+        }
+    }
+    else
+    {
+        strcpy(thegame.message2, "");
+    }
+
+    node = mxmlFindElement(tree, tree, "message3", 
+                NULL, NULL, MXML_DESCEND);
+    if(node)
+    {
+        if(node->child)
+        {
+            strcpy(thegame.message2, node->child->value.text.string);
+        }
+    }
+    else
+    {
+        strcpy(thegame.message2, "");
+    }
+
+    node = mxmlFindElement(tree, tree, "players", 
+                NULL, NULL, MXML_DESCEND);
+    if(node)
+    {
+        if(node->child)
+        {
+            value = atoi(node->child->value.text.string);
+            thegame.players = value;
+        }
+    }
+    else
+    {
+        thegame.players = 2;
+    }
+
+    node = mxmlFindElement(tree, tree, "population", 
+                NULL, NULL, MXML_DESCEND);
+    if(node)
+    {
+        if(node->child)
+        {
+            if(strcmp("YES",node->child->value.text.string)==0)
+            {
+                thegame.goal_population = 1;
+            }
+            else
+            {
+                thegame.goal_population = 0;
+            }
+        }
+    }
+    else
+    {
+        thegame.goal_population = 0;
+    }
+
+    node = mxmlFindElement(tree, tree, "conquest", 
+                NULL, NULL, MXML_DESCEND);
+    if(node)
+    {
+        if(node->child)
+        {
+            if(strcmp("YES",node->child->value.text.string)==0)
+            {
+                thegame.goal_conquest = 1;
+            }
+            else
+            {
+                thegame.goal_conquest = 0;
+            }
+        }
+    }
+    else
+    {
+        thegame.goal_conquest = 0;
+    }
+
+    node = mxmlFindElement(tree, tree, "goal_food", 
+                NULL, NULL, MXML_DESCEND);
+    if(node)
+    {
+        if(node->child)
+        {
+            if(strcmp("NO",node->child->value.text.string)==0)
+            {
+                thegame.goal_food = -1;
+            }
+            else
+            {
+                thegame.goal_food = atoi(node->child->value.text.string);
+            }
+        }
+    }
+    else
+    {
+        thegame.goal_food = -1;
+    }
+
+    node = mxmlFindElement(tree, tree, "goal_wood", 
+                NULL, NULL, MXML_DESCEND);
+    if(node)
+    {
+        if(node->child)
+        {
+            if(strcmp("NO",node->child->value.text.string)==0)
+            {
+                thegame.goal_wood = -1;
+            }
+            else
+            {
+                thegame.goal_wood = atoi(node->child->value.text.string);
+            }
+        }
+    }
+    else
+    {
+        thegame.goal_wood = -1;
+    }
+    
+    node = mxmlFindElement(tree, tree, "goal_gold", 
+                NULL, NULL, MXML_DESCEND);
+    if(node)
+    {
+        if(node->child)
+        {
+            if(strcmp("NO",node->child->value.text.string)==0)
+            {
+                thegame.goal_gold = -1;
+            }
+            else
+            {
+                thegame.goal_gold = atoi(node->child->value.text.string);
+            }
+        }
+    }
+    else
+    {
+        thegame.goal_gold = -1;
+    }
+
+    node = mxmlFindElement(tree, tree, "goal_stone", 
+                NULL, NULL, MXML_DESCEND);
+    if(node)
+    {
+        if(node->child)
+        {
+            if(strcmp("NO",node->child->value.text.string)==0)
+            {
+                thegame.goal_stone = -1;
+            }
+            else
+            {
+                thegame.goal_stone = atoi(node->child->value.text.string);
+            }
+        }
+    }
+    else
+    {
+        thegame.goal_stone = -1;
+    }
+
     for(inode = mxmlFindElement(tree, tree, "row", 
                 NULL, NULL, MXML_DESCEND);
             inode != NULL;
diff --git a/src/map.h b/src/map.h
index 7939b60..08e7626 100644
--- a/src/map.h
+++ b/src/map.h
@@ -39,6 +39,20 @@ typedef struct th_map{
     //int obj_id;
 }th_map;
 
+typedef struct th_game{
+    char message1[100];
+    char message2[100];
+    char message3[100];
+    int players;
+    int goal_conquest;
+    int goal_population;
+    int goal_food;
+    int goal_wood;
+    int goal_stone;
+    int goal_gold;
+}th_game;
+
+th_game thegame;
 th_point **anchor_map;
 struct hashtable *map_table_hash; //Values of Terrains and objects
 int flag_map; // Map flag: is a map surface allocated? 
diff --git a/src/panel.c b/src/panel.c
index 32d02c3..5f5b6a3 100644
--- a/src/panel.c
+++ b/src/panel.c
@@ -23,6 +23,7 @@
 #include "setup.h"
 #include "fileops.h"
 #include "players.h"
+#include "ai.h"
 
 static int rect_coll(th_point *p, SDL_Rect *r);
 
@@ -96,9 +97,8 @@ int panel_init(void)
 // from the object xml file info!
 void panel_draw(th_obj *select, int num)
 {
-    SDL_Rect dest, dest2, rect;
+    SDL_Rect dest, rect;
     char tmp_text[100];
-    int menu_y =(screen->h / 5) * 4;
 
     rect.x = 0;
     rect.y = 0;
diff --git a/src/tuxrts.c b/src/tuxrts.c
index 1fa97c3..6141cbe 100644
--- a/src/tuxrts.c
+++ b/src/tuxrts.c
@@ -10,13 +10,12 @@
 #include "graphs.h"
 #include "llist.h"
 #include "ai.h"
+#include "panel.h"
 
 
 int tuxrts_init(char *object_name, char *map_name, int players)
 {
-    float zoom;
     FILE *fp;
-    SDL_Surface *tmp_surf;
 
     object_counter = 0;
 
@@ -79,8 +78,6 @@ int tuxrts_init(char *object_name, char *map_name, int players)
 // and 0 if not.
 int rts_valid_tile(int player, int unit, th_point coords)
 {
-    list_node *node;
-    th_obj *obj_p;
     if(coords.x < 0 || coords.x > x_tildes)
         return 0;
     if(coords.y < 0 || coords.y > y_tildes)
@@ -196,7 +193,6 @@ int rts_goto(th_obj *obj, th_point point)
     th_path *path;
     th_point source;
     th_point tmp_point, extra_point;
-    int l;
     int action;
 
     if(!obj)
@@ -320,8 +316,6 @@ int rts_build(th_obj *obj, int type, th_point point)
     th_point extra_point;
     th_obj *obj_template;
     th_obj new_obj;
-    char obj_name[50];
-    int l;
     int action;
 
     if(type >= NUM_OBJECTS)

-- 
tuxhistory - Educational history game



More information about the Tux4kids-commits mailing list