*
*/
-#define HLINE 4
+#define HLINE 3
/**
* A 'wrapper' for libc's srand(), as we hope to eventually have our own random number
Mix_Chunk *crickets;
-/*
- * names is used to open a file containing all possible NPC names. It is externally
- * referenced in src/entities.cpp for getting random names.
-*/
-
-std::istream *names;
-
/*
* loops is used for texture animation. It is believed to be passed to entity
* draw functions, although it may be externally referenced instead.
//glEnable(GL_DEPTH_TEST); //THIS DOESN'T WORK ON LINUX
glEnable(GL_MULTISAMPLE);
- /*
- * Open the names file containing potential names for NPCs and store it in the names file
- * pointer. This will be reference by getName in src/entities.cpp when NPCs are spawned.
- *
- */
-
- static std::filebuf fb;
- fb.open("assets/names_en-us",std::ios::in);
- names = new std::istream(&fb);
-
-
crickets=Mix_LoadWAV("assets/sounds/crickets.wav");
//Mix_Volume(2,25);
/*
* Create all the worlds, entities, mobs, and the player. This function is defined in
* src/gameplay.cpp
- *
- */
+ */
+
fadeIntensity = 250;
initEverything();
Mix_HaltMusic();
Mix_CloseAudio();
- fb.close();
-
destroyInventory();
ui::destroyFonts();
Texture::freeTextures();
unsigned int tempNum,max=0;
char *bufs;
- names->seekg(0,names->beg);
+ std::ifstream names ("assets/names_en-us",std::ios::in);
+
+ names.seekg(0,names.beg);
bufs = new char[32];
- for(;!names->eof();max++)
- names->getline(bufs,32);
+ std::cout<<"1\n";
+
+ for(;!names.eof();max++)
+ names.getline(bufs,32);
+
+ std::cout<<"2\n";
tempNum = rand() % max;
- names->seekg(0,names->beg);
+ names.seekg(0,names.beg);
for(unsigned int i=0;i<tempNum;i++)
- names->getline(bufs,32);
+ names.getline(bufs,32);
+
+ names.close();
switch(bufs[0]){
default :
}else if(!strcmp(name,"npc")){
const char *npcname;
-
+
if(wxml->QueryFloatAttribute("x",&spawnx) != XML_NO_ERROR)
tmp->addNPC(getRand() % tmp->getTheWidth() / 2.0f,100);
else
tmp->addNPC(spawnx,wxml->FloatAttribute("y"));
+
if((npcname = wxml->Attribute("name"))){
delete[] tmp->npc.back()->name;
tmp->npc.back()->name = new char[strlen(npcname) + 1];