aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Changelog16
-rw-r--r--Goals.txt4
-rw-r--r--include/ui.h2
-rw-r--r--include/world.h10
-rw-r--r--main.cpp1
-rw-r--r--src/entities.cpp4
-rw-r--r--src/gameplay.cpp25
-rw-r--r--src/ui.cpp19
-rw-r--r--src/world.cpp37
9 files changed, 95 insertions, 23 deletions
diff --git a/Changelog b/Changelog
index c0d2b9e..e3ed5e0 100644
--- a/Changelog
+++ b/Changelog
@@ -460,3 +460,19 @@
- added World::getAvailableNPC() for easy quest assigner assigning
- added the Condition class, so that events and actions can be remembered by NPCs
- added functionality for multiple lights (GLSL)
+
+12/22/2015:
+===========
+
+ - 3 month Changelog anniversary!
+ - fixed dialog quitting bug
+ - worked on village spawning
+ - worked on wrapping text for dialog boxes
+ - did more work on GLSL shaders
+
+1/3/2015:
+=========
+
+ - finished wrapping text for dialog boxes
+ - began working on world saving/loading again
+ - got some mad GLSL shaders running
diff --git a/Goals.txt b/Goals.txt
index 140cdd3..4848bac 100644
--- a/Goals.txt
+++ b/Goals.txt
@@ -35,7 +35,7 @@ End of December:
- create first 'chapters' of story
- create very first areas in the game (code it) to get an
idea of what's gonna go down
-
+
January - March:
===============
@@ -45,7 +45,7 @@ January - March:
February - End of March:
========================
- - design sound effects / background music?
+ - design or focus on sound effects / background music?
March-ish:
======
diff --git a/include/ui.h b/include/ui.h
index 6a81dab..b769bbf 100644
--- a/include/ui.h
+++ b/include/ui.h
@@ -33,6 +33,8 @@ namespace ui {
extern unsigned char dialogOptChosen;
extern bool dialogImportant;
+ extern unsigned int textWrapLimit;
+
/*
* Initializes the FreeType system.
*/
diff --git a/include/world.h b/include/world.h
index 98ca54a..cdcea3c 100644
--- a/include/world.h
+++ b/include/world.h
@@ -8,6 +8,9 @@
#ifndef WORLD_H
#define WORLD_H
+#include <ostream>
+#include <istream>
+
#include <common.h>
#include <entities.h>
@@ -128,6 +131,7 @@ protected:
*/
Texturec *bgTex;
+ WORLD_BG_TYPE bgType;
/**
* The Mix_Music object that holds the background soundtrack for the world.
@@ -167,7 +171,7 @@ public:
std::vector<Particles *> particles;
void addStructure(_TYPE t,BUILD_SUB sub,float x,float y,World *inside);
- void addVillage(int bCount, int npcMin, int npcMax,_TYPE t,float x,float y,World *outside);
+ void addVillage(int bCount, int npcMin, int npcMax,_TYPE t,World *inside);
void addMob(int t,float x,float y);
void addMob(int t,float x,float y,void (*hey)(Mob *));
void addNPC(float x,float y);
@@ -262,8 +266,8 @@ public:
int getTheWidth(void);
- void save(FILE *);
- void load(FILE *);
+ void save(std::ofstream *);
+ void load(std::ifstream *);
};
/*
diff --git a/main.cpp b/main.cpp
index e6ff2eb..2c088cb 100644
--- a/main.cpp
+++ b/main.cpp
@@ -480,6 +480,7 @@ void mainLoop(void){
if(prev != currentWorld){
currentWorld->bgmPlay(prev);
+ ui::dialogBoxExists = false;
}
if(prevPrevTime + MSEC_PER_TICK <= currentTime){
diff --git a/src/entities.cpp b/src/entities.cpp
index 3849040..d424aba 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -101,7 +101,7 @@ NPC::NPC(){ //sets all of the NPC specific traits on object creation
tex = new Texturec(1,"assets/NPC.png");
inv = new Inventory(NPC_INV_SIZE);
- randDialog = rand() % 12 - 1;
+ randDialog = 6;//rand() % 12 - 1;
}
NPC::~NPC(){
while(!aiFunc.empty()){
@@ -341,7 +341,7 @@ const char *randomDialog[] = {
"How much wood could a woodchuck chuck if a woodchuck could chuck wood?",
"I don\'t think anyone has ever been able to climb up that hill.",
"If you ever see a hole in the ground, watch out; it could mean the end for you.",
- "Did you know this game has over 4000 lines of code? I didn\'t. I didn't even know I was in a game until now...",
+ "Did you know this game has over 5000 lines of code? I didn\'t. I didn't even know I was in a game until now...",
"HELP MY CAPS LOCK IS STUCK",
"You know, if anyone ever asked me who I wanted to be when I grow up, I would say Abby Ross.",
"I want to have the wallpaper in our house changed. It doesn\'t really fit the environment.",
diff --git a/src/gameplay.cpp b/src/gameplay.cpp
index 7dbe98e..ff77728 100644
--- a/src/gameplay.cpp
+++ b/src/gameplay.cpp
@@ -115,15 +115,21 @@ static World *worldSpawnHill3;
static IndoorWorld *worldSpawnHill2_Building1;
+static World *worldFirstVillage;
/*
* initEverything() start
*/
void destroyEverything(void);
void initEverything(void){
-
+ //static std::ifstream i ("world.dat",std::ifstream::in | std::ifstream::binary);
+
worldSpawnHill1 = new World();
- worldSpawnHill1->generateFunc(400,gen_worldSpawnHill1);
+ /*if(!i.fail()){
+ worldSpawnHill1->load(&i);
+ i.close();
+ }else*/
+ worldSpawnHill1->generateFunc(400,gen_worldSpawnHill1);
worldSpawnHill1->setBackground(BG_FOREST);
worldSpawnHill1->setBGM("assets/music/embark.wav");
worldSpawnHill1->addMob(MS_TRIGGER,0,0,worldSpawnHill1_hillBlock);
@@ -138,12 +144,18 @@ void initEverything(void){
worldSpawnHill3->generateFunc(1000,gen_worldSpawnHill3);
worldSpawnHill3->setBackground(BG_FOREST);
worldSpawnHill3->setBGM("assets/music/ozone.wav");
- worldSpawnHill3->addHole(800,1000);
+
+ worldFirstVillage = new World();
+ worldFirstVillage->generate(1000);
+ worldFirstVillage->setBackground(BG_FOREST);
+ worldFirstVillage->setBGM("assets/music/embark.wav");
worldSpawnHill1->toRight = worldSpawnHill2;
worldSpawnHill2->toLeft = worldSpawnHill1;
worldSpawnHill2->toRight = worldSpawnHill3;
worldSpawnHill3->toLeft = worldSpawnHill2;
+ worldSpawnHill3->toRight = worldFirstVillage;
+ worldFirstVillage->toLeft = worldSpawnHill3;
/*
* Spawn some entities.
@@ -166,6 +178,8 @@ void initEverything(void){
worldSpawnHill2->addStructure(STRUCTURET,HOUSE,(rand()%120*HLINE),100,worldSpawnHill2_Building1);
worldSpawnHill2->getAvailableNPC()->addAIFunc(worldSpawnHill2_Quest1,false);
+ worldFirstVillage->addVillage(5,0,0,STRUCTURET,worldSpawnHill2_Building1);
+
player = new Player();
player->spawn(200,100);
@@ -178,6 +192,11 @@ extern std::vector<int (*)(NPC *)> AIpreload;
extern std::vector<NPC *> AIpreaddr;
void destroyEverything(void){
+ static std::ofstream o;
+ o.open("world.dat",std::ifstream::binary);
+ worldSpawnHill1->save(&o);
+ o.close();
+
while(!AIpreload.empty())
AIpreload.pop_back();
while(!AIpreaddr.empty())
diff --git a/src/ui.cpp b/src/ui.cpp
index f73f48a..b827b43 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -95,6 +95,8 @@ namespace ui {
bool dialogImportant = false;
unsigned char dialogOptChosen = 0;
+ unsigned int textWrapLimit = 110;
+
/*
* Current font size. Changing this WILL NOT change the font size, see setFontSize() for
* actual font size changing.
@@ -266,7 +268,13 @@ namespace ui {
*/
do{
- if(s[i]=='\n'){ // Handle newlines
+ if(i && ((i / 110.0) == (i / 110))){
+ yo-=fontSize*1.05;
+ xo=x;
+ if(s[i] == ' ')
+ i++;
+ }
+ if(s[i] == '\n'){
yo-=fontSize*1.05;
xo=x;
}else if(s[i]==' '){ // Handle spaces
@@ -308,12 +316,13 @@ namespace ui {
* Draw a string in a typewriter-esque fashion. Each letter is rendered as calls are made
* to this function. Passing a different string to the function will reset the counters.
*/
-
+
+ static char *ret = NULL;
char *typeOut(char *str){
static unsigned int sinc, // Acts as a delayer for the space between each character.
linc=0, // Contains the number of letters that should be drawn.
size=0; // Contains the full size of the current string.
- static char *ret = NULL;
+ //static char *ret = NULL;
/*
* Create a well-sized buffer if we haven't yet.
@@ -453,6 +462,8 @@ namespace ui {
dialogBoxExists = true;
dialogImportant = false;
+ if(ret)
+ ret[0] = '\0';
}
void waitForDialog(void){
do{
@@ -667,7 +678,6 @@ DONE:
memcpy(&player->loc,&tmppos,sizeof(vec2));
currentWorld = tmp;
toggleBlackFast();
- dialogBoxExists = false;
}
}
break;
@@ -689,7 +699,6 @@ DONE:
memcpy(&player->loc,&tmppos,sizeof(vec2));
currentWorld = tmp;
toggleBlackFast();
- dialogBoxExists = false;
}
}
break;
diff --git a/src/world.cpp b/src/world.cpp
index 5663086..2afbdf5 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -50,6 +50,7 @@ float worldGetYBase(World *w){
}
void World::setBackground(WORLD_BG_TYPE bgt){
+ bgType = bgt;
switch(bgt){
case BG_FOREST:
bgTex = new Texturec(7,bgPaths[0]);
@@ -60,12 +61,28 @@ void World::setBackground(WORLD_BG_TYPE bgt){
}
}
-void World::save(FILE *s){
- fclose(s);
+void World::save(std::ofstream *o){
+ o->write((char *)&lineCount, sizeof(unsigned int));
+ o->write((char *)&line ,lineCount * sizeof(struct line_t));
+ o->write("GG" ,2 * sizeof(char));
+ o->write((char *)&star ,100 * sizeof(vec2));
}
-void World::load(FILE *s){
- fclose(s);
+void World::load(std::ifstream *i){
+ static char end[2];
+
+ i->read((char *)&lineCount,sizeof(unsigned int));
+ line = new struct line_t[lineCount];
+
+ i->read((char *)&line,lineCount * sizeof(struct line_t));
+ i->read(end ,2 * sizeof(char));
+ if(strncmp(end,"GG",2)){
+ std::cout<<"world.dat corrupt"<<std::endl;
+ exit(EXIT_FAILURE);
+ }
+ i->read((char *)&star,100 * sizeof(vec2));
+
+ x_start = 0 - getWidth(this) / 2;
}
World::World(void){
@@ -913,16 +930,20 @@ void World::addStructure(_TYPE t,BUILD_SUB sub, float x,float y,World *inside){
entity.push_back(build.back());
}
-void World::addVillage(int bCount, int npcMin, int npcMax,_TYPE t,float x,float y,World *outside){
+void World::addVillage(int bCount, int npcMin, int npcMax,_TYPE t,World *inside){
std::cout << npcMin << ", " << npcMax << std::endl;
- int xwasd;
+ //int xwasd;
for(int i = 0; i < bCount; i++){
- xwasd = (rand()%(int)x+1000*HLINE);
+ addStructure(t,HOUSE,x_start + (i * 300),100,inside);
+ /*std::cout<<"1\n";
HERE:
+ xwasd = (rand()%(int)x+1000*HLINE);
for(auto &bu : build){
if(xwasd > bu->loc.x && xwasd < bu->loc.x+bu->width)goto HERE;
}
- addStructure(t,HOUSE,xwasd,y,outside);
+ std::cout<<"2\n";
+ addStructure(t,HOUSE,xwasd,y,inside);
+ std::cout<<"3\n";*/
}
}
void World::addMob(int t,float x,float y){