From 897802f67d502c070eac0c14b43113d521a711ef Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Thu, 3 Dec 2015 20:06:19 -0500 Subject: fixed sounds --- src/entities.cpp | 4 ++-- src/gameplay.cpp | 3 ++- src/world.cpp | 24 +++++++++++++++--------- 3 files changed, 19 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/entities.cpp b/src/entities.cpp index a2bff3c..729bcdd 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -376,14 +376,14 @@ unsigned int Structures::spawn(_TYPE t, float x, float y){ unsigned int tempN = (getRand() % 5 + 2); - while(--tempN){ + for(unsigned int i = 0;i < tempN;i++){ /* * This is where the entities actually spawn. A new entity is created * with type NPC. */ - currentWorld->addNPC(loc.x + (tempN - 5),100); + currentWorld->addNPC(loc.x + i * HLINE ,100); } diff --git a/src/gameplay.cpp b/src/gameplay.cpp index f54c607..b4c4b16 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -71,6 +71,7 @@ void initEverything(void){ test->generate(SCREEN_WIDTH*2); test->setBackground(BG_FOREST); + test->setBGM("assets/music/embark.wav"); test->addHole(100,150); test->addLayer(400); @@ -115,7 +116,7 @@ void initEverything(void){ * Spawn some entities. */ - playerSpawnHill->addStructure(STRUCTURET,(rand()%120*HLINE),10,test,iw); + playerSpawnHill->addStructure(STRUCTURET,(rand()%120*HLINE),100,test,iw); playerSpawnHill->addMob(MS_TRIGGER,-1300,0,CUTSCENEEE); playerSpawnHill->addObject(SWORD_WOOD, false, "", 480,200); diff --git a/src/world.cpp b/src/world.cpp index ff4c461..5f8d44c 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -65,6 +65,7 @@ void World::load(FILE *s){ World::World(void){ bgm = NULL; + bgmObj = NULL; /* * Nullify pointers to other worlds. @@ -286,24 +287,29 @@ void World::update(Player *p,unsigned int delta){ void World::setBGM(const char *path){ if(!bgm) delete[] bgm; - if(!path){ + //if(!path){ bgm = new char[strlen(path) + 1]; strcpy(bgm,path); bgmObj = Mix_LoadMUS(bgm); - if(!bgmObj){ - std::cout<<"Failed to load song file "<