aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/entities.cpp12
-rw-r--r--src/inventory.cpp50
-rw-r--r--src/ui.cpp10
3 files changed, 12 insertions, 60 deletions
diff --git a/src/entities.cpp b/src/entities.cpp
index 1e6fad5..3286784 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -339,18 +339,14 @@ void NPC::interact(){ //have the npc's interact back to the player
}
}
-extern void waitForDialog(void);
-void Object::interact(void){
+void Object::interact(void){
if(questObject && alive){
-
ui::dialogBox("You",":Yes:No",pickupDialog);
- while(ui::dialogBoxExists);
-
- if(ui::dialogOptChosen == 1 && alive){
+ ui::waitForDialog();
+ if(ui::dialogOptChosen == 1){
player->inv->addItem((ITEM_ID)(identifier), (char)1);
alive = false;
- return;
- }
+ }
}else{
alive = false;
player->inv->addItem((ITEM_ID)(identifier), (char)1);
diff --git a/src/inventory.cpp b/src/inventory.cpp
index e67f031..a365204 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -41,7 +41,6 @@ Inventory::Inventory(unsigned int s){
size=s;
inv = new struct item_t[size];
memset(inv,0,size*sizeof(struct item_t));
- tossd=false;
for(int i = 0;i<ITEM_COUNT;i++){
itemtex[i]=Texture::loadTexture(getItemTexturePath((ITEM_ID)i));
}
@@ -162,29 +161,16 @@ void Inventory::draw(void){
lop++;
}
-static vec2 item_coord = {0,0};
-static vec2 item_velcd = {0,0};
-static bool item_tossd = false;
-static bool yes=false;
-
void itemDraw(Player *p,ITEM_ID id){
- static vec2 p1,p2;
if(!id)return;
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,itemtex[id]);
- if(!yes){
- p1 = {p->loc.x+p->width/2,
- p->loc.y+p->width/2+HLINE*3};
- p2 = {(float)(p1.x+p->width*(p->left?-.5:.5)),
- p->loc.y+HLINE*3};
- }
- if(p->inv->tossd) yes=true;
glColor4ub(255,255,255,255);
glBegin(GL_QUADS);
- glTexCoord2i(0,1);glVertex2f(item_coord.x+p->loc.x, item_coord.y+p->loc.y);
- glTexCoord2i(1,1);glVertex2f(item_coord.x+item[id].width+p->loc.x, item_coord.y+p->loc.y);
- glTexCoord2i(1,0);glVertex2f(item_coord.x+item[id].width+p->loc.x, item_coord.y+item[id].height+p->loc.y);
- glTexCoord2i(0,0);glVertex2f(item_coord.x+p->loc.x, item_coord.y+item[id].height+p->loc.y);
+ glTexCoord2i(0,1);glVertex2f(p->loc.x, p->loc.y);
+ glTexCoord2i(1,1);glVertex2f(p->loc.x+item[id].width,p->loc.y);
+ glTexCoord2i(1,0);glVertex2f(p->loc.x+item[id].width,p->loc.y+item[id].height);
+ glTexCoord2i(0,0);glVertex2f(p->loc.x, p->loc.y+item[id].height);
glEnd();
glDisable(GL_TEXTURE_2D);
}
@@ -202,31 +188,3 @@ int Inventory::useItem(void){
return 0;
}
-int Inventory::itemToss(void){
- if(!item_tossd && item[sel].count && item[sel].id){
- item_tossd = true;
- item_coord.x = HLINE;
- item_velcd.x = 0;
- item_velcd.y = 3;
- tossd = true;
- return 1;
- }else if(item_tossd){
- if(item_coord.y<0){
- memset(&item_coord,0,sizeof(vec2));
- memset(&item_velcd,0,sizeof(vec2));
- item_tossd = false;
-
- takeItem(item[sel].id,1);
-
- tossd = yes = false;
-
- return 0;
- }else{
- item_coord.x += item_velcd.x;
- item_coord.y += item_velcd.y;
- //item_velcd.x -= .005;
- item_velcd.y -= .1;
- return 1;
- }
- }
-}
diff --git a/src/ui.cpp b/src/ui.cpp
index a37a97c..e10ed46 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -514,12 +514,14 @@ namespace ui {
}
}
void handleEvents(void){
- unsigned char i;
static bool left=false,right=false;
static vec2 premouse={0,0};
+ unsigned char i;
SDL_Event e;
+
mouse.x=premouse.x+offset.x-(SCREEN_WIDTH/2);
mouse.y=(offset.y+SCREEN_HEIGHT/2)-premouse.y;
+
while(SDL_PollEvent(&e)){
switch(e.type){
case SDL_QUIT:
@@ -602,9 +604,7 @@ DONE:
player->ground=false;
}
}
- if(SDL_KEY==SDLK_q){
- player->inv->itemToss();
- }
+
if(SDL_KEY==SDLK_LSHIFT)player->speed = debug?4:3; // Sprint
if(SDL_KEY==SDLK_LCTRL)player->speed = .5;
}
@@ -632,8 +632,6 @@ DONE:
}
}
- if(player->inv->tossd)player->inv->itemToss();
-
if(!dialogBoxExists&&AIpreaddr.size()){ // Flush preloaded AI functions if necessary
for(i=0;i<AIpreaddr.size();i++){
AIpreaddr.front()->addAIFunc(AIpreload.front(),false);