[Tux4kids-commits] [SCM] tuxhistory - Educational history game branch, master, updated. d4fce6b7a0a27502d60fb9a4376c358d34831212
julio (none)
julio at julio-desktop.
Mon Jul 12 02:00:52 UTC 2010
The following commit has been merged in the master branch:
commit d4fce6b7a0a27502d60fb9a4376c358d34831212
Author: julio <julio at julio-desktop.(none)>
Date: Sun Jul 11 20:59:53 2010 -0500
Adding Players.c/h and graphs.c/h
diff --git a/data/maps/map.xml b/data/maps/map.xml
index 49e8c44..6dfae11 100644
--- a/data/maps/map.xml
+++ b/data/maps/map.xml
@@ -9,7 +9,7 @@
<row>
<tilde>
<height>0</height>
- <terrain>OCEAN</terrain>
+ <terrain>GRASSLAND</terrain>
<object>FOREST_MIXED</object>
<unit></unit>
<building></building>
@@ -23,7 +23,7 @@
</tilde>
<tilde>
<height>1</height>
- <terrain>GRASSLAND</terrain>
+ <terrain>SWAMP</terrain>
<object></object>
<unit></unit>
<building></building>
@@ -36,7 +36,7 @@
<building></building>
</tilde> <tilde>
<height>0</height>
- <terrain>OCEAN</terrain>
+ <terrain>SWAMP</terrain>
<object></object>
<unit></unit>
<building></building>
@@ -57,14 +57,14 @@
</tilde>
<tilde>
<height>1</height>
- <terrain>SWAMP</terrain>
+ <terrain>GRASSLAND</terrain>
<object></object>
<unit></unit>
<building></building>
</tilde>
<tilde>
<height>0</height>
- <terrain>OCEAN</terrain>
+ <terrain>GRASSLAND</terrain>
<object></object>
<unit></unit>
<building></building>
@@ -92,7 +92,7 @@
</tilde>
<tilde>
<height>0</height>
- <terrain>OCEAN</terrain>
+ <terrain>SWAMP</terrain>
<object></object>
<unit></unit>
<building></building>
@@ -151,7 +151,7 @@
<building></building>
</tilde> <tilde>
<height>0</height>
- <terrain>OCEAN</terrain>
+ <terrain>SWAMP</terrain>
<object></object>
<unit></unit>
<building></building>
@@ -179,7 +179,7 @@
</tilde>
<tilde>
<height>0</height>
- <terrain>OCEAN</terrain>
+ <terrain>SWAMP</terrain>
<object></object>
<unit></unit>
<building></building>
@@ -200,7 +200,7 @@
</tilde>
<tilde>
<height>1</height>
- <terrain>SWAMP</terrain>
+ <terrain>OCEAN</terrain>
<object></object>
<unit></unit>
<building></building>
diff --git a/src/graphs.c b/src/graphs.c
new file mode 100644
index 0000000..745785f
--- /dev/null
+++ b/src/graphs.c
@@ -0,0 +1,14 @@
+/*
+ * graphs.c
+ *
+ * Description: Graph functions
+ *
+ * Author: Jesús Manuel Mager Hois (fongog at gmail.com) 2010
+ * Copyright: GPL v3 or later
+ *
+ * Part of "Tux4Kids Project
+ * http://www.tux4kids.com
+ *
+ */
+
+#include "graphs.h"
diff --git a/src/graphs.h b/src/graphs.h
new file mode 100644
index 0000000..3f46c34
--- /dev/null
+++ b/src/graphs.h
@@ -0,0 +1,44 @@
+/*
+ * graphs.h
+ *
+ * Description: Graph functions
+ *
+ * Author: Jesús Manuel Mager Hois (fongog at gmail.com) 2010
+ * Copyright: GPL v3 or later
+ *
+ * Part of "Tux4Kids Project
+ * http://www.tux4kids.com
+ *
+ */
+
+#ifndef GRAPHS_H
+#define GRAPHS_H
+
+#include "map.h"
+
+{
+ ISO_NW,
+ ISO_N,
+ ISO_NE,
+ ISO_W,
+ ISO_E,
+ ISO_SW,
+ ISO_S,
+ ISO_SE
+}
+
+typedef struct gelement{
+ int anchor_x, anchor_y; //Anchors in main map surface.
+ th_obj *object;
+ th_map *terrain;
+}gelement;
+
+
+typedef struct gnode{
+ struct gnode *nodes[8];
+ gelement *data;
+}gnode;
+
+
+
+#define GRAPHS_H
diff --git a/src/hashtable.c b/src/hashtable.c
index 73cb52b..e6de361 100644
--- a/src/hashtable.c
+++ b/src/hashtable.c
@@ -1,3 +1,26 @@
+/*
+Copyright (c) 2007, 2008, 2010 Robbert Haarman
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
#include <stdlib.h>
#include <string.h>
#include "hashtable.h"
diff --git a/src/hashtable.h b/src/hashtable.h
index 1cf616d..aac6b0f 100644
--- a/src/hashtable.h
+++ b/src/hashtable.h
@@ -1,3 +1,26 @@
+/*
+Copyright (c) 2007, 2008, 2010 Robbert Haarman
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
#ifndef HASHTABLE_H
#define HASHTABLE_H
diff --git a/src/map.c b/src/map.c
index fc17aa4..84592da 100644
--- a/src/map.c
+++ b/src/map.c
@@ -38,11 +38,19 @@ static void str_upper(char *);
static int init_map_hash(void)
{
+ th_obj object_types[NUM_OF_TYPES];
+
map_table_hash = make_hashtable(hashtable_default_hash, 30);
if(map_table_hash == NULL)
return 1;
+ object_types[FOREST].type = FOREST;
+ object_types[FOREST].live = 30;
+ object_types[FOREST].defence = 0;
+ object_types[FOREST].attack = 0;
+ object_types[FOREST].move = 0;
+
hashtable_add(map_table_hash, "FOREST_MIXED", FOREST_MIXED);
hashtable_add(map_table_hash, "FOREST_TROPICAL", FOREST_TROPICAL);
hashtable_add(map_table_hash, "FOREST_CONIFER", FOREST_CONIFER);
@@ -55,7 +63,6 @@ static int init_map_hash(void)
hashtable_add(map_table_hash, "HIGHSEA", HIGHSEA);
hashtable_add(map_table_hash, "TUNDRA", TUNDRA);
hashtable_add(map_table_hash, "SWAMP", SWAMP);
- hashtable_add(map_table_hash, "UNEXPLORED", UNEXPLORED);
hashtable_add(map_table_hash, "DESERT", DESERT);
hashtable_add(map_table_hash, "GRASSLAND", GRASSLAND);
hashtable_add(map_table_hash, "ARCTIC", ARCTIC);
@@ -462,8 +469,8 @@ int generate_map(void)
// Prepare the variables...
SDL_FillRect(map_image, NULL, SDL_MapRGB(map_image->format, 0, 0 ,0));
- dest.x = (map_image->w/2)-(terrain[TUNDRA_CENTER_1]->w/2);
- dest.y = map_image->h-terrain[TUNDRA_CENTER_1]->h;
+ dest.x = map_image->w/2-terrain[TUNDRA_CENTER_1]->w/2;
+ dest.y = 0;
//printf("[%d,%d]\n", x_tildes, y_tildes);
@@ -471,11 +478,11 @@ int generate_map(void)
y = dest.y;
k = 0;
- //This loop blits all tildes to map_image.
- for (i = x_tildes; i >= 0; i--)
+ //This loop blits all tiles to map_image.
+ for (i = 0; i <= x_tildes; i++)
{
oe = k + 1;
- for (j = y_tildes; j >= 0; j--)
+ for (j = 0; j <= y_tildes; j++)
{
k++;
@@ -503,16 +510,16 @@ int generate_map(void)
}
printf(".");
- //Prepare te new coords for the next tilde
+ //Prepare te new coords for the next tile
dest.x = dest.x - (terrain[*img_enums]->w/2);
- dest.y = dest.y - (terrain[*img_enums]->h/2);
+ dest.y = dest.y + (terrain[*img_enums]->h/2);
FREE(context_array);
FREE(img_enums);
}
x = x + (terrain[TUNDRA_CENTER_1]->w/2);
- y = y - (terrain[TUNDRA_CENTER_1]->h/2);
+ y = y + (terrain[TUNDRA_CENTER_1]->h/2);
dest.x = x;
dest.y = y;
diff --git a/src/map.h b/src/map.h
index 6878d0e..97affdb 100644
--- a/src/map.h
+++ b/src/map.h
@@ -39,6 +39,8 @@ enum{
NUM_OF_TYPES
};
+
+
/*Global tuxhistory vars*/
typedef struct {
int id;
@@ -48,7 +50,8 @@ typedef struct {
char name[30];
int defence;
int attack;
- int move;
+ int move;
+ int player;
}th_obj;
// th_map is the main data strucutre
// th_map_tilde specifies the terrain
@@ -57,10 +60,10 @@ typedef struct {
typedef struct {
int height; //Height of this tilde
int terrain;
- //th_obj *obj;// Pointer to object
}th_map;
struct hashtable *map_table_hash; //Values of Terrains and objects
+list_node *list_nodes;
int flag_map; // Map flag: is a map surface allocated?
int x_tildes;
int y_tildes;
diff --git a/src/players.c b/src/players.c
new file mode 100644
index 0000000..2c25569
--- /dev/null
+++ b/src/players.c
@@ -0,0 +1 @@
+#include "players.h"
diff --git a/src/players.h b/src/players.h
new file mode 100644
index 0000000..5b1933d
--- /dev/null
+++ b/src/players.h
@@ -0,0 +1,18 @@
+#ifndef PLAYERS_H
+#define PLAYERS_H
+
+#include "graphs.h"
+
+typedef struct players{
+ char name[50];
+ int player_num;
+ int civ;
+ int max_pop;
+ gnode *pos;
+}players;
+
+int num_of_players;
+
+players *player;
+
+#endif
--
tuxhistory - Educational history game
More information about the Tux4kids-commits
mailing list