From 18377e3c0efe9359c341c0c330f6de1697afb788 Mon Sep 17 00:00:00 2001 From: drumsetmonkey Date: Thu, 16 Jun 2016 08:49:43 -0400 Subject: Changes --- brice.dat | 6 +-- include/entities.hpp | 100 +++++++++++++++++++++---------------- include/world.hpp | 1 + src/items.cpp | 28 +++-------- src/ui.cpp | 2 +- src/world.cpp | 10 ++-- xml/000.xml | 2 +- xml/playerSpawnHill1.xml | 36 ++++++++++--- xml/playerSpawnHill1_Building1.xml | 8 +-- 9 files changed, 108 insertions(+), 85 deletions(-) diff --git a/brice.dat b/brice.dat index 3b090ad..ee48d24 100644 --- a/brice.dat +++ b/brice.dat @@ -1,7 +1,7 @@ 3 -canSprint +Slow 0 canJump 0 -Slow -1 +canSprint +0 diff --git a/include/entities.hpp b/include/entities.hpp index 7e68be3..2523364 100644 --- a/include/entities.hpp +++ b/include/entities.hpp @@ -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. */ diff --git a/include/world.hpp b/include/world.hpp index cea79c1..34a597d 100644 --- a/include/world.hpp +++ b/include/world.hpp @@ -137,6 +137,7 @@ public: * drawing. */ class World { +friend class ItemLight; protected: /** diff --git a/src/items.cpp b/src/items.cpp index eacf5a9..f0b2f84 100644 --- a/src/items.cpp +++ b/src/items.cpp @@ -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; } diff --git a/src/ui.cpp b/src/ui.cpp index 8f234df..392cb13 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -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 ... - 700 + 700 diff --git a/xml/playerSpawnHill1.xml b/xml/playerSpawnHill1.xml index f997b4d..f5d8843 100644 --- a/xml/playerSpawnHill1.xml +++ b/xml/playerSpawnHill1.xml @@ -15,12 +15,36 @@ - -600 + Hello there! My name is Ralph. + 300 - - ... - 1000 - - + + You should go talk to my friend Johnny. He's a pretty chill dude. + + + Niice. + + + Go check out Johnny. He's cool. + + + + + + Sup bro! Have a quest. To complete it, just go talk to Ralph again. + + Dank MayMay,2 + Wood Sword,1 + + + Broooooooooooooo... + + + + + + Hey friend! It's dangerous out there, here take these! + Wait, promise you'll stop by my stand in the local market! + diff --git a/xml/playerSpawnHill1_Building1.xml b/xml/playerSpawnHill1_Building1.xml index d5c07b3..b68bc7b 100644 --- a/xml/playerSpawnHill1_Building1.xml +++ b/xml/playerSpawnHill1_Building1.xml @@ -9,18 +9,18 @@ - Hey. Have a Dank MayMay :) - + Hey. Have a Dank MayMay :) + What? You want another Dank MayMay? K. - + Well... I'm out of Dank MayMays. Have a sword though. - + -- cgit v1.2.3