]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
updated goals, better NPC interaction
authorClyne Sullivan <tullivan99@gmail.com>
Wed, 30 Sep 2015 12:15:10 +0000 (08:15 -0400)
committerClyne Sullivan <tullivan99@gmail.com>
Wed, 30 Sep 2015 12:15:10 +0000 (08:15 -0400)
Changelog
Goals.txt
include/entities.h
src/entities.cpp
src/main.cpp
src/ui.cpp

index cd04cf6bc9ae9c0a61c6e6ca7e38287d07f36623..c1d3ed99ae628251a2eab3ecfc3fb5e8d5fa57da 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -44,3 +44,9 @@
        - successfully ran game 200 entities
        - improved debug screen
        - added mouse interaction w/ NPCs
+       
+9/30/2015:
+==========
+
+       - improved left/right movement
+       - added framework work NPC dialog n' stuff
index db3d3990effde46dc8737e09d5362d0f3dc1cda2..ede8de8fbe772113430b69e97d59f5dc20cc2078 100644 (file)
--- a/Goals.txt
+++ b/Goals.txt
@@ -6,4 +6,23 @@ End of October:
        - have textures for the world and entities (png's and stuff)
        - have basic quest handling/player can interact with NPCs to take quests
        - have basic mobs/animals
-       - 
+
+...
+
+End of March:
+=============
+
+       - Have game ready to be beta-tested by friends/other people so we can work
+         on receiving bug reports/adding things testers expect to have in the game.
+         
+End of April:
+=============
+
+       - Have all major bugs found by beta testers removed/fixed
+       - Have the game ready for release to the public (during May the game should
+         be released in some form)
+
+End of May:
+===========
+
+       - Have game fully deployed with a way to receive feedback from the players
index 53a80574787af1cd66190dee50e10c8faba19f2a..9e0257ff16c9ffd71897f14b6825d9741615f6d8 100644 (file)
@@ -3,6 +3,8 @@
 
 #include <common.h>
 
+#define NPCp(n) ((NPC *)n)
+
 class Entity{
 public:
        void *inWorld;
@@ -40,8 +42,11 @@ public:
 };
 
 class NPC : public Entity{
+private:
+       std::vector<int (*)(NPC *)>aiFunc;
 public:
        NPC();
+       void addAIFunc(int (*func)(NPC *));
        void interact();
 };
 class Structures : public Entity{
index af4b45f8d8883d057d94aa3eceb0dccc88954712..cff971f5d3e429d9311646b21d13b1b1281b9c77 100644 (file)
@@ -60,8 +60,19 @@ NPC::NPC(){  //sets all of the NPC specific traits on object creation
        canMove = true;
 }
 
+void NPC::addAIFunc(int (*func)(NPC *)){
+       aiFunc.push_back(func);
+}
+
 void NPC::interact(){ //have the npc's interact back to the player
+       int (*func)(NPC *);
        loc.y += 5;
+       if(aiFunc.size()){
+               func=aiFunc.front();
+               if(!func(this)){
+                       aiFunc.erase(aiFunc.begin());
+               }
+       }
 }
 
 Structures::Structures(){ //sets the structure type
index d5fe3fd1f3b892a1c6583368983ca41f458da8e7..77d22bc1f3857aee93cf05d8e9d285762b2fe442 100644 (file)
@@ -33,6 +33,11 @@ FILE* names;
 void logic();
 void render();
 
+int entityInteractTest(NPC *speaker){
+       ui::dialogBox("NPC: Hello there!");
+       return 1;
+}
+
 unsigned int millis(void){
        std::chrono::system_clock::time_point now=std::chrono::system_clock::now();
        return std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()).count();
@@ -117,6 +122,8 @@ int main(int argc, char *argv[]){
                entity[i]->inWorld=test;
        }
        
+       NPCp(entity[1])->addAIFunc(entityInteractTest);
+       
        //************************************************************************//
        //      END WORLD GENERATION STUFF                                                                                        //
        //************************************************************************//
index ab15c897c71f3e7a23f00133b5c7b7c64b907fd5..ec78507b09c23e913ac8db6bb86d899c397b9cf4 100644 (file)
@@ -128,6 +128,7 @@ namespace ui {
                }
        }
        void handleEvents(void){
+               static bool left=false,right=false;
                SDL_Event e;
                while(SDL_PollEvent(&e)){
                        switch(e.type){
@@ -138,16 +139,24 @@ namespace ui {
                                mouse.x=e.motion.x;
                                mouse.y=e.motion.y;
                                break;
+                       case SDL_MOUSEBUTTONDOWN:
+                               if((e.button.button&SDL_BUTTON_RIGHT)&&dialogBoxExists){
+                                       dialogBoxExists=false;
+                                       dialogBoxText=NULL;
+                               }
+                               break;
                        /*
                                KEYDOWN
                        */
                        case SDL_KEYDOWN:
                                if(SDL_KEY==SDLK_ESCAPE)gameRunning=false;                                                      // Exit the game with ESC
                                if(SDL_KEY==SDLK_a){                                                                                            // Move left
+                                       left=true;
                                        player->vel.x=-.15;
                                        currentWorld=currentWorld->goWorldLeft(player);
                                }
                                if(SDL_KEY==SDLK_d){                                                                                            // Move right
+                                       right=true;
                                        player->vel.x=.15;
                                        currentWorld=currentWorld->goWorldRight(player);
                                }
@@ -167,22 +176,14 @@ namespace ui {
                                if(SDL_KEY==SDLK_k)currentWorld=currentWorld->goWorldFront(player);     // Go forward a layer if possible
                                if(SDL_KEY==SDLK_F3)debug^=true;
                                if(SDL_KEY==SDLK_LSHIFT)player->speed = 3;
-                               
-                               // TEMPORARY UNTIL MOUSE
-                               if(SDL_KEY==SDLK_t){
-                                       if(dialogBoxExists){
-                                               dialogBoxExists=false;
-                                               dialogBoxText=NULL;
-                                       }else dialogBox("Hello");
-                               }
-                               
                                break;
                        /*
                                KEYUP
                        */      
                        case SDL_KEYUP:
-                               if(SDL_KEY==SDLK_a)player->vel.x=0;     // Stop the player if movement keys are released
-                               if(SDL_KEY==SDLK_d)player->vel.x=0;
+                               if(SDL_KEY==SDLK_a)left=false;  // Stop the player if movement keys are released
+                               if(SDL_KEY==SDLK_d)right=false;
+                               if(!left&&!right)player->vel.x=0;
                                if(SDL_KEY==SDLK_LSHIFT)player->speed = 1;
 
                                break;