aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordrumsetmonkey <abelleisle@roadrunner.com>2016-02-19 18:33:29 -0500
committerdrumsetmonkey <abelleisle@roadrunner.com>2016-02-19 18:33:29 -0500
commit0075f9e7997d01fa2105bff38e40a3d5b8b421e6 (patch)
treec2e9bbbced1ac97cbcfd81930905aec50325dc64
parent2a4a514b654ef0e08134a116c658d49a8f16cfe7 (diff)
Village work
-rw-r--r--assets/style/classic/bg/bgFarTreeTile.pngbin9433 -> 0 bytes
-rw-r--r--assets/style/classic/bg/bgFrontTreeTile.pngbin27660 -> 0 bytes
-rw-r--r--assets/style/classic/bg/bgMidTreeTile.pngbin30605 -> 0 bytes
-rw-r--r--assets/style/rustic/bg/bgFarTreeTile.pngbin9433 -> 0 bytes
-rw-r--r--assets/style/rustic/bg/bgFrontTreeTile.pngbin27660 -> 0 bytes
-rw-r--r--assets/style/rustic/bg/bgMidTreeTile.pngbin30605 -> 0 bytes
-rw-r--r--include/common.h1
-rw-r--r--include/ui.h1
-rw-r--r--include/world.h22
-rw-r--r--main.cpp11
-rw-r--r--src/ui.cpp12
-rw-r--r--src/world.cpp128
-rw-r--r--xml/playerSpawnHill1.xml9
13 files changed, 125 insertions, 59 deletions
diff --git a/assets/style/classic/bg/bgFarTreeTile.png b/assets/style/classic/bg/bgFarTreeTile.png
deleted file mode 100644
index 07546a5..0000000
--- a/assets/style/classic/bg/bgFarTreeTile.png
+++ /dev/null
Binary files differ
diff --git a/assets/style/classic/bg/bgFrontTreeTile.png b/assets/style/classic/bg/bgFrontTreeTile.png
deleted file mode 100644
index 7fc7450..0000000
--- a/assets/style/classic/bg/bgFrontTreeTile.png
+++ /dev/null
Binary files differ
diff --git a/assets/style/classic/bg/bgMidTreeTile.png b/assets/style/classic/bg/bgMidTreeTile.png
deleted file mode 100644
index 126723e..0000000
--- a/assets/style/classic/bg/bgMidTreeTile.png
+++ /dev/null
Binary files differ
diff --git a/assets/style/rustic/bg/bgFarTreeTile.png b/assets/style/rustic/bg/bgFarTreeTile.png
deleted file mode 100644
index 07546a5..0000000
--- a/assets/style/rustic/bg/bgFarTreeTile.png
+++ /dev/null
Binary files differ
diff --git a/assets/style/rustic/bg/bgFrontTreeTile.png b/assets/style/rustic/bg/bgFrontTreeTile.png
deleted file mode 100644
index 7fc7450..0000000
--- a/assets/style/rustic/bg/bgFrontTreeTile.png
+++ /dev/null
Binary files differ
diff --git a/assets/style/rustic/bg/bgMidTreeTile.png b/assets/style/rustic/bg/bgMidTreeTile.png
deleted file mode 100644
index 126723e..0000000
--- a/assets/style/rustic/bg/bgMidTreeTile.png
+++ /dev/null
Binary files differ
diff --git a/include/common.h b/include/common.h
index 34260c9..f141afd 100644
--- a/include/common.h
+++ b/include/common.h
@@ -16,6 +16,7 @@
#include <string>
#include <fstream>
#include <thread>
+#include <mutex>
#define GLEW_STATIC
#include <GL/glew.h>
diff --git a/include/ui.h b/include/ui.h
index 38a4932..8d479a4 100644
--- a/include/ui.h
+++ b/include/ui.h
@@ -102,6 +102,7 @@ namespace ui {
extern bool dialogBoxExists;
extern unsigned char dialogOptChosen;
extern bool dialogImportant;
+ extern bool dialogPassive;
extern unsigned int textWrapLimit;
diff --git a/include/world.h b/include/world.h
index 43da6fc..edf7ebb 100644
--- a/include/world.h
+++ b/include/world.h
@@ -81,13 +81,29 @@ typedef struct line_t {
unsigned char color; /**< Lightness of dirt (brown) */
} line_t;
+/*
+ * Handle all logic that has to do with villages
+ */
+
+
+struct Village{
+ std::string name;
+
+ std::vector<std::shared_ptr<Entity>> entity;
+ std::vector<std::shared_ptr<Structures>> build;
+ std::vector<std::shared_ptr<NPC>> npc;
+
+ Village(const char *meme){
+ name = meme;
+ }
+};
+
/**
* The world class. This class does everything a world should do.
*/
class World {
protected:
-
/**
* The line array.
* This array is created through 'new' in World::generate(), with an amount
@@ -113,6 +129,8 @@ protected:
*/
void singleDetect(Entity *e);
+
+ static void villageLogic(World *world);
/**
* Empties all entity vectors.
@@ -244,6 +262,8 @@ public:
std::vector<std::string > sTexLoc;
+ std::vector<Village>village;
+
/**
* NULLifies pointers and allocates necessary memory. This should be
diff --git a/main.cpp b/main.cpp
index da1790f..eb53c99 100644
--- a/main.cpp
+++ b/main.cpp
@@ -237,6 +237,7 @@ int main(/*int argc, char *argv[]*/){
return -1;
}
Mix_AllocateChannels(8);
+ updateConfig();
// Run Mix_Quit when main returns
atexit(Mix_Quit);
@@ -373,8 +374,6 @@ int main(/*int argc, char *argv[]*/){
delete[] shaderSource;
glEnable(GL_MULTISAMPLE);
-
- Mix_Volume(0,VOLUME_MASTER);
/*
* Create all the worlds, entities, mobs, and the player. This function is defined in
@@ -524,7 +523,7 @@ void render(){
if(player->loc.x - SCREEN_WIDTH/2 < currentWorld->getTheWidth() * -0.5f)
offset.x = ((currentWorld->getTheWidth() * -0.5f) + SCREEN_WIDTH / 2) + player->width / 2;
if(player->loc.x + player->width + SCREEN_WIDTH/2 > currentWorld->getTheWidth() * 0.5f)
- offset.x = ((currentWorld->getTheWidth() * 0.5f) - SCREEN_WIDTH / 2);// + player->width / 2;
+ offset.x = ((currentWorld->getTheWidth() * 0.5f) - SCREEN_WIDTH / 2) - player->width / 2;
}
if(player->loc.y > SCREEN_HEIGHT/2)
@@ -570,7 +569,7 @@ void render(){
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
- glOrtho((offset.x-SCREEN_WIDTH/2),(offset.x+SCREEN_WIDTH/2),offset.y-SCREEN_HEIGHT/2,offset.y+SCREEN_HEIGHT/2,-1,1);
+ glOrtho((offset.x-SCREEN_WIDTH/2),(offset.x+SCREEN_WIDTH/2),(offset.y-SCREEN_HEIGHT/2),(offset.y+SCREEN_HEIGHT/2),-1,1);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
@@ -892,7 +891,7 @@ void logic(){
}
}
}
- for(auto &b : currentWorld->build){
+ /*for(auto &b : currentWorld->build){
switch(b->bsubtype){
case FOUNTAIN:
for(int r = 0; r < (rand()%25)+10;r++){
@@ -917,7 +916,7 @@ void logic(){
break;
default: break;
}
- }
+ }*/
/*
* Switch between day and night (SUNNY and DARK) if necessary.
diff --git a/src/ui.cpp b/src/ui.cpp
index e6ee988..43706e7 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -52,7 +52,6 @@ static char dialogBoxText[512];
static char *dialogOptText[4];
static float dialogOptLoc[4][3];
static unsigned char dialogOptCount = 0;
-static bool dialogPassive = false;
static bool typeOutDone = true;
extern Menu* currentMenu;
@@ -114,6 +113,8 @@ namespace ui {
bool debug=false;
bool posFlag=false;
+ bool dialogPassive = false;
+
/*
* Dialog stuff that needs to be 'public'.
@@ -555,9 +556,10 @@ namespace ui {
if(dialogImportant){
setFontColor(255,255,255);
- if(fadeIntensity == 255){
+ if(fadeIntensity == 255 || dialogPassive){
setFontSize(24);
putStringCentered(offset.x,offset.y,rtext);
+ setFontSize(16);
}
}else{
@@ -602,7 +604,7 @@ namespace ui {
Mix_PlayChannel(1,dialogClick,0);
}
- }else if(!dialogImportant && !fadeIntensity){
+ }if(!fadeIntensity){
vec2 hub = {
(SCREEN_WIDTH/2+offset.x)-fontSize*10,
(offset.y+SCREEN_HEIGHT/2)-fontSize
@@ -1182,6 +1184,10 @@ DONE:
return;
}
switch(SDL_KEY){
+ case SDLK_w:
+ dialogPassive = true;
+ importantText("Welcome to Meme-Town");
+ break;
case SDLK_a:
left = false;
break;
diff --git a/src/world.cpp b/src/world.cpp
index 2012d32..d039bca 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -17,39 +17,25 @@ bool worldInside = false; // True if player is inside a structure
WEATHER weather = SUNNY;
-// const char *bgPaths[2][7]={
-// {"assets/bg.png", // Daytime background
-// "assets/bgn.png", // Nighttime background
-// "assets/bgFarMountain.png", // Furthest layer
-// "assets/forestTileBack.png", // Closer layer
-// "assets/forestTileMid.png", // Near layer
-// "assets/forestTileFront.png", // Closest layer
-// "assets/dirt.png"}, // Dirt
-// {"assets/bgWoodTile.png",
-// NULL,
-// NULL,
-// NULL,
-// NULL,
-// NULL}
-// };
-
-const std::string bgPaths[2][8]={
- {"bg.png", // Daytime background
- "bgn.png", // Nighttime background
- "bgFarMountain.png", // Furthest layer
- "forestTileBack.png", // Closer layer
- "forestTileMid.png", // Near layer
- "forestTileFront.png", // Closest layer
- "dirt.png", // Dirt
- "grass.png"}, // Grass
- {"bgWoodTile.png",
- "bgWoodTile.png",
- "bgWoodTile.png",
- "bgWoodTile.png",
- "bgWoodTile.png",
- "bgWoodTile.png",
- "bgWoodTile.png",
- "bgWoodTile.png"}
+
+const std::string bgPaths[2][9]={
+ {"bg.png", // Daytime background
+ "bgn.png", // Nighttime background
+ "bgFarMountain.png", // Furthest layer
+ "forestTileFar.png", // Furthest away Tree Layer
+ "forestTileBack.png", // Closer layer
+ "forestTileMid.png", // Near layer
+ "forestTileFront.png", // Closest layer
+ "dirt.png", // Dirt
+ "grass.png"}, // Grass
+ {"bgWoodTile.png",
+ "bgWoodTile.png",
+ "bgWoodTile.png",
+ "bgWoodTile.png",
+ "bgWoodTile.png",
+ "bgWoodTile.png",
+ "bgWoodTile.png",
+ "bgWoodTile.png"}
};
const std::string buildPaths[] = { "townhall.png",
@@ -61,10 +47,11 @@ const std::string buildPaths[] = { "townhall.png",
"lampPost1.png",
"brazzier.png"};
-const float bgDraw[3][3]={
+const float bgDraw[4][3]={
{100,240,.6 },
{150,250,.4 },
- {255,255,.25}
+ {200,255,.25},
+ {255,255,.1}
};
float worldGetYBase(World *w){
@@ -342,7 +329,7 @@ void World::update(Player *p,unsigned int delta){
if(e->type != STRUCTURET && e->canMove){
e->loc.x += e->vel.x * delta;
if(e->vel.x < 0)e->left = true;
- else if(e->vel.x > 0)e->left = false;
+ else if(e->vel.x > 0)e->left = false;
}
}
@@ -489,10 +476,10 @@ void World::draw(Player *p){
glEnd();
/*
- * Draw three layers of trees.
+ * Draw four layers of trees.
*/
- for(i = 0; i < 3; i++){
+ for(i = 0; i < 4; i++){
bgTex->bindNext();
safeSetColorA(bgDraw[i][0]-bgshade,bgDraw[i][0]-bgshade,bgDraw[i][0]-bgshade,bgDraw[i][1]);
@@ -590,8 +577,7 @@ void World::draw(Player *p){
}
for(auto &b : current->build){
b->draw();
- }
-
+ }
/*
* Draw the layer up until the grass portion, which is done later.
*/
@@ -735,7 +721,6 @@ void World::draw(Player *p){
o->loc.y-=(yoff-DRAW_Y_OFFSET);
}
}
-
/*
* If we're drawing the closest/last world, handle and draw the player.
@@ -955,6 +940,7 @@ void World::singleDetect(Entity *e){
}
void World::detect(Player *p){
+ //static std::thread villageThread;
World *hey = this;
/*
@@ -962,6 +948,9 @@ void World::detect(Player *p){
*/
singleDetect(p);
+ //villageLogic(this);
+ //villageThread = std::thread(villageLogic, this);
+
/*
* Handle all remaining entities in this world.
@@ -988,10 +977,38 @@ void World::detect(Player *p){
}
what++;
}what=0;
+ for(auto &b : build){
+ switch(b->bsubtype){
+ case FOUNTAIN:
+ for(int r = 0; r < (rand()%25)+10;r++){
+ addParticle( rand()%HLINE*3 + b->loc.x + b->width/2,
+ b->loc.y + b->height,
+ HLINE*1.25,
+ HLINE*1.25,
+ rand()%2 == 0?-(rand()%7)*.01:(rand()%7)*.01,
+ ((4+rand()%6)*.05),
+ {0,0,255},
+ 2500);
+
+ particles.back()->fountain = true;
+ }
+ break;
+ case FIRE_PIT:
+ for(int r = 0; r < (rand()%20)+10;r++){
+ addParticle(rand()%(int)(b->width/2) + b->loc.x+b->width/4, b->loc.y+3*HLINE, HLINE, HLINE, rand()%2 == 0?-(rand()%3)*.01:(rand()%3)*.01,((4+rand()%6)*.005), {255,0,0}, 400);
+ particles.back()->gravity = false;
+ particles.back()->behind = true;
+ }
+ break;
+ default: break;
+ }
+ }
+
/*if(hey->infront){
hey = hey->infront;
goto LOOOOP;
}*/
+ //villageThread.join();
}
void World::addStructure(BUILD_SUB sub, float x,float y, char *tex, const char *inside){
build.push_back(new Structures());
@@ -1135,7 +1152,7 @@ World *World::goWorldRight(Player *p){
if(toRight && p->loc.x + p->width > -x_start - HLINE * 15){
tmp = loadWorldFromXML(toRight);
- p->loc.x = tmp->x_start + HLINE * 10;
+ p->loc.x = tmp->x_start + (int)HLINE * 10;
p->loc.y = tmp->line[0].y;
return tmp;
@@ -1479,6 +1496,7 @@ extern World *currentWorld;
World *loadWorldFromXML(const char *path){
XMLDocument xml;
XMLElement *wxml;
+ XMLElement *vil;
World *tmp;
float spawnx;
@@ -1499,11 +1517,17 @@ World *loadWorldFromXML(const char *path){
xml.LoadFile(currentXML);
wxml = xml.FirstChildElement("World");
+ vil = xml.FirstChildElement("World")->FirstChildElement("village");
if(wxml){
wxml = wxml->FirstChildElement();
Indoor = false;
tmp = new World();
+ if(vil){
+ vil = vil->FirstChildElement();
+ //tmp->village.push_back(vil->Attribute("name"));
+
+ }
}else if((wxml = xml.FirstChildElement("IndoorWorld"))){
wxml = wxml->FirstChildElement();
Indoor = true;
@@ -1512,7 +1536,6 @@ World *loadWorldFromXML(const char *path){
while(wxml){
name = wxml->Name();
-
if(!strcmp(name,"link")){
if((ptr = wxml->Attribute("left")))
tmp->setToLeft(ptr);
@@ -1577,9 +1600,26 @@ World *loadWorldFromXML(const char *path){
tmp->addMob(MS_TRIGGER,wxml->FloatAttribute("x"),0,commonTriggerFunc);
tmp->mob.back()->heyid = wxml->Attribute("id");
}
-
+
wxml = wxml->NextSiblingElement();
}
+
+ while(vil){
+ name = vil->Name();
+ if(!strcmp(name,"structure")){
+ ptr = vil->Attribute("inside");
+ tmp->addStructure((BUILD_SUB)vil->UnsignedAttribute("type"),
+ vil->QueryFloatAttribute("x",&spawnx) != XML_NO_ERROR ?
+ getRand() % tmp->getTheWidth() / 2.0f :
+ spawnx,
+ 100,
+ (char*)vil->Attribute("texture"),
+ ptr);
+
+ //tmp->village.back().build.push_back(tmp->build.back());
+ }
+ vil = vil->NextSiblingElement();
+ }
std::ifstream dat (((std::string)currentXML + ".dat").c_str());
if(dat.good()){
diff --git a/xml/playerSpawnHill1.xml b/xml/playerSpawnHill1.xml
index c5e736b..b0fb163 100644
--- a/xml/playerSpawnHill1.xml
+++ b/xml/playerSpawnHill1.xml
@@ -11,6 +11,10 @@
<npc name="Ralph" hasDialog="true" />
<npc name="Johnny" hasDialog="false" />
<structure type="5" inside="playerSpawnHill1_Building1.xml" />
+ <village name="Meme-Town">
+ <structure type="0" inside="playerSpawnHill1_Building1.xml" />
+ <structure type="5" inside="playerSpawnHill1_Building1.xml" />
+ </village>
</World>
@@ -29,14 +33,9 @@ And it wasn't stormy.
You should go talk to my friend Johnny. He's a pretty chill dude.
</text>
-<<<<<<< HEAD
- <text id="2" call="Johnny" callid="1">
- what you have done it to trick Microsoft?
-=======
<text id="2" >
Niice.
<quest check="Your First Quest" fail="3" />
->>>>>>> 3033594b89f23e65b6152daa6610f991307f2f67
</text>
<text id="3">