From bd80f4081451e6ef25b763d5f74891075936fdd0 Mon Sep 17 00:00:00 2001 From: drumsetmonkey Date: Tue, 13 Oct 2015 00:22:57 -0400 Subject: Documented things, updated DEBUG_printf() --- main.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index a220e2c..145df6e 100644 --- a/main.cpp +++ b/main.cpp @@ -107,6 +107,7 @@ int main(int argc, char *argv[]){ if( music == NULL ){ printf( "Failed to load beat music! SDL_mixer Error: %s\n", Mix_GetError() ); } + Mix_VolumeMusic(15); Mix_PlayMusic( music, -1 ); bgImage=loadTexture("assets/bg.png"); @@ -234,24 +235,28 @@ void render(){ void logic(){ ui::handleEvents(); currentWorld->detect(player); + //loops through whole entity stack for(int i=0;i<=entity.size();i++){ + //only loops through entities that are alive if(entity[i]->alive){ + //only loops through entities with type NPCT if(entity[i]->type == NPCT){ - entity[i]->wander((rand()%120 + 30), &entity[i]->vel); + entity[i]->wander((rand()%120 + 30), &entity[i]->vel); //makes the villager wander + //makes sure the entity is close to the player, and the mouse cursor is over the NPC if( pow((entity[i]->loc.x - player->loc.x),2) + pow((entity[i]->loc.y - player->loc.y),2) <= pow(40*HLINE,2)){ if(mx >= entity[i]->loc.x && mx <= entity[i]->loc.x + entity[i]->width && my >= entity[i]->loc.y && my <= entity[i]->loc.y + entity[i]->width){ - entity[i]->near=true; + entity[i]->near=true; //sets near to true so we can toggle names later if(SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(SDL_BUTTON_RIGHT)){ - entity[i]->interact(); + entity[i]->interact(); //interacts with the NPCS //std::cout <<"["< "<< entity[i]->name << ", " << (std::string)(entity[i]->gender == MALE ? "Male" : "Female") << std::endl; //Mix_PlayChannel( -1, horn, 0); } }else entity[i]->near=false; } }if(entity[i]->type == MOBT){ - entity[i]->wander(90,&entity[i]->vel); + entity[i]->wander((rand()%240 + 15),&entity[i]->vel); } } } loops++; -} +} \ No newline at end of file -- cgit v1.2.3