diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2015-10-08 09:12:18 -0400 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2015-10-08 09:12:18 -0400 |
commit | c88533e59e961a029f6bb4777932434a9ca517f4 (patch) | |
tree | 96a384874d8e9f49becc989fcc535f8d511a0c34 /main.cpp | |
parent | 6e9eda2e22e79a90395387f4014c975044ea8d05 (diff) | |
parent | edf746b79c8646c2c21c04997d23c94c1ee8adcd (diff) |
merge
Diffstat (limited to 'main.cpp')
-rw-r--r-- | main.cpp | 27 |
1 files changed, 16 insertions, 11 deletions
@@ -21,6 +21,7 @@ Player *player; std::vector<Entity*>entity; std::vector<NPC>npc; std::vector<Structures *>build; +std::vector<Mob>mob; int mx, my; FILE* names; @@ -234,17 +235,21 @@ void logic(){ ui::handleEvents(); currentWorld->detect(player); for(int i=0;i<=entity.size();i++){ - if(entity[i]->alive&&entity[i]->type == NPCT){ - entity[i]->wander((rand()%120 + 30), &entity[i]->vel); - 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; - if(SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(SDL_BUTTON_RIGHT)){ - entity[i]->interact(); - std::cout <<"["<<i<<"] -> "<< 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]->alive){ + if(entity[i]->type == NPCT){ + entity[i]->wander((rand()%120 + 30), &entity[i]->vel); + 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; + if(SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(SDL_BUTTON_RIGHT)){ + entity[i]->interact(); + std::cout <<"["<<i<<"] -> "<< 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); } } } |