summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2010-11-18 22:33:16 +0000
committerLudovic Pouzenc <ludovic@pouzenc.fr>2010-11-18 22:33:16 +0000
commit5f736ad433a58a09417dcf941d1e54fe5677214d (patch)
tree766e29078d72e2fcf228c65b6a4cf53f7e9fb6e5 /src
parent1742d99de4ca6624570f2a06bbcf5797acd46772 (diff)
download2010-netlemmings-5f736ad433a58a09417dcf941d1e54fe5677214d.tar.gz
2010-netlemmings-5f736ad433a58a09417dcf941d1e54fe5677214d.tar.bz2
2010-netlemmings-5f736ad433a58a09417dcf941d1e54fe5677214d.zip
Début pour le chargement des fichiers
git-svn-id: file:///var/svn/2010-netlemmings/trunk@161 077b3477-7977-48bd-8428-443f22f7bfda
Diffstat (limited to 'src')
-rw-r--r--src/loader.c30
-rw-r--r--src/loader.h7
-rw-r--r--src/parser/ginit.h1
-rw-r--r--src/parser/parse_ini.yy2
-rw-r--r--src/test/Makefile6
5 files changed, 43 insertions, 3 deletions
diff --git a/src/loader.c b/src/loader.c
new file mode 100644
index 0000000..6e38809
--- /dev/null
+++ b/src/loader.c
@@ -0,0 +1,30 @@
+#include <stdio.h>
+#include "loader.h"
+
+#define PATH_STYLE "../styles/"
+
+int loadRessources(struct gameInit *gInit) {
+ int i;
+ char *filepath, *kind;
+
+ filepath = malloc(sizeof(char)*(strlen(PATH_STYLE)+strlen(gInit->style.name)+strlen("/om_00.gif")+1));
+
+ gInit->ress.style.tiles=malloc(sizeof(SDL_Surface *)*gInit->style.tiles);
+ //(if null...)
+ for(i=0; i < gInit->style.tiles ; ++i) {
+ sprintf(filepath, "%s/%s_%d.gif", PATH_STYLE, gInit->style.name, i);
+ gInit->ress.style.tiles[i] = load_image(filepath,ccc_keyGif);
+ }
+
+ gInit->ress.style.objects=malloc(sizeof(SDL_Surface *)*gInit->style.objectCount);
+ //(if null...)
+ gInit->ress.style.objectMasks=malloc(sizeof(SDL_Surface *)*gInit->style.objectCount);
+ //(if null...)
+ for(i=0; i < gInit->style.objectCount ; ++i) {
+ sprintf(filepath, "%s/%so_%d.gif", PATH_STYLE, gInit->style.name, i);
+ gInit->ress.style.objects[i] = load_image(filepath,ccc_keyGif);
+ sprintf(filepath, "%s/%som_%d.gif", PATH_STYLE, gInit->style.name, i);
+ gInit->ress.style.objectMasks[i] = load_image(filepath,ccc_keyGif);
+ }
+
+}
diff --git a/src/loader.h b/src/loader.h
new file mode 100644
index 0000000..7da7ff6
--- /dev/null
+++ b/src/loader.h
@@ -0,0 +1,7 @@
+#ifndef LOADER_H
+#define LOADER_H
+
+#include "parser/ginit.h"
+int loadRessources(struct gameInit *gInit);
+
+#endif /*LOADER_H*/
diff --git a/src/parser/ginit.h b/src/parser/ginit.h
index 5d1ac15..77a6989 100644
--- a/src/parser/ginit.h
+++ b/src/parser/ginit.h
@@ -11,6 +11,7 @@ struct styleObjects {
};
struct style {
+ char *name;
uint32_t bgColor, debrisColor;
int tiles, particleColorCount, objectCount;
uint32_t *particleColor;
diff --git a/src/parser/parse_ini.yy b/src/parser/parse_ini.yy
index 2326572..ad32d4f 100644
--- a/src/parser/parse_ini.yy
+++ b/src/parser/parse_ini.yy
@@ -87,7 +87,7 @@ decl: BGCOLOR AFF INTHEX { gInit->style.bgColor = $3; }
gInit->style.particleColor = $3;
}
| TILES AFF INT {
- yyassert($3>0,"tiles", CANNOT_BE_NEGATIVE);
+ yyassert($3>0 && $3<100,"tiles", OUT_OF_BOUNDS);
gInit->style.tiles = $3;
//TODO check coherence par rapport aux fichiers trouvés
}
diff --git a/src/test/Makefile b/src/test/Makefile
index 1918e8d..88c7432 100644
--- a/src/test/Makefile
+++ b/src/test/Makefile
@@ -1,4 +1,4 @@
-all: test_lex test_parse
+all: test_lex test_parse test_load
test_lex: test_lex.c ../parser/lex.yy.c
gcc -Wall --std=c99 -D_POSIX_SOURCE -g -o $@ $^
@@ -6,6 +6,8 @@ test_lex: test_lex.c ../parser/lex.yy.c
test_parse: test_parse.c ../parser/y.tab.c ../parser/lex.yy.c
gcc -Wall --std=c99 -D_POSIX_SOURCE -g -o $@ $^
+test_load: test_load.c ../parser/y.tab.c ../parser/lex.yy.c
+ gcc -Wall --std=c99 -D_POSIX_SOURCE -g -o $@ $^
clean:
- -rm test_lex test_parse
+ -rm test_lex test_parse test_load