cleandata:
rm -rf xml/*.dat
+ rm -rf storyXML/*.dat
$(EXEC): $(CXXOUTDIR)/$(CXXOBJ) main.cpp
@echo " CXX/LD main"
<currency name="George Washington" value="25" sprite="assets/items/coin2.png"/>
<currency name="Barack Hussein Obama" value="100" sprite="assets/items/coin3.png"/>
-<item name="Debug" type="Tool" maxStackSize="1" width="1" height="1" sprite="assets/items/ITEM_TEST.png" />
-<item name="Dank MayMay" type="Tool" maxStackSize="420" width="10" height="10" sprite="assets/items/ITEM_TEST.png" />
-<item name="Your Bag" type="Equip" maxStackSize="1" width="5" height="5" sprite="assets/items/ITEM_TEST.png" />
-<item name="Flashlight" type="Tool" maxStackSize="1" width="4" height="8" sprite="assets/items/flashlight_off.png" />
-<item name="Wood Sword" type="Sword" damage="69" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Debug" type="Tool" value="10" maxStackSize="1" width="1" height="1" sprite="assets/items/ITEM_TEST.png" />
+<item name="Dank MayMay" type="Tool" value="10" maxStackSize="420" width="10" height="10" sprite="assets/items/ITEM_TEST.png" />
+<item name="Your Bag" type="Equip" value="32" maxStackSize="1" width="5" height="5" sprite="assets/items/ITEM_TEST.png" />
+<item name="Flashlight" type="Tool" value="1" maxStackSize="1" width="4" height="8" sprite="assets/items/flashlight_off.png" />
+<item name="Wood Sword" type="Sword" value="69" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Fried Chicken" type="Cooked Food" value="10" maxStackSize="6" width="4" height="6" sprite="assets/items/FOOD_CHICKEN_FRIED.png" />
+
<item name="Wood Sword2" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
<item name="Wood Sword3" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
<item name="Wood Sword4" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
#undef near
#endif
+//#define SEGFAULT
+
/**
* This flag lets the compiler know that we want to use shaders.
*/
#define initRand(s) srand(s)
+
+
/**
* A 'wrapper' for libc's rand(), as we hope to eventually have our own random number
* generator.
*/
#define DEBUG_printf( message, ...) DEBUG_prints(__FILE__, __LINE__, message, __VA_ARGS__ )
-#define C(x) std::cout << x << std::endl;
-
+void C(std::string m);
/**
* Defines pi for calculations that need it.
*/
float width;
float height;
int maxStackSize;
+ float attribValue;
std::string texloc;
Texturec *tex;
Menu optionsMenu;
Menu pauseMenu;
+std::string xmlFolder;
+
extern WorldWeather weather;
extern int fadeIntensity; // ui.cpp
* textures for the entities and stuff.
*/
- if(!(IMG_Init(IMG_INIT_PNG) & IMG_INIT_PNG)){
+ if(!(IMG_Init(IMG_INIT_PNG) & IMG_INIT_PNG) | !(IMG_Init(IMG_INIT_JPG) & IMG_INIT_JPG)){
std::cout << "Could not init image libraries! Error: " << IMG_GetError() << std::endl;
return -1;
}
fadeIntensity = 250;
+ std::cout << "emem" << std::endl;
initEverything();
+ std::cout << "meme" << std::endl;
if(!currentWorld){
std::cout<<"currentWorld == NULL!"<<std::endl;
#endif // __WIN32__
+void C(std::string m){
+ #ifdef SEGFAULT
+ std::cout << m << std::endl;
+ #else
+ (void)m;
+ #endif
+}
+
void DEBUG_prints(const char* file, int line, const char *s,...){
va_list args;
printf("%s:%d: ",file,line);
extern float VOLUME_MUSIC;
extern float VOLUME_SFX;
+extern std::string xmlFolder;
+
XMLDocument xml;
XMLElement *scr;
XMLElement *vol;
VOLUME_SFX = fval;
else VOLUME_SFX = 50;
+ xmlFolder = xml.FirstChildElement("world")->Attribute("start");
+ if(xmlFolder=="\0")xmlFolder = "xml/";
+ std::cout << "Folder: " << xmlFolder << std::endl;
+
ui::initFonts();
ui::setFontFace(xml.FirstChildElement("font")->Attribute("path"));
config::update();
Player::Player(){ //sets all of the player specific traits on object creation
width = HLINE * 10;
- height = HLINE * 15;
+ height = HLINE * 16;
type = PLAYERT; //set type to player
subtype = 0;
void Player::sspawn(float x,float y){
unsigned int i;
uint count;
- std::ifstream in ("xml/main.dat",std::ios::in | std::ios::binary);
+ std::ifstream in ("storyXML/main.dat",std::ios::in | std::ios::binary);
spawn(x,y);
if(in.good()){
extern Menu pauseMenu;
extern Menu optionsMenu;
+extern std::string xmlFolder;
+
extern void mainLoop(void); // main.cpp
extern std::vector<NPC *> AIpreaddr; // entities.cpp
return 0;
}
-void commonPageFunc( Mob *callee )
-{
+void commonPageFunc( Mob *callee ){
static bool lock = false;
if ( !lock ) {
* Read the XML directory into an array.
*/
- if(getdir("./xml/",xmlFiles)){
+ C("Scanning XML directory");
+ if(getdir(std::string("./"+xmlFolder).c_str(),xmlFiles)){
std::cout<<"Error reading XML files!!!1"<<std::endl;
abort();
}
+ C("Done scanning XML directory");
/*
* Sort the files alphabetically.
*/
+ C("Sorting XML files alphabetically");
strVectorSortAlpha(&xmlFiles);
+ C("Dpne sorting XML files alphabetically");
+
/*
* Load the first file found as currentWorld.
/*
* Read in the XML file.
*/
-
+ C("Setting current XML file");
+ std::cout << "File to load: " << xmlFiles[i] << std::endl;
currentWorld = loadWorldFromXML(xmlFiles[i]);
+ C("Done setting current XML file");
break;
}
}
static float hangle = 0.0f;
static bool swing = false;
static vec2 itemLoc;
-static const unsigned int numSlot = 2000;
+static const unsigned char numSlot = 7;
Mix_Chunk* swordSwing;
static std::vector<Item *> itemMap;
while(exml){
itemMap.push_back(new Item());
+
itemMap.back()->width = exml->FloatAttribute("width") * HLINE;
itemMap.back()->height = exml->FloatAttribute("height") * HLINE;
itemMap.back()->maxStackSize = exml->UnsignedAttribute("maxstack");
+ itemMap.back()->attribValue = exml->FloatAttribute("value");
+
itemMap.back()->name = exml->Attribute("name");
itemMap.back()->type = exml->Attribute("type");
}
void Inventory::draw(void){
+ C("Inventory Start Draw");
static unsigned int lop = 0;
static std::vector<int>dfp(numSlot);
static std::vector<Ray>iray(numSlot);
unsigned int a = 0;
static bool end = false;
static vec2 mouseStart = {0,0};
+ C("End define");
for(auto &r : iray){
r.start.x = player->loc.x + (player->width/2);
* a = 0
*/
+ C("Start drawing inventory");
if(invOpen){
for(auto &mr : massRay){
}
a++;
}
+ C("Done drawing standard inv");
}else if(invHover){
static unsigned int highlight = 0;
static unsigned int thing = 0;
}
}
}else hangle = 0.0f;
+ if(p->inv->usingi){
+ p->inv->useItem();
+ std::cout << "using" << std::endl;
+ }
glUseProgram(shaderProgram);
glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0);
swing=true;
Mix_PlayChannel(2,swordSwing,0);
}
+ }else if(itemMap[items[sel].id]->type == "Cooked Food"){
+ player->health += itemMap[items[sel].id]->attribValue;
+ usingi = false;
}
}
return 0;
xc += float(i) * cos((hangle+90)*PI/180);
yc += float(i) * sin((hangle+90)*PI/180);
- /*glColor4f(1.0f,1.0f,1.0f,1.0f);
- glBegin(GL_LINES);
- glVertex2f(player->loc.x,player->loc.y+player->height/3);
- glVertex2f(xc,yc);
- glEnd();*/
-
if(xc >= one.x && xc <= two.x){
if(yc >= one.y && yc <= two.y){
return true;
extern unsigned int tickCount; // main.cpp
+extern std::string xmlFolder;
+
int worldShade = 0;
std::string currentXML;
if ( b->inside.empty() )
return this;
- inside.push_back(currentXML.c_str() + 4);
+ inside.push_back(currentXML.c_str() + xmlFolder.size());
tmp = loadWorldFromXML( b->inside );
}
}
} else {
- current = currentXML.c_str() + 4;
+ current = currentXML.c_str() + xmlFolder.size();
tmp = loadWorldFromXML( inside.back() );
for ( auto &b : tmp->build ) {
if ( current == b->inside ) {
std::string save,data,line;
const char *filedata;
- save = (std::string)currentXML + ".dat";
+ //std::cout << "Loading from: " << std::string(currentXML + ".dat") << std::endl;
+ save = std::string(currentXML + ".dat");
+ //std::cout << "save file: " << save << std::endl;
filedata = readFile(save.c_str());
data = filedata;
std::istringstream iss (data);
static bool loadedRight = false;
World *loadWorldFromXML(std::string path){
+ C("Scanning for save file");
+ std::cout << "Scanning: " << path << std::endl;
if ( !currentXML.empty() )
currentWorld->save();
+ std::cout << "After Scanning: " << path << std::endl;
+ C("Done scanning for save file");
return loadWorldFromXMLNoSave(path);
}
if ( path.empty() )
return NULL;
- currentXML = (std::string)"xml/" + path;
+ std::cout << "File path: " << path << std::endl;
+ currentXML = std::string("storyXML/" + path);
+ std::cout << "Full file path: " << currentXML << std::endl;
xml.LoadFile(currentXML.c_str());
wxml = xml.FirstChildElement("World");
tmp->load();
}
+ std::cout << "adadadadasdsa" << std::endl;
+
return tmp;
}
<npc name="Ralph" hasDialog="true" />
<npc name="Johnny" hasDialog="false" />
+ <npc name="Big Dave" hasDialog="true"/>
<page x="-200" id="assets/pages/gootaGoFast.png" />
Broooooooooooooo...
</text>
</Dialog>
+
+<Dialog name="Big Dave">
+ <text id="0" pause="true">
+ Here have this sword!
+ <give id="Wood Sword" count="1"/>
+ <give id="Fried Chicken" count="1"/>
+ </text>
+</Dialog>