--- /dev/null
+#ifndef QUEST_H\r
+#define QUEST_H\r
+\r
+#include <common.h>\r
+#include <cstring>\r
+\r
+#define QUEST_LIMIT 5\r
+#define TOTAL_QUESTS 1\r
+\r
+class Quest {\r
+public:\r
+ char *title,*desc;\r
+ unsigned int xp;\r
+ Quest(const char *t,const char *d,unsigned int x);\r
+ ~Quest();\r
+};\r
+\r
+class QuestHandler {\r
+private:\r
+ unsigned char ccnt;\r
+ const Quest *current[QUEST_LIMIT];\r
+public:\r
+ QuestHandler();\r
+ int assign(const char *t);\r
+ int drop(const char *t);\r
+ int finish(const char *t);\r
+};\r
+\r
+#endif // QUEST_H\r
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_opengl.h>
-typedef struct { float x; float y; } vec2;
+typedef struct { float x; float y; }vec2;
+typedef struct { char* first; char* last; }_name;
enum _TYPE { //these are the main types of entities
STRUCTURET = -1,
--- /dev/null
+#include <Quest.h>\r
+\r
+const Quest QuestList[TOTAL_QUESTS]={\r
+ Quest("Test","A test quest",0)\r
+};\r
+\r
+Quest::Quest(const char *t,const char *d,unsigned int x){\r
+ size_t len;\r
+ title=(char *)malloc((len=strlen(t)));\r
+ strncpy(title,t,len);\r
+ desc=(char *)malloc((len=strlen(d)));\r
+ strncpy(desc,d,len);\r
+ xp=x;\r
+}\r
+Quest::~Quest(){\r
+ free(title);\r
+ free(desc);\r
+ xp=0;\r
+}\r
+\r
+QuestHandler::QuestHandler(){\r
+ ccnt=0;\r
+}\r
+int QuestHandler::assign(const char *t){\r
+ unsigned int i=0;\r
+ if(ccnt==QUEST_LIMIT)\r
+ return -1;\r
+ for(;i<TOTAL_QUESTS;i++){\r
+ if(!strcmp(QuestList[i].title,t)){\r
+ current[ccnt++]=&QuestList[i];\r
+ return ccnt;\r
+ }\r
+ }\r
+ return -1;\r
+}\r
+int QuestHandler::drop(const char *t){\r
+ unsigned char i=0;\r
+ for(;i<ccnt;i++){\r
+ if(!strcmp(current[i]->title,t)){\r
+ for(i++;i<ccnt;i++){\r
+ current[i-1]=current[i];\r
+ }\r
+ return (--ccnt);\r
+ }\r
+ }\r
+ return -1;\r
+}\r
+int QuestHandler::finish(const char *t){\r
+ unsigned char i=0;\r
+ unsigned int j;\r
+ for(;i<ccnt;i++){\r
+ if(!strcmp(current[i]->title,t)){\r
+ j=current[i]->xp;\r
+ for(i++;i<ccnt;i++){\r
+ current[i-1]=current[i];\r
+ }\r
+ ccnt--;\r
+ return j;\r
+ }\r
+ }\r
+ return -1;\r
+}\r
int mx, my;
+FILE* config;
+FILE* names;
+
void logic();
void render();
glMatrixMode(GL_PROJECTION); //set the matrix mode as projection so we can set the ortho size and the camera settings later on
glPushMatrix(); //push the matrix to the top of the matrix stack
glLoadIdentity(); //replace the entire matrix stack with the updated GL_PROJECTION mode
+typedef struct { char* first; char
glOrtho(player->loc.x-SCREEN_WIDTH/2,player->loc.x+SCREEN_WIDTH/2,0,SCREEN_HEIGHT,-1,1);
glMatrixMode(GL_MODELVIEW); //set the matrix to modelview so we can draw objects
glPushMatrix(); //push the matrix to the top of the matrix stack
if(entity[i]->alive&&entity[i]->type == NPCT){
entity[i]->wander((rand()%120 + 30), &entity[i]->vel);
if( pow((entity[i]->loc.x - player->loc.x),2) + pow((entity[i]->loc.y - player->loc.y),2) <= pow(35*HLINE,2)){
- if(mx >= entity[i]->loc.x && mx <= entity[i]->loc.x + entity[i]->width && my >= entity[i]->loc.y && my <= entity[i]->loc.y + entity[i]->width && (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_RIGHT)))
+ if(mx >= entity[i]->loc.x && mx <= entity[i]->loc.x + entity[i]->width && my >= entity[i]->loc.y && my <= entity[i]->loc.y + entity[i]->width
+ && (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_RIGHT)))
entity[i]->interact();
}
}