]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
Added quest files and file for names
authordrumsetmonkey <abelleisle@roadrunner.com>
Wed, 30 Sep 2015 12:06:06 +0000 (08:06 -0400)
committerdrumsetmonkey <abelleisle@roadrunner.com>
Wed, 30 Sep 2015 12:06:06 +0000 (08:06 -0400)
assets/names_en-us [new file with mode: 0644]
include/Quest.h [new file with mode: 0644]
include/common.h
src/Quest.cpp [new file with mode: 0644]
src/main.cpp

diff --git a/assets/names_en-us b/assets/names_en-us
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/include/Quest.h b/include/Quest.h
new file mode 100644 (file)
index 0000000..c73bf79
--- /dev/null
@@ -0,0 +1,29 @@
+#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
index 0c356048748771617835d84a93a11f49a771ea0b..8410f58608ff300106af517019f749247c8eeec3 100644 (file)
@@ -11,7 +11,8 @@
 #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,
diff --git a/src/Quest.cpp b/src/Quest.cpp
new file mode 100644 (file)
index 0000000..a42e42c
--- /dev/null
@@ -0,0 +1,62 @@
+#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
index 7980cf72c0fd1812d88e6604a4560e29469ec734..1e3bc103ddd83bf038d99a9f5138943e181e0d3b 100644 (file)
@@ -27,6 +27,9 @@ std::vector<Structures>build;
 
 int mx, my;
 
+FILE* config;
+FILE* names;
+
 void logic();
 void render();
 
@@ -151,6 +154,7 @@ 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
@@ -214,7 +218,8 @@ void logic(){
                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();
                        }
                }