diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2016-04-05 08:48:29 -0400 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2016-04-05 08:48:29 -0400 |
commit | 16920d744a2e638f564753f15f1269f51c131b6b (patch) | |
tree | ae3ee1ba2b2f7a92c196347853e0c82e2dd14973 /src/inventory.cpp | |
parent | 4ea7b19bf2d4c64719471a53e6223aac7c250585 (diff) |
sword improvements, page threading
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r-- | src/inventory.cpp | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp index 14ccfd06..521b695 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -522,6 +522,8 @@ void Inventory::draw(void){ } void itemDraw(Player *p,uint id){ + static unsigned char inc = 0; + itemLoc.y = p->loc.y+(p->height/3); itemLoc.x = p->left?p->loc.x:p->loc.x+p->width; glPushMatrix(); @@ -540,9 +542,16 @@ void itemDraw(Player *p,uint id){ p->inv->usingi = false; } } - }else hangle = 0.0f; + } else + hangle = 0; + if ( p->inv->usingi ) + inc = 10; + + if ( inc ) { + inc--; p->inv->useItem(); + } glUseProgram(shaderProgram); glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0); @@ -564,25 +573,31 @@ void itemDraw(Player *p,uint id){ glUseProgram(0); } -int Inventory::useItem(void){ +int Inventory::useItem( void ) +{ static bool up = false; - if(!invHover){ - - if(itemMap[items[sel].id]->type == "Sword"){ - - if(swing){ - if(!player->left){ - if(hangle==-15){up=true;Mix_PlayChannel(2,swordSwing,0);} - if(up)hangle-=.75*deltaTime; - if(hangle<=-90)hangle=-14; - }else{ - if(hangle==15){up=true;Mix_PlayChannel(2,swordSwing,0);} - if(up)hangle+=.75*deltaTime; - if(hangle>=90)hangle=14; + + if ( !invHover ) { + if ( itemMap[items[sel].id]->type == "Sword" ) { + if ( swing ) { + int dir = player->left ? 1 : -1; + + if ( hangle == 15 * dir ) { + up = true; + Mix_PlayChannel( 2, swordSwing, 0 ); } - }else if(!swing){ - swing=true; - Mix_PlayChannel(2,swordSwing,0); + + if ( up ) + hangle += 0.325f * dir * deltaTime; + + if ( !player->left ) { + if ( hangle <= -90 ) + hangle = -14; + } else if ( hangle >= 90 ) + hangle = 14; + } else { + swing = true; + Mix_PlayChannel( 2, swordSwing, 0 ); } }else if(itemMap[items[sel].id]->type == "Cooked Food"){ player->health += itemMap[items[sel].id]->attribValue; @@ -601,7 +616,6 @@ bool Inventory::detectCollision(vec2 one, vec2 two){ if(items.empty() || !items[sel].count) return false; if(itemMap[items[sel].id]->type == "Sword"){ - std::cout<<"Collision???"<<std::endl; while(i<itemMap[items[sel].id]->height){ xc = itemLoc.x; yc = itemLoc.y; xc += float(i) * cos((hangle+90)*PI/180); |