]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
settings xml'd
authorClyne Sullivan <tullivan99@gmail.com>
Wed, 13 Jan 2016 13:30:23 +0000 (08:30 -0500)
committerClyne Sullivan <tullivan99@gmail.com>
Wed, 13 Jan 2016 13:30:23 +0000 (08:30 -0500)
Changelog
config/settings.xml [new file with mode: 0644]
include/common.h
main.cpp
src/gameplay.cpp
xml/playerSpawnHill1.xml

index 30c1a50947e2b05bd3b6da505417e57d8692b096..cad80bad4fe413e9444575b296241476559e16ff 100644 (file)
--- a/Changelog
+++ b/Changelog
        - WIP xml'd world linking
        - textures?
        - music?
+
+1/12/2015:
+==========
+
+       - world linking xml'd
+       - xml'ing indoors
+       - shaderssss
+       - more music
+       
+1/13/2015:
+==========
+
+       - discovered how intel and nvidia gpus handle lighting
+       - xml'd buildings and their indoors
+       - xml'd settings for screen dimensions
+       - xml'd item giving through npc dialog
diff --git a/config/settings.xml b/config/settings.xml
new file mode 100644 (file)
index 0000000..82363a8
--- /dev/null
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+
+<screen width="1024" height="720" />
+<hline value="3" />
index be3201973a40da44541b72e53a416c1be49c13d5..bfd01268b335606414f1e2a47be8bcd2bb2f9999 100644 (file)
@@ -78,13 +78,15 @@ typedef struct{
  * The desired width of the game window.
  */
 
-#define SCREEN_WIDTH   1280
+//#define SCREEN_WIDTH 1280
+extern unsigned int SCREEN_WIDTH;
 
 /**
  * The desired height of the game window.
  */
 
-#define SCREEN_HEIGHT  720
+//#define SCREEN_HEIGHT        720
+extern unsigned int SCREEN_HEIGHT;
 
 //#define FULLSCREEN
 
@@ -98,7 +100,7 @@ typedef struct{
  * 
  */
 
-#define HLINE 3
+#define HLINE 1
 
 /**
  * A 'wrapper' for libc's srand(), as we hope to eventually have our own random number
index dba36052ffa12cba4a6ab2f7ba2763042df36690..06df250c62ad840495fe005399267c52674c9c32 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -11,6 +11,9 @@
 #include <world.h>
 #include <ui.h>
 #include <entities.h>
+#include <tinyxml2.h>
+
+using namespace tinyxml2;
 
 /*
  *     TICKS_PER_SEC & MSEC_PER_TICK
@@ -196,12 +199,21 @@ extern bool fadeWhite;
 extern bool fadeFast;
 extern int  fadeIntensity;
 
+unsigned int SCREEN_WIDTH;
+unsigned int SCREEN_HEIGHT;
+
 /*******************************************************************************
  * MAIN ************************************************************************
  *******************************************************************************/
 int main(/*int argc, char *argv[]*/){
        //*argv = (char *)argc;
+       
        gameRunning=false;
+       
+       XMLDocument xml;
+       xml.LoadFile("config/settings.xml");
+       SCREEN_WIDTH = xml.FirstChildElement("screen")->UnsignedAttribute("width");
+       SCREEN_HEIGHT = xml.FirstChildElement("screen")->UnsignedAttribute("height");
 
        /*!
         *      (Attempt to) Initialize SDL libraries so that we can use SDL facilities and eventually
@@ -529,7 +541,7 @@ void render(){
         *  see past the world render
        */
        
-       if(currentWorld->getTheWidth() < SCREEN_WIDTH){
+       if(currentWorld->getTheWidth() < (int)SCREEN_WIDTH){
                offset.x = 0;
        }else if(!worldInside){
                if(player->loc.x - SCREEN_WIDTH/2 < currentWorld->getTheWidth() * -0.5f)
index c4249a44f5e9604932aa6d45407f8047cc7e2a5c..6626811585f25eb6098233766217f8a0c540352c 100644 (file)
@@ -75,6 +75,13 @@ int commonAIFunc(NPC *speaker){
                                if(!strcmp(exml->Name(),"text")){
                                        if(exml->UnsignedAttribute("id") == idx){
                                                
+                                               if((oxml = exml->FirstChildElement("give"))){
+                                                       while(oxml){
+                                                               player->inv->addItem((ITEM_ID)oxml->UnsignedAttribute("id"),oxml->UnsignedAttribute("count"));
+                                                               oxml = oxml->NextSiblingElement();
+                                                       }
+                                               }
+                                               
                                                if((oxml = exml->FirstChildElement("option"))){
                                                        const char *op;
                                                        char *bp1 = new char[1],*bp2,*tmp;
@@ -281,12 +288,6 @@ SKIP:
                                                        }
                                                }       
                                        }
-                                       /*for(auto &l : earthlnk){
-                                               if(!strcmp(file+4,l.name)){
-                                                       yoyo2 = &l.ptr;
-                                                       break;
-                                               }
-                                       }*/
                                        if(wxml->QueryFloatAttribute("x",&spawnx) != XML_NO_ERROR)
                                                earth.back()->addStructure((BUILD_SUB)wxml->UnsignedAttribute("type"),getRand() % earth.back()->getTheWidth() / 2.0f,100,yoyo);//,yoyo2);
                                        else
index 12d55fc6b14c56ce00c0212a87c94f94b28a8f4c..e96d6a530442ef001f1e91933520522b709272cb 100644 (file)
@@ -3,7 +3,7 @@
        <style background="0" bgm="assets/music/embark.wav" />
        <generation type="Random" width="800" />
        
-       <!--<link right="playerSpawnHill2.xml" />-->
+       <link right="playerSpawnHill2.xml" />
        
        <mob type="1" />
        
@@ -38,5 +38,7 @@
        
        <text id="1" >
                My name's Johnny.
+               
+               <give id="0" count="1" />
        </text>
 </Dialog>