aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2015-09-30 08:15:10 -0400
committerClyne Sullivan <tullivan99@gmail.com>2015-09-30 08:15:10 -0400
commitb3e21d31304efd793c58e904765bf298da6c5c20 (patch)
tree2650158bddb5c6fc496cbcbab22ec0c27f2bab19
parentf39124d141ca3faaa63dd30ba87905837ae47b48 (diff)
updated goals, better NPC interaction
-rw-r--r--Changelog6
-rw-r--r--Goals.txt21
-rw-r--r--include/entities.h5
-rw-r--r--src/entities.cpp11
-rw-r--r--src/main.cpp7
-rw-r--r--src/ui.cpp23
6 files changed, 61 insertions, 12 deletions
diff --git a/Changelog b/Changelog
index cd04cf6..c1d3ed9 100644
--- 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
diff --git a/Goals.txt b/Goals.txt
index db3d399..ede8de8 100644
--- 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
diff --git a/include/entities.h b/include/entities.h
index 53a8057..9e0257f 100644
--- a/include/entities.h
+++ b/include/entities.h
@@ -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{
diff --git a/src/entities.cpp b/src/entities.cpp
index af4b45f..cff971f 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -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
diff --git a/src/main.cpp b/src/main.cpp
index d5fe3fd..77d22bc 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -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 //
//************************************************************************//
diff --git a/src/ui.cpp b/src/ui.cpp
index ab15c89..ec78507 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -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;