Exemple #1
0
void Network::parseUserCommand(uint8_t *buff, int size)
{
	printf("user command received\n");

	movementCommand_t move;
	memcpy(&move, &buff[1], sizeof(move));

	int id;
	memcpy(&id, &buff[1 + sizeof(move)], sizeof(id));

	//name gathering
	char *name;
	name = (char *)&buff[1 + sizeof(move) + sizeof(id)];

	Bubble *b = new Bubble();

	Point pos;
	pos.x = move.x;
	pos.y = move.y;
	Point dir;
	dir.x = move.dirX;
	dir.y = move.dirY;
	std::string strName(name);

	b->setPos(pos);
	b->setDir(dir);
	b->setName(strName);
	b->setID(id);

	chatObject->addBubble(*b);	

	return;
}
Exemple #2
0
void PacientScene::createBubble()
{
    Bubble *bubble = new Bubble();
    bubble->setText("Write text here...");
    bubble->setPos(_lastMousePressPosition);
    addItem(bubble);

    bubble->changeText();
}
Exemple #3
0
void CglWnd::OnMouseMove( UINT fwKeys, int xPos, int yPos )
{
	//转换为Opengl的坐标系
	xPos = xPos - 240;
	yPos = 360 - yPos;
	if (m_bEdit)
	{
		for (int i = 0; i < MAX_BUBBLES; i++)
		{
			Bubble *b = &m_bubbles[i];
			if (b->eState == ST_EDIT_SHOW && b->bSelect)
			{
				b->setPos(b->ox + xPos - m_lastPosX, b->oy + yPos - m_lastPosY);
			}
		}
	}
	else
	{
		for (int i = 0; i < MAX_BUBBLES; i++)
		{
			Bubble *b = &m_bubbles[i];
			if (b->eState == ST_NORMAL && b->bSelect)
			{
				b->mx = xPos - b->ox;
				b->my = yPos - b->oy;
				int r2 = (b->mx*b->mx + b->my*b->my);
				int rr = b->r*0.6;
				if (r2 > rr*rr)
				{
					float scaleRate = rr/sqrt(r2);
					b->mx *= scaleRate;
					b->my *= scaleRate;
				}
			}
		}
	}

	m_lastPosX = xPos;
	m_lastPosY = yPos;
	
}