From: drumsetmonkey Date: Thu, 7 Jan 2016 13:33:54 +0000 (-0500) Subject: Hey, that's pretty good lighting! X-Git-Url: https://code.bitgloo.com/?a=commitdiff_plain;h=e043a2432c4dacce56a308948188482fb230ff33;p=clyne%2Fgamedev.git Hey, that's pretty good lighting! --- e043a2432c4dacce56a308948188482fb230ff33 diff --cc include/common.h index 207b95f,038bf42..0c4d700 --- a/include/common.h +++ b/include/common.h @@@ -148,8 -141,23 +148,25 @@@ extern vec2 offset */ extern unsigned int loops; +extern GLuint shaderProgram; + + /** + * This class contains a string for identification and a value. It can be used to + * save certain events for and decisions so that they can be recalled later. + */ + + class Condition { + private: + char *id; + void *value; + public: + Condition(const char *_id,void *val); + ~Condition(); + + bool sameID(const char *s); + void *getValue(void); + }; + /** * Prints a formatted debug message to the console, along with the callee's file and line * number. diff --cc include/entities.h index a4bc282,894dc16..90af0f2 --- a/include/entities.h +++ b/include/entities.h @@@ -139,9 -164,12 +165,12 @@@ public virtual void interact(){} virtual ~Entity(){} + + char *baseSave(void); + void baseLoad(char *); }; -class Player : public Entity { +class Player : public Entity{ public: QuestHandler qh; bool light = false; diff --cc include/world.h index e10d0dc,cdcea3c..5021fbb --- a/include/world.h +++ b/include/world.h @@@ -170,16 -169,20 +174,22 @@@ public std::vector entity; std::vector object; std::vector particles; + std::vector light; void addStructure(_TYPE t,BUILD_SUB sub,float x,float y,World *inside); - void addVillage(int bCount, int npcMin, int npcMax,_TYPE t,float x,float y,World *outside); + void addVillage(int bCount, int npcMin, int npcMax,_TYPE t,World *inside); void addMob(int t,float x,float y); void addMob(int t,float x,float y,void (*hey)(Mob *)); void addNPC(float x,float y); void addObject(ITEM_ID, bool, const char *, float, float); void addParticle(float, float, float, float, float, float, Color color, int); + void addLight(vec2, Color); + + NPC *getAvailableNPC(void); + + /* + * Update coordinates of all entities. + */ void update(Player *p,unsigned int delta); diff --cc main.cpp index c174f11,2c088cb..1725ccf --- a/main.cpp +++ b/main.cpp @@@ -201,7 -202,8 +202,7 @@@ extern int fadeIntensity int main(/*int argc, char *argv[]*/){ //*argv = (char *)argc; gameRunning=false; - - ++ /*! * (Attempt to) Initialize SDL libraries so that we can use SDL facilities and eventually * make openGL calls. Exit if there was an error. diff --cc src/entities.cpp index d12a1ca,f34abd6..7e8d55a --- a/src/entities.cpp +++ b/src/entities.cpp @@@ -158,11 -150,17 +151,17 @@@ Mob::Mob(int sub) width = HLINE * 20; height = 2000; tex = new Texturec(0); + break; case MS_DOOR: width = HLINE * 12; - height = HLINE * 19; + height = HLINE * 20; tex = new Texturec(1,"assets/door.png"); break; + case MS_PAGE: + width = HLINE * 6; + height = HLINE * 4; + tex = new Texturec(1,"assets/items/ITEM_PAGE.png"); + break; } inv = new Inventory(NPC_INV_SIZE); @@@ -256,8 -247,8 +255,9 @@@ void Entity::draw(void){ //draws the e break; case MS_BIRD: case MS_DOOR: + case MS_PAGE: default: + glActiveTexture(GL_TEXTURE0 + 0); tex->bind(0); break; } diff --cc src/gameplay.cpp index 1c83bd8,94fb954..431d2cf --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@@ -102,11 -122,17 +122,17 @@@ static World *worldFirstVillage void destroyEverything(void); void initEverything(void){ - + static std::ifstream i ("world.dat",std::ifstream::in | std::ifstream::binary); + worldSpawnHill1 = new World(); - worldSpawnHill1->generateFunc(400,gen_worldSpawnHill1); worldSpawnHill1->setBackground(BG_FOREST); - worldSpawnHill1->setBGM("assets/music/embark.wav"); - if(!i.fail()){ - worldSpawnHill1->load(&i); - i.close(); - }else{ ++ // if(!i.fail()){ ++ // worldSpawnHill1->load(&i); ++ // i.close(); ++ // }else{ + worldSpawnHill1->generateFunc(400,gen_worldSpawnHill1); + worldSpawnHill1->setBGM("assets/music/embark.wav"); - } ++ // } worldSpawnHill1->addMob(MS_TRIGGER,0,0,worldSpawnHill1_hillBlock); worldSpawnHill2 = new World(); @@@ -149,9 -177,10 +177,12 @@@ worldSpawnHill2_Building1->setBGM("assets/music/theme_jazz.wav"); worldSpawnHill2->addStructure(STRUCTURET,HOUSE,(rand()%120*HLINE),100,worldSpawnHill2_Building1); + worldSpawnHill2->addLight({300,100},{1.0f,1.0f,1.0f}); + worldSpawnHill2->getAvailableNPC()->addAIFunc(worldSpawnHill2_Quest1,false); + + worldFirstVillage->addVillage(5,0,0,STRUCTURET,worldSpawnHill2_Building1); + //worldSpawnHill2->addStructure(STRUCTURET,HOUSE,(rand()%120*HLINE),100,worldSpawnHill1,worldSpawnHill2); player = new Player(); player->spawn(200,100); diff --cc src/ui.cpp index b9a44aa,b827b43..7979138 --- a/src/ui.cpp +++ b/src/ui.cpp @@@ -803,6 -813,6 +813,9 @@@ DONE break; case SDLK_RIGHT: player->inv->sel++; ++ break; ++ case SDLK_f: ++ break; default: break;