From 8deee144293102d4498424c38161d13c877250b2 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Wed, 30 Sep 2015 08:51:10 -0400 Subject: quest stuff --- src/Quest.cpp | 52 +++++++++++++++++++++++++--------------------------- src/entities.cpp | 3 +-- src/main.cpp | 4 +++- 3 files changed, 29 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/Quest.cpp b/src/Quest.cpp index a42e42c..c9175b1 100644 --- a/src/Quest.cpp +++ b/src/Quest.cpp @@ -4,58 +4,56 @@ const Quest QuestList[TOTAL_QUESTS]={ Quest("Test","A test quest",0) }; -Quest::Quest(const char *t,const char *d,unsigned int x){ +Quest::Quest(const char *t,const char *d,unsigned int r){ size_t len; title=(char *)malloc((len=strlen(t))); strncpy(title,t,len); desc=(char *)malloc((len=strlen(d))); strncpy(desc,d,len); - xp=x; + reward=r; } + Quest::~Quest(){ free(title); free(desc); - xp=0; + reward=0; } -QuestHandler::QuestHandler(){ - ccnt=0; -} int QuestHandler::assign(const char *t){ - unsigned int i=0; - if(ccnt==QUEST_LIMIT) - return -1; - for(;ititle,t)){ + return -2; + } + } + for(i=0;ititle,t)){ - for(i++;ititle,t)){ - j=current[i]->xp; - for(i++;ireward; + current.erase(current.begin()+i); + return r; } } return -1; diff --git a/src/entities.cpp b/src/entities.cpp index cff971f..8689b00 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -94,14 +94,13 @@ unsigned int Structures::spawn(_TYPE t, float x, float y){ //spawns a structure width = 20 * HLINE; height = 16 * HLINE; - int tempN = (getRand() % 5 + 1); //amount of villagers that will spawn + int tempN = 2;//(getRand() % 5 + 1); //amount of villagers that will spawn for(int i=0;ispawn(loc.x + (float)(i - 5),100); //sets the position of the villager around the village } - entity.pop_back(); return entity.size(); } } diff --git a/src/main.cpp b/src/main.cpp index 77d22bc..afc34b6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,7 +34,7 @@ void logic(); void render(); int entityInteractTest(NPC *speaker){ - ui::dialogBox("NPC: Hello there!"); + player->qh.assign("Test"); return 1; } @@ -213,6 +213,8 @@ void render(){ glVertex2i(mx,my-HLINE*3.5); glEnd(); + ui::putText(player->loc.x-SCREEN_WIDTH/2,SCREEN_HEIGHT/2,"Quest count: %d",player->qh.current.size()); + glPopMatrix(); //take the matrix(s) off the stack to pass them to the renderer SDL_GL_SwapWindow(window); //give the stack to SDL to render it } -- cgit v1.2.3