diff options
-rw-r--r-- | init.c | 5 | ||||
-rw-r--r-- | level.c | 28 | ||||
-rw-r--r-- | render.c | 9 |
3 files changed, 27 insertions, 15 deletions
@@ -5,6 +5,7 @@ #include <zoom/texture.h> #include <zoom/level.h> #include <zoom/light.h> +#include <zoom/player.h> LEVEL *level; GLuint sphere; @@ -13,6 +14,8 @@ GLuint lightmap; extern TEXLIST *texlist; +extern PLAYER player; + int InitGame() { LIGHT light = {LIGHT_POINT, {15.0, 15.0, 15.0}, {0.0, 0.0, 0.0}}; @@ -59,6 +62,8 @@ int InitGame() { level = LoadLevel("level.lvl"); + player.pos = level->info->start; + sphere = glGenLists(1); glNewList(sphere, GL_COMPILE); glRotatef(90, 1.0, 0.0, 0.0); @@ -36,7 +36,7 @@ static void LoadTriangles(xmlNodePtr node, LEVEL *level, WALL* walls, int nWalls VECTOR v; - for(; node = node->next; node != NULL) { + for(; node != NULL; node = node->next) { if(node->type != XML_ELEMENT_NODE || xmlStrcmp(node->name, "triangle")) continue; walls[i].visible = 1; @@ -57,7 +57,7 @@ static void LoadTriangles(xmlNodePtr node, LEVEL *level, WALL* walls, int nWalls } j = -1; - for(node2 = node->children; node2 = node2->next; node2 != NULL) { + for(node2 = node->children; node2 != NULL; node2 = node2->next) { if(node2->type != XML_ELEMENT_NODE) continue; if(!xmlStrcmp(node2->name, "vertex")) { @@ -192,20 +192,20 @@ LEVEL *LoadLevel(char *filename) { if(!root || xmlStrcmp(root->name, "level")) { xmlFreeDoc(doc); xmlCleanupParser(); - return NULL;puts("Loaded."); + return NULL; } level = calloc(1, sizeof(LEVEL)); - for(node = root->children; node = node->next; node != NULL) { + for(node = root->children; node != NULL; node = node->next) { if(node->type != XML_ELEMENT_NODE) continue; if(!xmlStrcmp(node->name, "info")) { level->info = calloc(1, sizeof(LEVELINFO)); - for(node2 = node->children; node2 = node2->next; node2 != NULL) { + for(node2 = node->children; node2 != NULL; node2 = node2->next) { if(node2->type != XML_ELEMENT_NODE) continue; if(!xmlStrcmp(node2->name, "name")) { @@ -242,7 +242,7 @@ LEVEL *LoadLevel(char *filename) { rooms = node; - for(node2 = node->children; node2 = node2->next; node2 != NULL) { + for(node2 = node->children; node2 != NULL; node2 = node2->next) { if(node2->type == XML_ELEMENT_NODE && !xmlStrcmp(node2->name, "room")) level->nRooms++; } } @@ -251,21 +251,23 @@ LEVEL *LoadLevel(char *filename) { gates = node; - for(node2 = node->children; node2 = node2->next; node2 != NULL) { + node2 = node->children; + + for(node2 = node->children; node2 != NULL; node2 = node2->next) { if(node2->type == XML_ELEMENT_NODE && !xmlStrcmp(node2->name, "gate")) level->nGates++; } } else if(!xmlStrcmp(node->name, "textures")) { if(level->textures != NULL) continue; - for(node2 = node->children; node2 = node2->next; node2 != NULL) { + for(node2 = node->children; node2 != NULL; node2 = node2->next) { if(node2->type == XML_ELEMENT_NODE && !xmlStrcmp(node2->name, "texture")) level->nTextures++; } level->textures = calloc(level->nTextures, sizeof(TEXTURE)); i = 0; - for(node2 = node->children; node2 = node2->next; node2 != NULL) { + for(node2 = node->children; node2 != NULL; node2 = node2->next) { if(node2->type != XML_ELEMENT_NODE || xmlStrcmp(node2->name, "texture")) continue; data = xmlGetProp(node2, "name"); @@ -292,7 +294,7 @@ LEVEL *LoadLevel(char *filename) { level->rooms = calloc(level->nRooms, sizeof(ROOM)); i = 0; - for(node = rooms->children; node = node->next; node != NULL) { + for(node = rooms->children; node != NULL; node = node->next) { if(node->type != XML_ELEMENT_NODE || xmlStrcmp(node->name, "room")) continue; data = xmlGetProp(node, "id"); @@ -302,7 +304,7 @@ LEVEL *LoadLevel(char *filename) { xmlFree(data); } - for(node2 = node->children; node2 = node2->next; node2 != NULL) { + for(node2 = node->children; node2 != NULL; node2 = node2->next) { if(node2->type == XML_ELEMENT_NODE && !xmlStrcmp(node2->name, "triangle")) level->rooms[i].nWalls++; } @@ -318,7 +320,7 @@ LEVEL *LoadLevel(char *filename) { level->gates = calloc(level->nGates, sizeof(GATE)); i = 0; - for(node = gates->children; node = node->next; node != NULL) { + for(node = gates->children; node != NULL; node = node->next) { if(node->type != XML_ELEMENT_NODE || xmlStrcmp(node->name, "gate")) continue; data = xmlGetProp(node2, "room1"); @@ -341,7 +343,7 @@ LEVEL *LoadLevel(char *filename) { xmlFree(data); } - for(node2 = node->children; node2 = node2->next; node2 != NULL) { + for(node2 = node->children; node2 != NULL; node2 = node2->next) { if(node2->type == XML_ELEMENT_NODE && !xmlStrcmp(node2->name, "triangle")) level->gates[i].nWalls++; } @@ -96,10 +96,15 @@ void Render() { glBindTexture(GL_TEXTURE_2D, lightmap); glActiveTexture(GL_TEXTURE1); - glEnable(GL_TEXTURE_2D); for(i = 0; i < nLights; i++) { - glBindTexture(GL_TEXTURE_2D, room->polygons[0].texture); + if(room->polygons[0].texture) { + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, room->polygons[0].texture); + } + else + glDisable(GL_TEXTURE_2D); + last_tex = room->polygons[0].texture; glBegin(GL_TRIANGLES); |