From: drumsetmonkey Date: Wed, 8 Jun 2016 12:45:29 +0000 (-0400) Subject: Lighting! X-Git-Url: https://code.bitgloo.com/?a=commitdiff_plain;h=a978ddfb98734514874231ed28d0395533afa25d;p=clyne%2Fgamedev.git Lighting! --- a978ddfb98734514874231ed28d0395533afa25d diff --cc assets/blankNormal.png index 0000000,0000000..cff3ee7 new file mode 100644 Binary files differ diff --cc assets/cat_normal.png index 0000000,0000000..59aaee8 new file mode 100644 Binary files differ diff --cc assets/cat_normal_old.png index 0000000,0000000..c3ed4aa new file mode 100644 Binary files differ diff --cc assets/items/basic_torch.png index 0000000,0000000..fe6a994 new file mode 100644 Binary files differ diff --cc assets/style/classic/bg/bgnew.png index 0000000,0000000..05c352b new file mode 100644 Binary files differ diff --cc assets/style/classic/bg/star.png index 0000000,0000000..6360d30 new file mode 100644 Binary files differ diff --cc include/entities.hpp index d2185c4,e406397..7c712c9 --- a/include/entities.hpp +++ b/include/entities.hpp @@@ -412,16 -368,73 +369,80 @@@ public flame = false; } - void makeFlame(void){ + void follow(Entity *f) + { + following = f; + belongsTo = true; + } + + void makeFlame(void) + { flame = true; } + + void createFromXML(XMLElement *e); + }; + + /** + * The particle class, handles a single particle. + */ + class Particles{ + public: + // the location of the particle + vec2 loc; + float zOffset; + + // the width of the particle, in pixels + float width; + + // the height of the particle, in pixels + float height; + + // the velocity of the particle, in pixels + vec2 vel; + + // the color of the particle + Color color; + + // TODO + vec2 index; + + // the amount of milliseconds left for the particle to live + float duration; + + // when true, the particle will move + bool canMove; + + // TODO + bool fountain; + + // when true, the particle will be affected by gravity + bool gravity; + + // when true, draws the particle behind structures + bool behind; + + // when true, the particle will bounce on impact with ground + bool bounce; + + Structures *stu; + + Particles(void){} + + // creates a particle with the desired characteristics + Particles(float x, float y, float w, float h, float vx, float vy, Color c, float d); + + // allows the particle to be destroyed + ~Particles(void){} + + // draws the particle + void draw(GLfloat*& p) const; + + // updates a particle + void update(float _gravity, float ground_y); + + // returns true if the particle should be killed + bool timeUp(void); }; #include diff --cc src/mob.cpp index a0e7087,526d7b1..1bc1499 --- a/src/mob.cpp +++ b/src/mob.cpp @@@ -143,13 -146,14 +146,14 @@@ void Cat::onHit(unsigned int _health bool Cat::bindTex(void) { - glActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE0); tex(0); - return true; + return true; } - void Cat::createFromXML(const XMLElement *e) + void Cat::createFromXML(XMLElement *e, World *w=nullptr) { + (void)w; float Xlocx; if (e->QueryFloatAttribute("x", &Xlocx) == XML_NO_ERROR) loc.x = Xlocx; diff --cc src/ui.cpp index 1f6e593,ae47234..f32bc79 --- a/src/ui.cpp +++ b/src/ui.cpp @@@ -1408,8 -1408,10 +1408,10 @@@ EXIT if (debug) posFlag ^= true; else { - currentWorld->addStructure(FIRE_PIT, player->loc.x, player->loc.y, "", ""); + auto s = new Structures(); + s->spawn(FIRE_PIT, player->loc.x, player->loc.y); + currentWorld->addStructure(s); - currentWorld->addLight({player->loc.x + SCREEN_WIDTH/2, player->loc.y},{1.0f,1.0f,1.0f}); + currentWorld->addLight({player->loc.x + SCREEN_WIDTH/2, player->loc.y}, 400.0f, {1.0f,1.0f,1.0f}); //currentWorld->getLastLight()->follow(currentWorld->build.back()); currentWorld->getLastLight()->makeFlame(); }