From cf8ed3fe2dfb2e5f569e1dbb3fd19c2673bd4b53 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Tue, 13 Oct 2015 08:47:09 -0400 Subject: quest debug --- include/Quest.h | 2 ++ include/entities.h | 4 ++-- main.cpp | 6 +++--- src/Quest.cpp | 27 +++++++++++++++++++++++---- src/common.cpp | 4 ++-- src/gameplay.cpp | 14 ++++---------- 6 files changed, 36 insertions(+), 21 deletions(-) diff --git a/include/Quest.h b/include/Quest.h index 11d04a6..bbcf7ee 100644 --- a/include/Quest.h +++ b/include/Quest.h @@ -7,6 +7,8 @@ #include +#define DEBUG + #define TOTAL_QUESTS 1 class Quest { diff --git a/include/entities.h b/include/entities.h index ecfe539..537ed49 100644 --- a/include/entities.h +++ b/include/entities.h @@ -51,7 +51,7 @@ public: private: }; -class Player : public Entity{ +class Player : public Entity { public: QuestHandler qh; Player(); @@ -95,4 +95,4 @@ ENTITY TYPES | 2 MOBS |->1 Skirl -**/ \ No newline at end of file +**/ diff --git a/main.cpp b/main.cpp index 386d419..6e10420 100644 --- a/main.cpp +++ b/main.cpp @@ -134,9 +134,9 @@ static float debugY=0; void mainLoop(void){ static unsigned int debugDiv=0; - unsigned int i, - prevTime = 0, - currentTime = 0; + unsigned int i; + static unsigned int prevTime = 0, + currentTime = 0; if(!currentTime)currentTime=millis(); prevTime = currentTime; diff --git a/src/Quest.cpp b/src/Quest.cpp index c331e32..5d19795 100644 --- a/src/Quest.cpp +++ b/src/Quest.cpp @@ -1,5 +1,6 @@ -#include -#include +#include +//#include +//#include const Quest QuestList[TOTAL_QUESTS]={ Quest("Test","A test quest",(struct item_t){1,TEST_ITEM}) @@ -22,17 +23,26 @@ Quest::~Quest(){ int QuestHandler::assign(const char *t){ unsigned char i; - for(i=0;ititle,t)){ +#ifdef DEBUG + DEBUG_printf("The QuestHandler already has this quest: %s\n",t); +#endif // DEBUG return -2; } } - for(i=0;ititle,t)){ +#ifdef DEBUG + DEBUG_printf("Completing quest %s.\n",t); +#endif // DEBUG ((Entity *)completer)->inv->addItem(current[i]->reward.id,current[i]->reward.count); current.erase(current.begin()+i); +#ifdef DEBUG + DEBUG_printf("QuestHandler now has %u active quests.\n",current.size()); +#endif // DEBUG return 0; } } +#ifdef DEBUG + DEBUG_printf("QuestHandler never had quest %s.\n",t); +#endif // DEBUG return -1; } diff --git a/src/common.cpp b/src/common.cpp index 80488eb..8dcbd11 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -4,9 +4,9 @@ GLuint loadTexture(const char *fileName){ SDL_Surface *image = IMG_Load(fileName); if(!image)return 0; - #ifdef DEBUG +#ifdef DEBUG DEBUG_printf("Loaded image file: %s\n", fileName); - #endif // DEBUG +#endif // DEBUG unsigned object = 0; //creates a new unsigned variable for the texture glGenTextures(1, &object); //turns "object" into a texture diff --git a/src/gameplay.cpp b/src/gameplay.cpp index 5ffe5a6..17a7bed 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -20,15 +20,8 @@ int compTestQuest(NPC *speaker){ } int giveTestQuest(NPC *speaker){ - static bool done=false; - if(!done){ - ui::dialogBox(speaker->name,"Here, have a quest!"); - player->qh.assign("Test"); - done=true; - } - /*while(ui::dialogBoxExists){ - mainLoop(); - }*/ + ui::dialogBox(speaker->name,"Here, have a quest!"); + player->qh.assign("Test"); NPCp(entity[2])->addAIFunc(compTestQuest); return 0; } @@ -70,9 +63,10 @@ void initEverything(void){ entity[entity.size()-1]->spawn(200,100); //sets the position of the villager around the village entity.pop_back(); + + NPCp(entity[1])->addAIFunc(giveStuff); NPCp(entity[1])->addAIFunc(giveTestQuest); for(i=0;iinWorld=test; - if(entity[i]->type==NPCT&&i>1)NPCp(entity[i])->addAIFunc(giveStuff); } } -- cgit v1.2.3 From 58716d5e4f20eb5a30025c88fe5119a0e40c4187 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Tue, 13 Oct 2015 08:48:44 -0400 Subject: changelog --- Changelog | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Changelog b/Changelog index fa6608c..27384e0 100644 --- a/Changelog +++ b/Changelog @@ -103,3 +103,11 @@ - improved quests - added mobs - added DEBUG flags and functions to inventory.cpp and ui.cpp + +10/13/2015: +=========== + + - cleaned up main.cpp + - added DEBUG flags to common.cpp and Quest.cpp + - added player health + - made textures for rabbit -- cgit v1.2.3