]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
Changes
authordrumsetmonkey <abelleisle@roadrunner.com>
Thu, 16 Jun 2016 12:49:43 +0000 (08:49 -0400)
committerdrumsetmonkey <abelleisle@roadrunner.com>
Thu, 16 Jun 2016 12:49:43 +0000 (08:49 -0400)
brice.dat
include/entities.hpp
include/world.hpp
src/items.cpp
src/ui.cpp
src/world.cpp
xml/000.xml
xml/playerSpawnHill1.xml
xml/playerSpawnHill1_Building1.xml

index 3b090ad887b4d2aa51cf2d99adc0eeaf055a2798..ee48d24d65e33bbcde48fb7aa0a01dd6e0ce641b 100644 (file)
--- a/brice.dat
+++ b/brice.dat
@@ -1,7 +1,7 @@
 3
-canSprint
+Slow
 0
 canJump
 0
-Slow
-1
+canSprint
+0
index 7e68be32df9bc5b57d37db2ed06f83265404fa8d..2523364689012a9ff92ff28f268c09b27b5e4c4c 100644 (file)
@@ -108,6 +108,60 @@ extern const unsigned int NPC_INV_SIZE;
 // a prototype of the world class, necessary for some function prototypes
 class World;
 
+/**
+ * The light structure, used to store light coordinates and color.
+ */
+
+class Light{
+public:
+       vec2 loc;               /**< Light location */
+       Color color;    /**< Light color */
+       float radius;   /**< Light radius */
+
+       bool belongsTo;
+       Entity *following;
+
+       bool flame;
+       float fireFlicker;
+       vec2 fireLoc;
+       Light()
+       {
+               loc = vec2(0,0);
+               color = Color(1.0, 1.0, 1.0);
+               radius = 0;
+
+               belongsTo = false;
+               following = nullptr;
+
+               flame = false;  
+       }
+
+       Light(vec2 l, float r, Color c)
+       {
+               loc = l;
+               color = c;
+               radius = r;
+
+               belongsTo = false;
+               following = nullptr;
+
+               flame = false;
+       }
+
+       void follow(Entity *f)
+       {
+               following = f;
+               belongsTo = true;
+       }
+
+       void makeFlame(void)
+       {
+               flame = true;
+       }
+       
+       void createFromXML(XMLElement *e);
+};
+
 /**
  * The entity class.
  * This class contains common functions and variables for all types of
@@ -174,6 +228,9 @@ public:
        // the entity's inventory
        Inventory *inv;
 
+       // the entity's light
+       Light light;
+
        // the entity's health
        float health;
 
@@ -348,49 +405,6 @@ public:
        void saveToXML(void);
 };
 
-/**
- * The light structure, used to store light coordinates and color.
- */
-
-class Light{
-public:
-       vec2 loc;               /**< Light location */
-       Color color;    /**< Light color */
-       float radius;   /**< Light radius */
-
-       bool belongsTo;
-       Entity *following;
-
-       bool flame;
-       float fireFlicker;
-       vec2 fireLoc;
-
-       Light(vec2 l, float r, Color c)
-       {
-               loc = l;
-               color = c;
-               radius = r;
-
-               belongsTo = false;
-               following = nullptr;
-
-               flame = false;
-       }
-
-       void follow(Entity *f)
-       {
-               following = f;
-               belongsTo = true;
-       }
-
-       void makeFlame(void)
-       {
-               flame = true;
-       }
-       
-       void createFromXML(XMLElement *e);
-};
-
 /**
  * The particle class, handles a single particle.
  */
index cea79c10491ce37146a5532cc21f02ecee079168..34a597d303f4d897520695166ab363e6ada5f857 100644 (file)
@@ -137,6 +137,7 @@ public:
  * drawing.
  */
 class World {
+friend class ItemLight;
 protected:
 
        /**
index eacf5a9ec45c9a74deb6f6d7f5e2b7d90f36b448..f0b2f84fad435660512e016155a6bcda13946eba 100644 (file)
@@ -74,28 +74,9 @@ int Sword::useItem()
                                                                else
                                                                        e->takeHit(damage, 600);
 
-                                                               static GLuint sColor = Texture::genColor(Color(255,0,0));
-                                                               GLfloat t[] = {0.0, 0.0,
-                                                                                          1.0, 1.0};
-                                                               GLfloat v[] = {hitbox.start.x,  hitbox.start.y, 1.0,
-                                                                                          hitbox.end.x,        hitbox.end.y,   1.0};
-
-                                       
-                                                               glBindTexture(GL_TEXTURE_2D, sColor);
-                                                               glUseProgram(worldShader);
-                                                               glEnableVertexAttribArray(worldShader_attribute_coord);
-                                                               glEnableVertexAttribArray(worldShader_attribute_tex);
-                                               
-                                                               glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, v);
-                                                               glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, t);
-                                                               glDrawArrays(GL_LINES, 0, 2);
-
-                                                               glDisableVertexAttribArray(worldShader_attribute_coord);
-                                                               glDisableVertexAttribArray(worldShader_attribute_tex);
-                                                               glUseProgram(0);
                                                                // add some blood
-                                                               // for(int r = 0; r < (rand()%5);r++)
-                                                               //      currentWorld->addParticle(rand()%game::HLINE*3 + e->loc.x - .05f,e->loc.y + e->height*.5, game::HLINE,game::HLINE, -(rand()%10)*.01,((rand()%4)*.001-.002), {(rand()%75+10)/100.0f,0,0}, 10000);
+                                                               //for(int r = 0; r < (rand()%5);r++)
+                                                                       //currentWorld->addParticle(rand()%game::HLINE*3 + e->loc.x - .05f,e->loc.y + e->height*.5, game::HLINE,game::HLINE, -(rand()%10)*.01,((rand()%4)*.001-.002), {(rand()%75+10)/100.0f,0,0}, 10000);
                                                        }
                                                }
 
@@ -160,7 +141,10 @@ int Food::useItem()
 
 int ItemLight::useItem()
 {
-       std::cout << "fsdfsdf" << std::endl;
+       if (player->light.radius > 0)
+               player->light.radius = 0;
+       else
+               player->light.radius = 500;
        return 0;
 }
 
index 8f234dfff18e2fd7f3737cc1832c29247f5ae1ff..392cb13f6492dbf64c7e3fbc8fbb0edb3f8a8400 100644 (file)
@@ -1093,7 +1093,7 @@ namespace ui {
                                drawNiceBox(vec2 {x, y}, vec2 {x + SCREEN_WIDTH - HLINES(16), y - SCREEN_HEIGHT / 4}, -7.0);
 
                                rtext = typeOut(dialogBoxText);
-                               putString(x + game::HLINE, y - fontSize - game::HLINE, rtext);
+                               putString(x + (2*game::HLINE), y - fontSize - game::HLINE, rtext);
 
                                for(i=0;i<dialogOptText.size();i++) {
                                        setFontColor(255,255,255);
index 450d9567853c3a1908d124c44af05c110aa692d9..8c6a5482b857dbf2afde2e61b916c08ba4ae3f54 100644 (file)
@@ -524,12 +524,12 @@ void World::draw(Player *p)
 
        uint ls = light.size();
        
-       GLfloat *lightCoords = new GLfloat[light.size() * 4];
-       GLfloat *lightColors = new GLfloat[light.size() * 4];
-       
+       GLfloat *lightCoords = new GLfloat[ls * 4];
+       GLfloat *lightColors = new GLfloat[ls * 4];
+
        uint lpIndex = 0;
        uint lcIndex = 0;
-               
+
        for (uint i = 0; i < ls; i++) {
                auto &l = light[i];
                if (l.belongsTo) {
@@ -1482,7 +1482,7 @@ addParticle(float x, float y, float w, float h, float vx, float vy, Color color,
 void World::
 addLight(vec2 loc, float radius, Color color)
 {
-       if (light.size() < 64)
+       if (light.size() < 128)
         light.emplace_back(loc, radius, color);
 }
 
index 18063327fbbb66494d30c513789c82ee447fd411..dc5d4e9e5fd2eb775caca8e4038ac8cbea4af8a7 100644 (file)
@@ -19,7 +19,7 @@
     </text>
     <text id="1">
         ...
-                                                                                                                                                                                                                                                                        <gotox>700</gotox>
+                                                                                                                                                                                                                                                                                                        <gotox>700</gotox>
         <set id="Slow" value="0"/>
     </text>
 </Dialog>
index f997b4dda150d7506ec24948799b2ec6c2470c1d..f5d8843fc1255546493f97a2c3b993e6eb504105 100644 (file)
 
 <Dialog name="Guy">
     <text id="0" nextid="1">
-        <gotox>-600</gotox>
+               Hello there! My name is Ralph.
+                                                                                                                                                                                                                                                                                                                                               <gotox>300</gotox>
     </text>
-    <text id="1">
-               ...
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       <gotox>1000</gotox>
-        <set id="Slow" value="0"/>
-        <set id="canSprint" value="1"/>
+    <text id="1" nextid="2" call="Johnny" callid="0" pause="true">
+               You should go talk to my friend Johnny. He's a pretty chill dude.
+       </text>
+    <text id="2">
+               Niice.
+                                                                                                                                                                                                                                                                                                                                               <quest check="Your First Quest" fail="3"/></text>
+    <text id="3">
+               Go check out Johnny. He's cool.
+       </text>
+</Dialog>
+
+<Dialog name="Johnny">
+    <text id="0" nextid="1" pause="true">
+               Sup bro! Have a quest. To complete it, just go talk to Ralph again.
+                                                                                                                                                                                                                                                                                                                                               <quest assign="Your First Quest">
+                       Dank MayMay,2
+                       Wood Sword,1
+               </quest>
     </text>
+    <text id="1" nextid="1" pause="true">
+               Broooooooooooooo...
+       </text>
+</Dialog>
+
+<Dialog name="Big Dave">
+    <text id="0" stop="true">
+               Hey friend! It's dangerous out there, here take these!
+               Wait, promise you'll stop by my stand in the local market!
+                                                                                                                                                                                                                                                                                                                                               <give id="Wood Sword" count="1"/>        <give id="Hunters Bow" count="1"/>        <give id="Crude Arrow" count="110"/>        <give id="Fried Chicken" count="1"/>        <give id="Mossy Torch" count="1"/></text>
 </Dialog>
index d5c07b33f0bff7d6b419f39685fcc23fd19429a6..b68bc7b63be14c109847b36b197dfd53f01007e5 100644 (file)
@@ -9,18 +9,18 @@
 
 <Dialog name="Bob">
     <text id="0" nextid="1" pause="true">
-       Hey. Have a Dank MayMay :)
-               <give id="Dank MayMay" count="1"/></text>
+               Hey. Have a Dank MayMay :)
+                                               <give id="Dank MayMay" count="1"/></text>
     <text id="1" nextid="2">
        What? You want another Dank MayMay?
     </text>
     <text id="2" nextid="3" pause="true">
                K.
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           <give id="Dank MayMay" count="1"/></text>
+                                               <give id="Dank MayMay" count="1"/></text>
     <text id="3" nextid="4">
                Well... I'm out of Dank MayMays.
        </text>
     <text id="4">
                Have a sword though.
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       <give id="Wood Sword" count="1"/></text>
+                                               <give id="Wood Sword" count="1"/></text>
 </Dialog>