本文整理汇总了C++中PacketStream::writeFloat方法的典型用法代码示例。如果您正苦于以下问题:C++ PacketStream::writeFloat方法的具体用法?C++ PacketStream::writeFloat怎么用?C++ PacketStream::writeFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketStream
的用法示例。
在下文中一共展示了PacketStream::writeFloat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SendMyCarData
void Game::SendMyCarData()
{
PacketStream PS;
//===================== send data ==================================
ENUM_Event e = STATEDATA;
PS.writeInt(e);
// write the xy values to the stream
PS.writeFloat(m_pMyCar->X());
PS.writeFloat(m_pMyCar->Y());
// write the angle of rotation to the stream
PS.writeFloat(m_pMyCar->GetAngleY());
// write the direction and topspeed variables to the stream
PS.writeFloat(m_pMyCar->DirectionX());
PS.writeFloat(m_pMyCar->DirectionY());
PS.writeFloat(m_pMyCar->TopSpeed());
PS.writeFloat(m_pMyCar->Speed());
PS.writeFloat(m_pMyCar->Friction());
e = ENDOFMESSAGE;
PS.writeInt(e);
// get the data from the stream
char data[100];
PS.toCharArray(data);
// send the data
Net::GetInstance()->SendData(data,"127.0.0.1",m_sendToPort);
// update the time of the packet sent - for interpolate
m_lastPacketSentTime = GetTickCount();
// increment the number of packets sent
m_numPacketsSent++;
//===================================================================
}
示例2: update
//.........这里部分代码省略.........
}
}
else if(type == Constants::DESTROY) {
int id;
pStream->readInt(id);
mLevel->killEnemy(id);
}
else if(type == Constants::DESTROYPICKUP) {
int id;
pStream->readInt(id);
mLevel->destroyPickup(id);
}
else if(type == Constants::CREATEPICKUP) {
int type, x, y, id;
pStream->readInt(type);
pStream->readInt(id); // Clients sends -1
pStream->readInt(x);
pStream->readInt(y);
mLevel->createPickup(type, x, y);
if(mHost) {
// Send create to peer
// Send Id of created pickup
PacketStream s;
s.writeInt(Constants::CREATEPICKUP);
s.writeInt(mLevel->getPickups().back()->getID());
s.writeInt(type);
s.writeFloat(x);
s.writeFloat(y);
s.writeChar('\0');
char message[10];
s.toCharArray(message);
message[strlen(message)-1] = '\0';
s3eSocketSendTo(mSock, message, strlen(message), 0, &mDest_addr);
}
else {
// Set id of pickup if client if client
mLevel->getPickups().back()->setID(id);
}
}
else if(type == Constants::CREATECRATE) {
int type, id;
float x, y;
//pStream->readInt(id);
pStream->readInt(type);
pStream->readFloat(x);
pStream->readFloat(y);
if(mHost) {
mLevel->createCrate(type, x, y);
crateSpawned = true;
PacketStream s;
s.writeInt(Constants::CREATECRATE);
//s.writeInt(mLevel->getCrates().back()->getID());
s.writeInt(type);