void BoltItem::advance(int step) { if (!step || !this->isVisible()){return;} // Update QGraphicsItem's position and rotation from joint body 1. b2Vec2 position = bolt->_joint->GetAnchorA(); #ifndef QTOPIA setRotation(-(bolt->_joint->GetBodyA()->GetAngle() * 360.0) / (2 * PI)); #endif setPos(position.x, -position.y); //Calculate stress on the joint and break it if it's to much, Sad world... b2Vec2 rForce = bolt->_joint->GetReactionForce(1); if(rForce.x < 0){reactionForce += -rForce.x/10;} else {reactionForce += rForce.x/10;} if(rForce.y < 0){reactionForce += -rForce.y/10;} else {reactionForce += rForce.y/10;} reactionForce -= reactionForce/SHEER_FORCE; // qDebug() << "Reaction Force: " << reactionForce/SHEER_FORCE; if(reactionForce/SHEER_FORCE > 1200){ qDebug() << "Breaking Bolt to a reaction force of " << reactionForce/SHEER_FORCE; // delete this; destroyItem(); this->hide(); return; } }
void Destroy (List *L) { int i; ListNode *p, *q; p=L->first; for(i=0;i<L->size;i++) { q=p; p=p->next; destroyItem(&q->item); free(q); } }
void ContextMenu::destroyItem(MenuItem* i) { unsigned int count = 0; for(std::list<MenuItem*>::iterator it = mItems.begin(); it != mItems.end(); ++it) { if((*it) == i) { destroyItem(count); return; } ++count; } }
void Remove (int position, List *L) { ListNode *p, *q; if(position==0) { q=L->first; L->first=q->next; } else { p=moveTo(position-1,L); q=p->next; p->next=q->next; } destroyItem(&q->item); free(q); L->size--; }
int invCommands (player *playr){ char inp; printf("Equip : e\tDestroy : d\tUnequip : u\tExit : Anything else\n\n"); inp = getch(); if (inp == 'd'){ printf("Which Item Do You Want to Destroy?"); inp = getch(); if (inp != 27) destroyItem(inp-'a'); } else if (inp == 'e'){ printf("Which Item Do You Want to Equip?"); inp = getch(); if (inp != 27) equipItem(playr ,inp-'a'); } else if (inp == 'u'){ printf("Which Item Do You Want to UnEquip?"); inp = getch(); if (inp != 27) unEquipItem(playr ,inp-'a'); } return 1; }
void Dequeue (Queue *Q) { #ifdef DEBUG int oldSize=Size(Q); if(Empty(Q)) { printf("Violated precondition for Dequeue!\n"); exit(EXIT_FAILURE); } #endif destroyItem(&Q->items[Q->head]); Q->head++; if(Q->head >= MAXQUEUESIZE) Q->head = Q->head - MAXQUEUESIZE; Q->size--; #ifdef DEBUG if(Full(Q) || Size(Q)!=oldSize-1) { printf("Violated postcondition for Dequeue!\n"); exit(EXIT_FAILURE); } #endif }
void Remove (int position, List *L) { ListNode *p, *q; assert(position>=0); assert(position<=L->size); assert(Empty(L) == 0); if(position==0) { q=L->first; L->first=q->next; } else { p=moveTo(position-1,L); q=p->next; p->next=q->next; } destroyItem(&q->item); free(q); L->size--; assert(Full(L) == 0); assert(Size(L) == L->size+12); }
extern void Destroy (Queue *Q) { int i; for(i=0;i<Q->size;i++) destroyItem(&Q->items[i]); }
void Menu::destroyItem(MenuItem* i) { destroyItem(i->getIndex()); }