Exemple #1
0
void Face::update()
{
	//Issue where neither paddle nor ball are accessible
	if (paddle != NULL && ball != NULL)
	{
		paddle->getComponent<Physics>()->velocity = glm::vec3(0, 0, 0);
		if (isControlDown("left"))
		{
			if (paddle->transform->position.x > -0.4)
				paddle->getComponent<Physics>()->velocity = glm::vec3(-0.01, 0, 0);
		}

		if (isControlDown("right"))
		{
			if (paddle->transform->position.x < 0.4)
				paddle->getComponent<Physics>()->velocity = glm::vec3(0.01, 0, 0);
		}
/*
		if (ball->getComponent<Collider>()->checkCollision(paddle))
		{
			ball->getComponent<Physics>()->velocity = glm::vec3(ball->getComponent<Physics>()->velocity.x, -ball->getComponent<Physics>()->velocity.y, 0);
		}
*/
		paddle->transform->position += paddle->getComponent<Physics>()->velocity;
		ball->transform->position += ball->getComponent<Physics>()->velocity;
	}
	
}
bool BaseKeyboardState::readKey(Common::Event *event) {
	//_currentPrintable = (event->type == SDL_TEXTINPUT); // TODO
	_currentCharCode = keyCodeToVKey(event);
	// Verify that this is a printable ISO-8859-character (including the upper charset)
	if ((_currentCharCode <= 0x7E && _currentCharCode >= 0x20) || (_currentCharCode <= 0xFF && _currentCharCode >= 0xA0)) {
		_currentPrintable = true;
	} else {
		_currentPrintable = false;
	}
	//_currentKeyData = KeyData;

	_currentControl = isControlDown();
	_currentAlt     = isAltDown();
	_currentShift   = isShiftDown();

	return STATUS_OK;
}
bool BaseKeyboardState::readKey(Common::Event *event) {
	//_currentPrintable = (event->type == SDL_TEXTINPUT); // TODO
	_currentCharCode = keyCodeToVKey(event);
	if ((_currentCharCode <= Common::KEYCODE_z && _currentCharCode >= Common::KEYCODE_a) ||
	        (_currentCharCode <= Common::KEYCODE_9 && _currentCharCode >= Common::KEYCODE_0) ||
			(_currentCharCode == Common::KEYCODE_SPACE)) {
		_currentPrintable = true;
	} else {
		_currentPrintable = false;
	}
	//_currentKeyData = KeyData;

	_currentControl = isControlDown();
	_currentAlt     = isAltDown();
	_currentShift   = isShiftDown();

	return STATUS_OK;
}
bool BaseKeyboardState::readKey(Common::Event *event) {
	//_currentPrintable = (event->type == SDL_TEXTINPUT); // TODO
	_currentCharCode = keyCodeToVKey(event);
	// convert all lowercase keys to uppercase to make it easier for handling later on for consistency
	if (Common::isLower(_currentCharCode) && (event->kbd.hasFlags(Common::KBD_SHIFT) || event->kbd.flags & Common::KBD_CAPS)) {
		if (!(event->kbd.keycode >= Common::KEYCODE_F1 && event->kbd.keycode <= Common::KEYCODE_F12)) {
			_currentCharCode = toupper(_currentCharCode);
		}
	}
	// Verify that this is a printable ISO-8859-character (including the upper charset)
	if ((_currentCharCode <= 0x7E && _currentCharCode >= 0x20) || (_currentCharCode <= 0xFF && _currentCharCode >= 0xA0)) {
		_currentPrintable = true;
	} else {
		_currentPrintable = false;
	}
	//_currentKeyData = KeyData;

	_currentControl = isControlDown();
	_currentAlt     = isAltDown();
	_currentShift   = isShiftDown();

	return STATUS_OK;
}
Exemple #5
0
void CUIEditorView::OnMouseMove(UINT nFlags, CPoint point)
{
	g_CoreSystem.getCEGUISystem()->injectMousePosition(point.x, point.y);

	if( !getShowMode() ) return;

	//如果是创建窗口的过程
	if (getCreateWindowFlag())
	{
		//创建了窗口,那么改变他的大小
		if (m_pCreatedWindow)
		{
			//setWindowSelected(m_pCreatedWindow->getName().c_str());
			m_nResponseType = BRP_CREATE_NEW_WINDOW_QUAD;
		}
		SetCursor(m_BorderResponse[BRP_CREATE_NEW_WINDOW_QUAD].cursor);
	}
	else
	{
		//如果按住了CTRL那么鼠标移动的时候选择窗口
		if ( isControlDown() && getShowMode() )
		{
			CEGUI::Window* mouseWindow = g_CoreSystem.getCEGUISystem()->getWindowContainingMouse();
			if (mouseWindow)
			{
				setWindowSelected(mouseWindow->getName(),false);
			}
		}
		//检测鼠标感应
		if ( !m_bProcessing )
		{
			m_nResponseType = BRP_INVALID;
			for (INT i=0; i<BRP_NUM; i++)
			{
				if( m_BorderResponse[i].hoverRect.PtInRect(point) )
				{
					SetCursor(m_BorderResponse[i].cursor);
					m_nResponseType = (BorderResponsePos)i;
					break;
				}
			}
		}
	}

	//处理拖动和改变查看大小的操作
	if (m_lButtonDown)
	{
		if(m_nResponseType == BRP_SELECT_WINDOW_MIDDLE_MIDDLE_QUAD)
		{
			while( ShowCursor(FALSE) > 0 );
		}
		SetCursor(m_BorderResponse[m_nResponseType].cursor);
		setProcessing(true);
		processMoveAndSizing(point);
	}

	//显示鼠标位置
	CHAR szMouseText[MAX_PATH] = {0};
	sprintf(szMouseText, "鼠标(%d,%d)",point.x, point.y);
	((CMainFrame*)AfxGetMainWnd())->SetStatusText(1,szMouseText);

	updateCurrentOperationStatusText();

	SetFocus();

	CView::OnMouseMove(nFlags, point);
	
}