aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Changelog7
-rw-r--r--assets/items/flashlight_off.pngbin0 -> 330 bytes
-rw-r--r--assets/playerk.pngbin0 -> 375 bytes
-rw-r--r--config/items.h6
-rw-r--r--include/common.h2
-rw-r--r--include/world.h2
-rw-r--r--src/gameplay.cpp94
-rw-r--r--src/ui.cpp10
-rw-r--r--src/world.cpp23
-rw-r--r--test.frag3
-rw-r--r--xcf/player.xcfbin0 -> 2357 bytes
-rw-r--r--xml/playerSpawnHill1.xml31
12 files changed, 138 insertions, 40 deletions
diff --git a/Changelog b/Changelog
index e8a016a..02dd436 100644
--- a/Changelog
+++ b/Changelog
@@ -377,7 +377,7 @@
==========
- re-did fullscreen text (importantText)
- - began doxygening headers
+ - began doxygening headersspin a dreidel
- fixed entity name reading
- fixed entity sprites
@@ -387,6 +387,9 @@
- continued to document header files through doxygen
- added border to dialogBox
- fix entity movement handling; npcs stop when you talk to them
+<<<<<<< HEAD
+ - added sword animation?
+=======
- added sword animation?
12/9/2015,
@@ -408,6 +411,7 @@
- imrpoved BGM handling
- continued work on particles, made a fountain
- added sanic
+=======
~ Broke 5000 lines of code/doc, now with some file Doxygen'd
@@ -420,6 +424,7 @@
- fixed fading bugs
- continued fixing general game bugs
- fixed structure spawn issues
+=======
12/15/2015:
===========
diff --git a/assets/items/flashlight_off.png b/assets/items/flashlight_off.png
new file mode 100644
index 0000000..8f6f204
--- /dev/null
+++ b/assets/items/flashlight_off.png
Binary files differ
diff --git a/assets/playerk.png b/assets/playerk.png
new file mode 100644
index 0000000..be98f97
--- /dev/null
+++ b/assets/playerk.png
Binary files differ
diff --git a/config/items.h b/config/items.h
index 9012ff6..ee1024c 100644
--- a/config/items.h
+++ b/config/items.h
@@ -29,10 +29,10 @@ ID PLAYER_BAG
ID FLASHLIGHT
NAME "Flashlight"
TYPE TOOL
- WIDTH HLINE*2
- HEIGHT HLINE*4
+ WIDTH HLINE*4
+ HEIGHT HLINE*8
STACKSIZE 1
- TEX "assets/items/ITEM_TEST.png"
+ TEX "assets/items/flashlight_off.png"
ENI
ID SWORD_WOOD
diff --git a/include/common.h b/include/common.h
index adbd7fa..8552720 100644
--- a/include/common.h
+++ b/include/common.h
@@ -78,7 +78,7 @@ typedef struct{
* The desired width of the game window.
*/
-#define SCREEN_WIDTH 1024
+#define SCREEN_WIDTH 1280
/**
* The desired height of the game window.
diff --git a/include/world.h b/include/world.h
index 5021fbb..0e85462 100644
--- a/include/world.h
+++ b/include/world.h
@@ -167,7 +167,7 @@ public:
* loaded inside the world, with the Entity vector containing pointers to
* the contents of all the others.
*/
-
+
std::vector<NPC *> npc;
std::vector<Structures *> build;
std::vector<Mob *> mob;
diff --git a/src/gameplay.cpp b/src/gameplay.cpp
index 6637d23..a257ad3 100644
--- a/src/gameplay.cpp
+++ b/src/gameplay.cpp
@@ -32,19 +32,22 @@ typedef struct {
char *file;
} WorldXML;
+
typedef struct {
NPC *npc;
unsigned int index;
} NPCDialog;
-std::vector<NPCDialog> npcd;
-std::vector<WorldXML> earthxml;
-std::vector<World *> earth;
+std::vector<NPCDialog> npcd;
+std::vector<WorldXML> earthxml;
+std::vector<World *> earth;
+std::vector<XMLElement *> dopt;
int commonAIFunc(NPC *speaker){
XMLDocument xml;
- XMLElement *exml;
+ XMLElement *exml,*oxml;
unsigned int idx;
+ bool stop = false;
for(auto &n : npcd){
if(n.npc == speaker){
@@ -56,13 +59,67 @@ int commonAIFunc(NPC *speaker){
for(auto &e : earthxml){
if(e.ptr == currentWorld){
xml.LoadFile(e.file);
- exml = xml.FirstChildElement("Dialog")->FirstChildElement();
+
+ exml = xml.FirstChildElement("Dialog");
+ while(strcmp(exml->Attribute("name"),speaker->name))
+ exml = exml->NextSiblingElement();
+
+ exml = exml->FirstChildElement();
do{
if(!strcmp(exml->Name(),"text")){
- if(!strcmp(exml->Attribute("name"),speaker->name) && exml->UnsignedAttribute("id") == idx){
- ui::dialogBox(speaker->name,"",false,exml->GetText());
- ui::waitForDialog();
+ if(/*!strcmp(exml->Attribute("name"),speaker->name) &&*/ exml->UnsignedAttribute("id") == idx){
+
+ if((oxml = exml->FirstChildElement("option"))){
+ const char *op;
+ char *bp1 = new char[1],*bp2,*tmp;
+ unsigned int idx = 0;
+ bp1[0] = '\0';
+ while(oxml){
+ op = oxml->Attribute("text");
+
+ bp2 = new char[strlen(bp1) + strlen(op) + 2];
+ strcpy(bp2,bp1);
+
+ bp2[idx++] = ':';
+ strcpy(bp2+idx,op);
+ idx += strlen(op);
+
+ tmp = bp1;
+ bp1 = bp2;
+ delete[] tmp;
+
+ dopt.push_back(oxml);
+
+ oxml = oxml->NextSiblingElement();
+ }
+ ui::dialogBox(speaker->name,bp1,false,exml->GetText());
+ ui::waitForDialog();
+ if(ui::dialogOptChosen){
+ exml = dopt[ui::dialogOptChosen-1];
+ }
+ while(!dopt.empty())
+ dopt.pop_back();
+ }else{
+ ui::dialogBox(speaker->name,"",false,exml->GetText());
+ ui::waitForDialog();
+ }
+ if(exml->Attribute("call")){
+ for(auto &n : currentWorld->npc){
+ if(!strcmp(n->name,exml->Attribute("call"))){
+ if(exml->QueryUnsignedAttribute("callid",&idx) == XML_NO_ERROR){
+ for(auto &n2 : npcd){
+ if(n2.npc == n){
+ n2.index = idx;
+ break;
+ }
+ }
+ }
+ n->addAIFunc(commonAIFunc,false);
+ break;
+ }
+ }
+ }
if(exml->QueryUnsignedAttribute("nextid",&idx) == XML_NO_ERROR){
for(auto &n : npcd){
if(n.npc == speaker){
@@ -70,7 +127,11 @@ int commonAIFunc(NPC *speaker){
break;
}
}
- return 1;
+ if(exml->QueryBoolAttribute("stop",&stop) == XML_NO_ERROR && stop)
+ return 0;
+ else if(exml->QueryBoolAttribute("pause",&stop) == XML_NO_ERROR && stop)
+ return 1;
+ else return commonAIFunc(speaker);
}
return 0;
}
@@ -88,6 +149,7 @@ void initEverything(void){
std::vector<std::string> xmlFiles;
static char *file;
bool dialog;
+ float spawnx;
XMLDocument xml;
XMLElement *wxml;
@@ -98,7 +160,8 @@ void initEverything(void){
for(auto x : xmlFiles){
if(strncmp(x.c_str(),".",1) && strncmp(x.c_str(),"..",2)){
- file = new char[4 + x.size()];
+ file = new char[5 + x.size()];
+ memset(file,0,5 + x.size());
strncpy(file,"xml/",4);
strcpy(file+4,x.c_str());
xml.LoadFile(file);
@@ -118,9 +181,16 @@ void initEverything(void){
earth.back()->generate(wxml->UnsignedAttribute("width"));
}
}else if(!strcmp(name,"mob")){
- earth.back()->addMob(wxml->UnsignedAttribute("type"),wxml->FloatAttribute("x"),wxml->FloatAttribute("y"));
+ if(wxml->QueryFloatAttribute("x",&spawnx) != XML_NO_ERROR)
+ earth.back()->addMob(wxml->UnsignedAttribute("type"),getRand() % earth.back()->getTheWidth() / 2,100);
+ else
+ earth.back()->addMob(wxml->UnsignedAttribute("type"),wxml->FloatAttribute("x"),wxml->FloatAttribute("y"));
}else if(!strcmp(name,"npc")){
- earth.back()->addNPC(wxml->FloatAttribute("x"),wxml->FloatAttribute("y"));
+ if(wxml->QueryFloatAttribute("x",&spawnx) != XML_NO_ERROR)
+ earth.back()->addNPC(getRand() % earth.back()->getTheWidth() / 2.0f,100);
+ else
+ earth.back()->addNPC(wxml->FloatAttribute("x"),wxml->FloatAttribute("y"));
+
if(wxml->Attribute("name")){
delete[] earth.back()->npc.back()->name;
earth.back()->npc.back()->name = new char[strlen(wxml->Attribute("name"))+1];
diff --git a/src/ui.cpp b/src/ui.cpp
index ead9d8c..64ebe92 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -437,10 +437,11 @@ namespace ui {
dialogOptCount--;
};
- dialogOptChosen=0;
+ dialogOptCount = 0;
+ dialogOptChosen = 0;
memset(&dialogOptLoc,0,sizeof(float)*12);
- if(opt){
+ if(opt != NULL){
soptbuf = new char[strlen(opt)+1];
strcpy(soptbuf,opt);
@@ -815,9 +816,12 @@ DONE:
case SDLK_RIGHT:
player->inv->sel++;
break;
- case SDLK_f:
+ case SDLK_l:
player->light^=true;
break;
+ case SDLK_f:
+ currentWorld->addLight({player->loc.x + SCREEN_WIDTH/2, player->loc.y},{1.0f,1.0f,1.0f});
+ break;
default:
break;
}
diff --git a/src/world.cpp b/src/world.cpp
index e97ec56..e66fb0d 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -669,7 +669,7 @@ LOOP2:
glActiveTexture(GL_TEXTURE0);
bgTex->bindNext();
- GLfloat pointArray[light.size()][2];
+ GLfloat pointArray[light.size() + (int)p->light][2];
for(uint w = 0; w < light.size(); w++){
pointArray[w][0] = light[w].loc.x - offset.x;
pointArray[w][1] = light[w].loc.y;
@@ -680,15 +680,18 @@ LOOP2:
glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0);
glUniform1f(glGetUniformLocation(shaderProgram, "amb"), float(shade+50.0f)/100.0f);
if(p->light){
- glUniform1i(glGetUniformLocation(shaderProgram, "numLight"), 1);
- glUniform2f(glGetUniformLocation(shaderProgram, "lightLocation"), p->loc.x - offset.x+SCREEN_WIDTH/2, p->loc.y);
- glUniform3f(glGetUniformLocation(shaderProgram, "lightColor"), 1.0f,1.0f,1.0f);
- }else if(!light.size()){
+ //glUniform1i(glGetUniformLocation(shaderProgram, "numLight"), 1);
+ //glUniform2f(glGetUniformLocation(shaderProgram, "lightLocation"), p->loc.x - offset.x+SCREEN_WIDTH/2, p->loc.y);
+ //glUniform3f(glGetUniformLocation(shaderProgram, "lightColor"), 1.0f,1.0f,1.0f);
+ pointArray[light.size()+1][0] = (float)(p->loc.x + SCREEN_WIDTH/2);
+ pointArray[light.size()+1][1] = (float)(p->loc.y);
+ }
+ if(light.size()+(int)p->light == 0){
glUniform1i(glGetUniformLocation(shaderProgram, "numLight"), 0);
}else{
- glUniform1i(glGetUniformLocation(shaderProgram, "numLight"), light.size());
- glUniform2fv(glGetUniformLocation(shaderProgram, "lightLocation"), light.size(), (GLfloat *)&pointArray);
- glUniform3f(glGetUniformLocation(shaderProgram, "lightColor"), 1.0f,1.0f,1.0f);
+ glUniform1i (glGetUniformLocation(shaderProgram, "numLight"), light.size()+(int)p->light);
+ glUniform2fv(glGetUniformLocation(shaderProgram, "lightLocation"), light.size()+(int)p->light, (GLfloat *)&pointArray);
+ glUniform3f (glGetUniformLocation(shaderProgram, "lightColor"), 1.0f,1.0f,1.0f);
}
glBegin(GL_QUADS);
@@ -770,11 +773,9 @@ LOOP2:
cline[i].y-=(yoff-DRAW_Y_OFFSET);
}
//glEnd();
- //glUseProgram(0);
+ glUseProgram(0);
glDisable(GL_TEXTURE_2D);
- //glUseProgram(0);
-
/*
* Draw non-structure entities.
*/
diff --git a/test.frag b/test.frag
index 0bb64a6..083fc0b 100644
--- a/test.frag
+++ b/test.frag
@@ -1,7 +1,8 @@
+#version 130
uniform sampler2D sampler;
uniform int numLight;
-uniform vec2 lightLocation[10];
+uniform vec2 lightLocation[255];
uniform vec3 lightColor;
uniform float amb;
diff --git a/xcf/player.xcf b/xcf/player.xcf
new file mode 100644
index 0000000..8815a08
--- /dev/null
+++ b/xcf/player.xcf
Binary files differ
diff --git a/xml/playerSpawnHill1.xml b/xml/playerSpawnHill1.xml
index c924d7e..5a0e51f 100644
--- a/xml/playerSpawnHill1.xml
+++ b/xml/playerSpawnHill1.xml
@@ -1,22 +1,39 @@
<?xml version="1.0"?>
<World>
<style background="0" bgm="assets/music/embark.wav" />
- <generation type="Random" width="500" />
+ <generation type="Random" width="2000" />
- <!--<mob type="1" x="250" y="100" />-->
+ <mob type="1" />
- <npc name="Ralph" x="0" y="100" hasDialog="true"/>
+ <npc name="Ralph" hasDialog="true" />
+ <npc name="Johnny" hasDialog="true" />
</World>
-<Dialog>
+<Dialog name="Ralph">
- <text name="Ralph" id="0" nextid="1">
+ <text id="0">
Hello there!
+ <option text="Hello" nextid="1" />
+ <option text="Frig" nextid="2" />
</text>
- <text name="Ralph" id="1">
- Lol
+ <text id="1">
+ gg.
</text>
+ <text id="2" call="Johnny" callid="1">
+ what you have done it to trick Microsoft
+ </text>
+
+</Dialog>
+
+<Dialog name="Johnny">
+ <text id="0" nextid="1" stop="true">
+ Sup bro!
+ </text>
+
+ <text id="1" >
+ My name's Johnny.
+ </text>
</Dialog>