示例#1
0
bool ItemView::on_button_release_event(GdkEventButton* event)
{
    if (isHit(event, rectClearNotification))
    {
        signal_item_button_clicked.emit(this, (int)BUTTON_ID_TOGGLE_NOTIFICATION);
        return true;
    }

    if (isSelected())
    {
        //test buttons
        if (isHit(event, rectBtnDelete))
        {
            signal_item_button_clicked.emit(this, (int)BUTTON_ID_DELETE);
        }
        else if (isHit(event, rectBtnEdit))
        {
            signal_item_button_clicked.emit(this, (int)BUTTON_ID_EDIT);
        }
        else
        {
            signal_item_selected.emit(this);
        }
    }
    else
    {
        signal_item_selected.emit(this);
    }

    return true;
}
示例#2
0
文件: mdllctr.cpp 项目: Jaxo/yaxx
/*------------------------------------------------------------------isValidEnd-+
| Determine if the current content model can be ended.                         |
|                                                                              |
| Try to find a way out from the model tree starting at the current token.     |
| Climb the tree up while setting the hit bits.  Then check the highest node.  |
|                                                                              |
| On Entry:                                                                    |
|   (no parameters)                                                            |
|                                                                              |
| When returning:                                                              |
|                                                                              |
|   Return code is: (see mdllctr.h for explanations)                           |
|                                                                              |
|     MDLLCTR_MISSING                                                          |
|     MDLLCTR_CLOSED                                                           |
|     MDLLCTR_UNCLOSABLE                                                       |
|     MDLLCTR_INTERNAL_ERROR  An internal error occurred.                      |
|                                                                              |
+-----------------------------------------------------------------------------*/
e_MdllctrStatus ModelLocator::isValidEnd()
{
   if (!pTknCurr || !mdl.isModel()) {         // model has ended, or it's Nil,
      return MDLLCTR_CLOSED;                  // or it's declared.  That's it
   }
   for (
      ModelToken const* pTknParent = pTknCurr;
      pTknParent = pTknParent->parent(), pTknParent;
      pTknCurr = pTknParent
   ) {
      if (pTknParent->isOrGroup()) {          // OR group is satisfied
         if (isHit(pTknCurr)) {               // if a token was hit
            hit(pTknParent);                  // turn on group hit bit
         }
      }else {                                 // and_group or seq_group
         if (isSome_hits(pTknParent)) {       // some were hit
            if (pTknParent->isAndGroup()) {
               pTknCurr = pTknParent->child;  // restart from beginning
            }
            if (find_first_required_sibling_unhit()) {  // required token...
               return find_missing_element();
            }
            hit(pTknParent);                  // turn on group hit bit
         }
      }
   }
   if ((isHit(pTknCurr)) || (pTknCurr->isOmissible())) {
      pTknCurr = 0;                           // group can be safely closed
      return MDLLCTR_CLOSED;                  // hit, or not but allowed to
   }
   if (pTknCurr->isOrGroup()) {
      return MDLLCTR_UNCLOSABLE;
   }
   return find_missing_element();             // MISSING or UNCLOSABLE
}
示例#3
0
void ButtonBase::updateInternalState(const Point& mouse_pos)
{
    // This code is rewritten and has a slightly different behaviour
    // it is no longer fully "correct", as overlapping windows will not be
    // considered if the widget is currently captured.
    // On the other hand it's alot faster, so I believe it's a worthy
    // tradeoff

    bool oldstate = d_hovering;

    // assume not hovering
    d_hovering = false;

    // if input is captured, but not by 'this', then we never hover highlight
    const Window* capture_wnd = getCaptureWindow();
    if (capture_wnd == 0)
    {
        System* sys = System::getSingletonPtr();
        if (sys->getWindowContainingMouse() == this && isHit(mouse_pos))
        {
            d_hovering = true;
        }
    }
    else if (capture_wnd == this && isHit(mouse_pos))
    {
        d_hovering = true;
    }

    // if state has changed, trigger a re-draw
    if (oldstate != d_hovering)
    {
        requestRedraw();
    }
}
示例#4
0
    bool MapCollideMgr::isHit( MapElement *elem, const cocos2d::Rect &aabb ) {
        MapTankVec &userTanks = m_map->getUserTanks();

        if (isHit(elem, aabb, userTanks)) {
            return true;
        } else {
            return isHit(elem, aabb, m_map->getEnemyTanks());
        }
    }
示例#5
0
void collisionDetection() {
	//Check if any bullets hit
	for (std::vector<Projectile>::iterator projectile = projectiles.begin(); projectile != projectiles.end();) {
		bool broken = false;
		for (std::vector<Enemy>::iterator enemy = enemies.begin(); enemy != enemies.end();) {
			if (isHit((*projectile).getBoundingBox(), (*enemy).getBoundingBox())) {
				enemy = enemies.erase(enemy);
				projectile = projectiles.erase(projectile);
				broken = true;
				break;
			}
			else {
				++enemy;
			}
		}
		if (!broken && isHit((*projectile).getBoundingBox(), boss.getBoundingBox())) {
			boss.hit();
			projectile = projectiles.erase(projectile);
			broken = true;
		}
		if (!broken) {
			projectile++;
		}
	}

	//Check if anything went outside the viewport
	for (std::vector<Enemy>::iterator enemy = enemies.begin(); enemy != enemies.end();) {
		if ((*enemy).getBoundingBox()[1][0] < topLeft[0]) {
			enemy = enemies.erase(enemy);
		}
		else {
			++enemy;
		}
	}
	Entity viewport = Entity();
	viewport.height = H_fen;
	viewport.width = W_fen;
	for (std::vector<Projectile>::iterator projectile = projectiles.begin(); projectile != projectiles.end();) {
		if (!isHit((*projectile).getBoundingBox(), viewport.getBoundingBox())) {
			projectile = projectiles.erase(projectile);
		}
		else {
			++projectile;
		}
	}

	//Check if the player didn't hit an enemy
	for (std::vector<Enemy>::iterator enemy = enemies.begin(); enemy != enemies.end();) {
		if (isHit(character.getBoundingBox(), (*enemy).getBoundingBox())) {
			enemy = enemies.erase(enemy);
			// Do some logic here
		}
		else {
			++enemy;
		}
	}
}
示例#6
0
//-----------------------------------------------
INT AflSpriteScroll::hitTest(FLOAT fX,FLOAT fY)
{
	if(isHit(&m_rectScrollBar,fX,fY))
		return AFL_HIT_SCROLLBAR;
	if(isHit(&m_rectScroll1,fX,fY))
		return AFL_HIT_SCROLL1;
	if(isHit(&m_rectScroll2,fX,fY))
		return AFL_HIT_SCROLL2;
	return AflSpriteWnd::hitTest(fX,fY);

}
示例#7
0
//-----------------------------------------------
INT AflSpriteWnd::hitTest(FLOAT fX,FLOAT fY)
{
	if(!isHit(&m_rectWindow,fX,fY))
		return AFL_HIT_NO;
	if(isHit(&m_rectSize,fX,fY))
		return AFL_HIT_SIZE;
	if(isHit(&m_rectTitle,fX,fY))
		return AFL_HIT_TITLE;
	if(isHit(&m_rectClient,fX,fY))
		return AFL_HIT_CLIENT;
	return AFL_HIT_FRAME;
}
示例#8
0
文件: mdllctr.cpp 项目: Jaxo/yaxx
/*-----------------------------------------------------------------isSome_hits-+
| Return true if tokens where hit in the current model group                   |
+-----------------------------------------------------------------------------*/
inline bool ModelLocator::isSome_hits(ModelToken const* pTkn) const
{
   for (pTkn = pTkn->child; !isHit(pTkn); pTkn = pTkn->sibling) {
      if (pTkn->isYounger()) return false;
   }
   return true;
}
示例#9
0
// 弾情報更新
void update_shot(void)
{
	int i, j;

	// 全ての弾について、現在位置を更新した後
	// 衝突判定を行い、衝突している弾を殺す。
	// *** 弾が当たっている場合は、何かフラグでも立てた方がいいかな?(得点計算的に)
	// *** 描画関数は呼び出さなくていいんだよね? <- いいよ
	calcShotPosAll();
	for(i=0; i<NUM_OF_SHOTS; i++){
		// 衝突判定は、生きている弾についてのみ行う
		if(shot[i].alive != 0){
			for(j=0; j<p_character; j++){
				if(isHit(&shot[i], &character[j]) == 1 && character[j].alive){
                    // 衝突した!!
					if (character[j].score == 10 || character[j].score == 50)
                    	score += character[j].score; // スコア加算
					else 
                    	score += 10; // スコア加算
                    //printf("HIT!!!  score = %d\n", score);
                    character[j].alive = 0; // キャラクタ死亡
					shot[i].alive= 0; // 弾死亡
                    used_shots++;
				}
			}
		}
	}

}
示例#10
0
文件: mdllctr.cpp 项目: Jaxo/yaxx
/*--------------------------------------------------find_another_and_candidate-+
| Find out if another token could be a candidate in an AND group, or, if not,  |
| if the group can be safely closed.                                           |
|                                                                              |
| On Entry:                                                                    |
|   `pTknCurr'     points the current token (as returned by previous calls     |
|                  to this routine, or initialized to the first AND token)     |
|   `pTokenParent' is `pTknCurr's parent                                       |
|   `isCurrentHit' indicates if `pTknCurr' was just hit                        |
|                                                                              |
| When returning:                                                              |
|                                                                              |
|   Return code is:                                                            |
|     true:  another candidate was found                                       |
|     false: no other candidate                                                |
|                                                                              |
|   `pTknCurr' is:                                                             |
|   - NULL pointer:  no other candidate, but the  group can be safely closed   |
|   - A valid ModelToken pointer:                                              |
|     - if true is returned, this is the new candidate                         |
|     - if false is returned, this is the first required token that prevents   |
|                             the group to be closed                           |
|                                                                              |
| IMPLEMENTATION NOTES:                                                        |
|                                                                              |
| In an AND group, no more token can be a candidate if all tokens, including   |
| optionals, were hit.                                                         |
|                                                                              |
| AND groups are tricky to handle, especially to avoid infinite loops and      |
| not to miss any.                                                             |
|                                                                              |
| Here is the way this is done:                                                |
|                                                                              |
| 1) At the time the token is hit: (isCurrentHit is true)                      |
|   a- if it is repeatable, find_candidate() returns early and this code       |
|      is not reached for this time.                                           |
|   b- if it is not repeatable, this code is called: it will restart the       |
|      scanning in the AND group to the first unhit token (from the            |
|      beginning).  This token will no more be a candidate.                    |
|   Return.                                                                    |
|                                                                              |
| 2) If isCurrentHit is false,                                                 |
|   a - if the AND token hit bit is on, this token was a repeatable token      |
|       left as current by 1)a-.  Since isCurrentHit is false, it is safe      |
|       to declare this token no more a candidate: restart the scanning        |
|       of the AND group from the beginning to the next unhit token.           |
|       Return.                                                                |
|   b - Else, if a next sibling is unhit, make it a new candidate.             |
|       Return.                                                                |
|   c - If no more sibling, it's definitively INVALID.                         |
|       Return.                                                                |
|                                                                              |
| Again, this algorithm ensures the AND list wont be examined twice,           |
| and that all candidate tokens are returned one after each other.             |
| Because, 1) the list is restarted one time only (when the token              |
| was hit, or later if it's a repeatable token), and 2) it restarts            |
| from the beginning so we wont miss any.                                      |
+-----------------------------------------------------------------------------*/
bool ModelLocator::find_another_and_candidate(
   ModelToken const* pTknParent, bool const isCurrentHit
)
{
   if ((isCurrentHit) || (isHit(pTknCurr))) {
      pTknCurr = pTknParent->child;            // restart from the elder
      if (find_first_optional_sibling_unhit()) {
         return true;                          // new candidate
      }
      pTknCurr = 0;                            // good: no more candidates!
      return false;                            // but group can be closed
   }else {
      if (!pTknCurr->isYounger()) {            // more siblings
         pTknCurr = pTknCurr->sibling;         // start at next unhit sibling
         if (find_first_optional_sibling_unhit()) {
            return true;                       // new candidate
         }
      }
      /*
      | All AND tokens have been examined.
      | See if we could end the group by
      | now skipping over optional tokens...
      */
      pTknCurr = pTknParent->child;            // re-scan from the beginning
      if (find_first_required_sibling_unhit()) {
         return false;                         // required
      }
      pTknCurr = 0;                            // group can be closed!
      return false;
   }
}
示例#11
0
//updates gary the ghost to move about
void updateGary() {

	speed += acceleration;
	gary.xPos += speed;
	
	if(isHit())
		endGame();
	
}
示例#12
0
文件: mdllctr.cpp 项目: Jaxo/yaxx
/*---------------------------------------------------find_another_or_candidate-+
| Find out if another token could be a candidate in an OR group, or, if not,   |
| if the group can be safely closed.                                           |
|                                                                              |
| On Entry:                                                                    |
|   `pTknCurr'  points the current token (as returned by previous calls        |
|               to this routine, or initialized to the first OR token)         |
| When returning:                                                              |
|                                                                              |
|   Return code is:                                                            |
|     true:  another candidate was found                                       |
|     false: no other candidate                                                |
|                                                                              |
|   `pTknCurr' is:                                                             |
|   - NULL pointer:  no other candidate, but the  group can be safely closed   |
|   - A valid ModelToken pointer: this is the new candidate                    |
|                                                                              |
| In an OR group, no more token can be a candidate if current token was hit.   |
| This occurs at the time the token is hit (isCurrentHit is true) when it is   |
| non repeatable, or when looking for a match and the token was a repeatable   |
| token hit previously.                                                        |
|                                                                              |
| The next valid token is the next sequential one.                             |
| It is not a no-sibling token, or OR group would have ended                   |
+-----------------------------------------------------------------------------*/
inline bool ModelLocator::find_another_or_candidate()
{
   if (isHit(pTknCurr)) {
      pTknCurr = 0;                       // group can be safely closed
      return false;                       // there are no more candidates
   }else {
      pTknCurr = pTknCurr->sibling;
      return true;                        // one more candidate
   }
}
bool ofxUIDraggableLabelButton::mousePressed(ofMouseEventArgs &e)
{
    if(isHit(e.x,e.y))
    {
        isDraggedOut = false;
        saveX = e.x - posX;
        saveY = e.y - posY;
        onPressed = true;
        return true;
    }
}
示例#14
0
// check distance between dots and mark them as exploded if too close
void Cube::collisionCheck() {
    for (uint8_t i=0; i<dot_n; i++)
        if (not vid.sprites[i].isHidden() && !dots[i].exp)
            for (uint8_t j=i+1; j<dot_n; j++)
                if (not vid.sprites[j].isHidden() && !dots[i].exp)  {
                    Float2 dif = dots[i].pos - dots[j].pos;
                    // are the dots too close ?
                    if (dif.len2() < SPR_size.len2()/4) {
                        dots[i].pos -= dif/2; // bring dots closer
                        dots[j].pos += dif/2; // to each other
                        dots[i].exp = exploDuration;
                        dots[j].exp = exploDuration;
#if ACCURATE == 1
                        // use a binary map to check if we hit or miss Conan:
                        dots[i].bnd = isHit(dots[i].pos);
                        dots[j].bnd = isHit(dots[j].pos);
#else
                        // ...or use a FlatAssetImage but it's less accurate:
                        Float2 o = SPR_size/2; // offset to sprite center
                        uint16_t linPosI = uint16_t( (dots[i].pos.x+o.x)/8 ) +
                                           uint16_t( (dots[i].pos.y+o.y)/8 ) *
                                           ConanIMG.tileWidth() ;
                        uint16_t linPosJ = uint16_t( (dots[j].pos.x+o.x)/8 ) +
                                           uint16_t( (dots[j].pos.y+o.y)/8 ) *
                                           ConanIMG.tileWidth() ;
                        // D'oh! need band aid ?
                        dots[i].bnd = (ConanIMG.tile(linPosI) != whiteTile);
                        dots[j].bnd = (ConanIMG.tile(linPosJ) != whiteTile &&
                                       linPosJ  != linPosI);
#endif
                        // D'oh! need band aid ?
                        if (dots[i].bnd)
                            lifeCounter -= 5;
                        if (dots[j].bnd)
                            lifeCounter -= 5;
                    }
                }

    if (lifeCounter <= 0)
        win();
}
示例#15
0
文件: mdllctr.cpp 项目: Jaxo/yaxx
/*-------------------------------------------find_first_required_sibling_unhit-+
| ... and return true if found                                                 |
+-----------------------------------------------------------------------------*/
inline bool ModelLocator::find_first_required_sibling_unhit()
{
   for (;;) {
      if ((!isHit(pTknCurr)) && (!pTknCurr->isOmissible())) {
         return true;
      }
      if (pTknCurr->isYounger()) {
         return false;
      }
      pTknCurr = pTknCurr->sibling;
   }
}
示例#16
0
 bool Button::vTouchBegan(const Touch &touch) {
     if (!_pTouch) {
         if (isHit(-_extLeft, -_extTop, _w+_extRight, _h+_extBottom, touch.x, touch.y)) {
             _pTouch = &touch;
             if (_pCallback) {
                 _pCallback->vDown(this);
             }
             return true;
         }
     }
     return false;
 }
示例#17
0
文件: mdllctr.cpp 项目: Jaxo/yaxx
/*-------------------------------------------find_first_optional_sibling_unhit-+
| ... and return true if found                                                 |
+-----------------------------------------------------------------------------*/
inline bool ModelLocator::find_first_optional_sibling_unhit()
{
   for (;;) {
      if (!isHit(pTknCurr)) {
         return true;
      }
      if (pTknCurr->isYounger()) {
         return false;
      }
      pTknCurr = pTknCurr->sibling;
   }
}
示例#18
0
 bool Button::vTouchEnded(const Touch &touch) {
     if (_pTouch == &touch) {
         _pTouch = NULL;
         if (isHit(-_extLeft, -_extTop, _w+_extRight, _h+_extBottom, touch.x, touch.y)) {
             if (_pCallback) {
                 _pCallback->vClick(this);
             }
             return true;
         }
     }
     return false;
 }
示例#19
0
/*************************************************************************
	Handler for mouse movement events
*************************************************************************/
void ComboDropList::onMouseMove(MouseEventArgs& e)
{
	Listbox::onMouseMove(e);

	// if mouse is within our area (but not our children)
	if (isHit(e.position))
	{
		if (!getChildAtPosition(e.position))
		{
			// handle auto-arm
			if (d_autoArm)
			{
				d_armed = true;
			}

			if (d_armed)
			{
				//
				// Convert mouse position to absolute window pixels
				//
				Point localPos(CoordConverter::screenToWindow(*this, e.position));

				// check for an item under the mouse
				ListboxItem* selItem = getItemAtPoint(localPos);

				// if an item is under mouse, select it
				if (selItem)
				{
					setItemSelectState(selItem, true);
				}
				else
				{
					clearAllSelections();
				}

			}
		}

		e.handled = true;
	}
	// not within the list area
	else
	{
		// if left mouse button is down, clear any selection
		if (e.sysKeys & LeftMouse)
		{
			clearAllSelections();
		}

	}

}
示例#20
0
文件: mdllctr.cpp 项目: Jaxo/yaxx
/*--------------------------------------------------find_another_seq_candidate-+
| Find out if another token could be a candidate in an SEQ group, or, if not,  |
| if the group can be safely closed.                                           |
|                                                                              |
| On Entry:                                                                    |
|   `pTknCurr'  points the current token (as returned by previous calls        |
|               to this routine, or initialized to the first SEQ token)        |
| When returning:                                                              |
|                                                                              |
|   Return code is:                                                            |
|     true:  another candidate was found                                       |
|     false: no other candidate                                                |
|                                                                              |
|   `pTknCurr' is:                                                             |
|   - NULL pointer:  no other candidate, but the  group can be safely closed   |
|   - A valid ModelToken pointer:                                              |
|     - if true is returned, this is the new candidate                         |
|     - if false is returned, this is the first required token that prevents   |
|                             the group to be closed                           |
|                                                                              |
| In an SEQ group, no more token can be a candidate if current token           |
| is the last and was either hit, or is omittable.                             |
| The next valid token is the next sequential one.                             |
| It is not an no-sibling token, or SEQ group would have ended                 |
+-----------------------------------------------------------------------------*/
bool ModelLocator::find_another_seq_candidate()
{
   if ((pTknCurr->isOmissible()) || (isHit(pTknCurr))) {
      if (pTknCurr->isYounger()) {        // last token?
         pTknCurr = 0;                    // group can be safely closed
         return false;                    // there are no more candidates
      }else {
         pTknCurr = pTknCurr->sibling;    // here is the candidate
         return true;
      }
   }else {
      return false;                       // sorry: pTknCurr is required
   }
}
示例#21
0
/*************************************************************************
	Handler for mouse movement events
*************************************************************************/
void ComboDropList::onMouseMove(MouseEventArgs& e)
{
	Listbox::onMouseMove(e);

	// if mouse is within our area (but not our children)
	if (isHit(e.position))
	{
		if (!getChildAtPosition(e.position))
		{
			// handle auto-arm
			if (d_autoArm)
			{
				d_armed = true;
			}

			if (d_armed)
			{
				// check for an item under the mouse
				ListboxItem* selItem = getItemAtPoint(e.position);

				// if an item is under mouse, select it
				if (selItem)
				{
					setItemSelectState(selItem, true);
				}
				else
				{
					clearAllSelections();
				}

			}
		}

		++e.handled;
	}
	// not within the list area
	else
	{
		// if left mouse button is down, clear any selection
		if (e.sysKeys & LeftMouse)
		{
			clearAllSelections();
		}

	}

}
bool ofxUIDraggableLabelButton::mouseDragged(ofMouseEventArgs &e)
{
    if(isHit(e.x, e.y)) // mouse dragged inside
    {
        if(!onPressed) return false;
        posX = e.x - saveX;
        posY = e.y - saveY;
    }
    else //mouse dragged outside
    {
        if(!onPressed) return false;
        isDraggedOut = true;
        posX = e.x - saveX;
        posY = e.y - saveY;
    }
    setPos(posX, posY);
    return onPressed;
}
示例#23
0
/*************************************************************************
	Handler for cursor movement events
*************************************************************************/
void ComboDropList::onCursorMove(CursorInputEventArgs& e)
{
    ListWidget::onCursorMove(e);

    // if cursor is within our area (but not our children)
	if (isHit(e.position))
	{
		if (!getChildAtPosition(e.position))
		{
			// handle auto-arm
			if (d_autoArm)
			{
				d_armed = true;
			}

			if (d_armed)
			{
                // check for an item under the cursor
                StandardItem* item = d_itemModel.getItemForIndex(indexAt(e.position));

                // if an item is under cursor, select it
                if (item != 0)
                {
                    setIndexSelectionState(item, true);
                }
                else
                {
                    clearSelections();
                }
			}
		}

		++e.handled;
	}
	// not within the list area
	else
	{
		// if left cursor is held, clear any selection
		if (e.state.isHeld(CIS_Left))
		{
            clearSelections();
		}
	}
}
示例#24
0
文件: Source.cpp 项目: chari8/Tetris
void store() {
	if (!buff) {
		buff = true;
		b_minoT = minoType;
		b_minoA = minoAngle;
		memcpy(minobuff, minoShapes[minoType][minoAngle], sizeof(minoShapes[minoType][minoAngle]));
		resetMino();
	}
	else {
		if (!isHit(minoX, minoY, b_minoT, b_minoA)) {
			int T = b_minoT, A = b_minoA;
			memcpy(minobuff, minoShapes[minoType][minoAngle], sizeof(minoShapes[minoType][minoAngle]));
			b_minoT = minoType;
			b_minoA = minoAngle;
			minoType = T;
			minoAngle = A;
		}
	}
}
示例#25
0
/*************************************************************************
    Handler for cursor pressed events
*************************************************************************/
void ComboDropList::onCursorPressHold(CursorInputEventArgs& e)
{
    ListWidget::onCursorPressHold(e);

    if (e.source == CIS_Left)
	{
		if (!isHit(e.position))
		{
            clearSelections();
			releaseInput();
		}
		else
		{
			d_armed = true;
		}

		++e.handled;
	}
}
示例#26
0
/*************************************************************************
	Handler for mouse button pressed events
*************************************************************************/
void ComboDropList::onMouseButtonDown(MouseEventArgs& e)
{
	Listbox::onMouseButtonDown(e);

	if (e.button == LeftButton)
	{
		if (!isHit(e.position))
		{
			clearAllSelections();
			releaseInput();
		}
		else
		{
			d_armed = true;
		}

		++e.handled;
	}

}
示例#27
0
NEPHILIM_NS_BEGIN

bool UIScrollBar::onEventNotification(Event& event)
{
	if (event.type == Event::MouseButtonPressed && isHit(vec2(event.mouseButton.x, event.mouseButton.y)))
	{
		// Drag start
		draggingBar = true;
		lastMouse = event.getPointerPosition();
	}
	else if (event.type == Event::MouseButtonReleased)
	{
		draggingBar = false;
	}
	else if (event.type == Event::MouseMoved && draggingBar)
	{
		// Move the paddle in local space, that movement is then translated back to a scrolling factor in the view

		vec2i currMouse = event.getPointerPosition();
		vec2i offset = lastMouse - currMouse;
		lastMouse = currMouse;

		paddleOffset += -offset.y;

		if (paddleOffset <= 0.f)
			paddleOffset = 0.f;

		if (paddleOffset + paddleHeight >= size.y)
			paddleOffset = size.y - paddleHeight;

		Log("paddle offset %f", paddleOffset);

		if (linkedView)
		{
			float scrollToWidgetRatio = linkedView->childrenRect().height / height();
			linkedView->scrolling_offset.y = -paddleOffset * scrollToWidgetRatio;
		}
	}

	return true;
}
示例#28
0
QPointF Ball::calculateNewPos(int x)
{
    double newX=x+moveByX,newY;
    double midw=viewWidth/2;

    newY=(newX-midw)*(newX-midw)/randHeight;

    if(isNotPositionIn(newX, newY, viewWidth, viewHeight)) {
        randHeight=(qrand()%500)+100;
        setBrush(Qt::blue);

        if(isHit()){
            emit increasePoint(300);
            setHit(false);
        }
        //Rest Position
        return QPointF(20,newY);

    }
    return QPointF(newX,newY);
}
示例#29
0
// 弾情報更新
void update_shot(void)
{
	int i, j;

	// 全ての弾について、現在位置を更新した後
	// 衝突判定を行い、衝突している弾を殺す。
	// *** 弾が当たっている場合は、何かフラグでも立てた方がいいかな?(得点計算的に)
	// *** 描画関数は呼び出さなくていいんだよね? <- いいよ
	calcShotPosAll();
	for(i=0; i<p_shot; i++){
		// 衝突判定は、生きている弾についてのみ行う
		if(shot[i].alive != 0){
			for(j=0; j<p_character; j++){
				if(isHit(&shot[i], &character[j]) == 1){
					shot[i].alive= 0;
				}
			}
		}
	}

}
示例#30
0
void Fire::Update()
{
	m_basePosition += m_speed;

	//接触判定
	//当たったプレイヤーのisHitItemフラグをtrue
	//当たったアイテムのisActiveフラグをfalseにする

	for (unsigned int i = 0; i < CharacterManager::GetInstance()->GetCharacterNumber(); i++)
	{

		if (isHit(CharacterManager::GetInstance()->m_character[i]->m_transform.GetPosition())){

			oka::SoundManager::GetInstance()->Play("slipSE");
			m_isActive = false;
			CharacterManager::GetInstance()->m_character[i]->m_isHitItem = true;
			CharacterManager::GetInstance()->m_character[i]->m_transform.SetRotationZ(0.0f);
			CharacterManager::GetInstance()->m_character[i]->m_crashRotate = 360000.f*(M_PI / 180);

		}
	}

	for (int i = 0; i < FIRE_PARTICLE_NUMBER; i++)
	{
		m_particle[i].m_alpha -= 0.025f;

		m_particle[i].m_transform.SetScale(m_particle[i].m_transform.GetScale()+0.04f);

		m_particle[i].m_transform.GetPosition() += m_particle[i].m_speed*m_particle[i].m_alpha;

		if (m_particle[i].m_alpha <= 0.f){
			m_particle[i].m_alpha = (float)rand() / RAND_MAX;
			m_particle[i].m_transform.SetScale(oka::Vec3(0.0f, 0.0f, 0.0f));

			m_particle[i].m_speed.m_x = ((float)rand() / RAND_MAX - 0.5)*0.01f;//-0.05から0.05の値
			m_particle[i].m_speed.m_y = (((float)rand() / RAND_MAX - 0.5)*.5) *.04;
			m_particle[i].m_speed.m_z = ((float)rand() / RAND_MAX - 0.5)*0.01f;//-0.05から0.05の値;
		}
	}
}