diff options
Diffstat (limited to 'main.cpp')
-rw-r--r-- | main.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
@@ -838,10 +838,16 @@ void logic(){ */ if(n->canMove) n->wander((rand() % 120 + 30)); - - if(player->inv->usingi && player->inv->detectCollision(vec2{n->loc.x, n->loc.y},vec2{n->loc.x+n->width,n->loc.y+n->height})){ + if(!player->inv->usingi) n->hit = false; + if(player->inv->usingi && !n->hit && player->inv->detectCollision(vec2{n->loc.x, n->loc.y},vec2{n->loc.x+n->width,n->loc.y+n->height})){ n->health -= 25; - currentWorld->addParticle(n->loc.x, n->loc.y, HLINE*3, HLINE*3, {255,0,0}); + n->hit = true; + for(int r = 0; r < (rand()%5);r++) + currentWorld->addParticle(rand()%HLINE*3 + n->loc.x - .05f,n->loc.y + n->height*.5, HLINE,HLINE, -(rand()%10)*.01,((rand()%4)*.001-.002), {(rand()%75+10)/100.0f,0,0}, 10000); + if(n->health <= 0){ + for(int r = 0; r < (rand()%30)+15;r++) + currentWorld->addParticle(rand()%HLINE*3 + n->loc.x - .05f,n->loc.y + n->height*.5, HLINE,HLINE, -(rand()%10)*.01,((rand()%10)*.01-.05), {(rand()%75)+10/100.0f,0,0}, 10000); + } } /* * Don't bother handling the NPC if another has already been handled. @@ -866,9 +872,7 @@ void logic(){ * considered legal. In other words, require the player to be close to * the NPC in order to interact with it. * - * This uses the Pythagorean theorem to check for NPCs within a certain - * radius (40 HLINEs) of the player's coordinates. - * + * This uses the Pythagorean theorem to check for NPCs within a certain * */ if(pow((n->loc.x - player->loc.x),2) + pow((n->loc.y - player->loc.y),2) <= pow(40*HLINE,2)){ @@ -928,7 +932,7 @@ void logic(){ if(ui::mouse.x >= o->loc.x && ui::mouse.x <= o->loc.x + o->width && ui::mouse.y >= o->loc.y && - ui::mouse.y <= o->loc.y + o->width ){ + ui::mouse.y <= o->loc.y + o->height ){ if(pow((o->loc.x - player->loc.x),2) + pow((o->loc.y - player->loc.y),2) <= pow(40*HLINE,2)){ /* @@ -948,6 +952,12 @@ void logic(){ } } } + for(auto &b : currentWorld->build){ + if(b->bsubtype == FOUNTAIN){ + for(int r = 0; r < (rand()%20)+10;r++) + currentWorld->addParticle(rand()%HLINE*3 + b->loc.x + b->width/2,b->loc.y + b->height, HLINE,HLINE, rand()%2 == 0?-(rand()%7)*.01:(rand()%7)*.01,((4+rand()%6)*.05), {0,0,1.0f}, 2500); + } + } /* * Switch between day and night (SUNNY and DARK) if necessary. |