- 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
- 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
#include <common.h>
+#define NPCp(n) ((NPC *)n)
+
class Entity{
public:
void *inWorld;
};
class NPC : public Entity{
+private:
+ std::vector<int (*)(NPC *)>aiFunc;
public:
NPC();
+ void addAIFunc(int (*func)(NPC *));
void interact();
};
class Structures : public Entity{
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
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();
entity[i]->inWorld=test;
}
+ NPCp(entity[1])->addAIFunc(entityInteractTest);
+
//************************************************************************//
// END WORLD GENERATION STUFF //
//************************************************************************//
}
}
void handleEvents(void){
+ static bool left=false,right=false;
SDL_Event e;
while(SDL_PollEvent(&e)){
switch(e.type){
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);
}
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;