Sample5.rar

  • juunr95
    了解作者
  • C/C++
    开发工具
  • 137KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 0
    下载次数
  • 2021-03-03 12:34
    上传日期
This samples mix all other codes together to create a simple game based on network
Sample5.rar
  • Sample5
  • clientshell
  • clientshell.ncb
    49KB
  • chasecam.cpp
    5.5KB
  • cHud.cpp
    6.8KB
  • sample_clientshell.h
    890B
  • MusicSystem.h
    2.2KB
  • clientshell.dsw
    545B
  • clientshell.opt
    52.5KB
  • sample_clientshell.cpp
    6.4KB
  • clientshell.dsp
    4.6KB
  • clientshell.plg
    2.4KB
  • MusicSystem.cpp
    3.4KB
  • PlayerClient.H
    1.3KB
  • PlayerClient.CPP
    3.9KB
  • Chasecam.h
    1.6KB
  • cHud.h
    2.1KB
  • appended_clientshell
  • clientshell.ncb
    49KB
  • chasecam.cpp
    6.6KB
  • cHud.cpp
    6.8KB
  • sample_clientshell.h
    890B
  • MusicSystem.h
    2.2KB
  • clientshell.dsw
    545B
  • clientshell.opt
    52.5KB
  • sample_clientshell.cpp
    6.4KB
  • clientshell.dsp
    4.6KB
  • clientshell.plg
    2.4KB
  • MusicSystem.cpp
    3.4KB
  • PlayerClient.H
    1.3KB
  • PlayerClient.CPP
    3.9KB
  • Chasecam.h
    1.7KB
  • cHud.h
    2.1KB
  • release
  • cshell2.dll
    68KB
  • cshell.dll
    67.5KB
  • object.lto
    74.5KB
  • object
  • door.cpp
    7KB
  • sample_servershell.h
    392B
  • cpp_engineobjects_de.cpp
    642B
  • player.h
    552B
  • player.cpp
    5.6KB
  • object.dsw
    535B
  • sample_servershell.cpp
    2.2KB
  • object.dsp
    4.1KB
  • Door.h
    846B
内容介绍
// Door.cpp // Description // Source code that contains the implementation of a door object // Revisions // #include "de_server.h" #include "sample_servershell.h" #include "door.h" #include <stdio.h> float Abs(float val) { if (val < 0.0f) return (val * -1.0f); else return (val); } cDoor::cDoor() : BaseClass(OT_WORLDMODEL) { m_sndLastSound = DNULL; } cDoor::~cDoor() { CServerDE* pServerDE = GetServerDE(); if (m_sndLastSound) { pServerDE->KillSound(m_sndLastSound); m_sndLastSound = DNULL; } } DDWORD cDoor::EngineMessageFn(DDWORD messageID, void *pData, DFLOAT lData) { ObjectCreateStruct *pObjectCreateStruct; DVector temp1,ObjPos; DDWORD dwRet = BaseClass::EngineMessageFn(messageID, pData, lData); // See serverobj_de.h (near line 100) for descriptions of the messages. switch(messageID) { case MID_PRECREATE: { // As a general rule, it's best to use GetPropGeneric instead of // GetProp<type>, tempting as the shortcut may be. Generic props // are more flexible. GenericProp gProp; pObjectCreateStruct = (ObjectCreateStruct*)pData; // Read in the Door's Starting Current State if (GetServerDE()->GetPropGeneric("CurrentState",&gProp) == DE_OK) { m_eAction = (eDOORACTION)gProp.m_Long; } else { m_eAction = CLOSED; } // Get the Starting Position from the object if (GetServerDE()->GetPropGeneric("StartPosition",&gProp) == DE_OK) { VEC_COPY(m_StartPosition, gProp.m_Vec); } else { VEC_SET(m_StartPosition,0,0,0); } // Get the Ending Position from the object if (GetServerDE()->GetPropGeneric("EndPosition",&gProp) == DE_OK) { VEC_COPY(m_EndPosition, gProp.m_Vec); } else { VEC_SET(m_StartPosition,0,0,0); } GetServerDE()->CPrint("Creating the door object"); strcpy(pObjectCreateStruct->m_Filename, pObjectCreateStruct->m_Name); pObjectCreateStruct->m_SkinName[0] = '\0'; pObjectCreateStruct->m_Flags |= FLAG_TOUCH_NOTIFY | FLAG_GOTHRUWORLD | FLAG_BOXPHYSICS; break; } case MID_INITIALUPDATE: { DVector dims, temp1; // set the door's initial state m_eAction = CLOSED; GetServerDE()->SetNextUpdate(m_hObject, 0.1f); // get the actual Ending position GetServerDE()->GetObjectPos(m_hObject,&ObjPos); VEC_SUB(temp1,m_StartPosition,ObjPos); VEC_SUB(m_StartPosition,m_StartPosition,temp1); VEC_SUB(m_EndPosition,m_EndPosition,temp1); VEC_INIT(dims); VEC_INIT(temp1); // Tell Lithtech to update us pretty soon (give the doors a bit of a delay in opening. GetServerDE()->SetForceIgnoreLimit(m_hObject,1); GetServerDE()->CPrint("Initial Update of the door object"); break; } case MID_UPDATE: { // This is where we process what the door is doing. // Then register for another update.. switch (m_eAction) { case STILL: break; case CLOSED: break; case BEGINOPENING: // get the direction the Door needs to move VEC_SUB(m_Delta,m_StartPosition,m_EndPosition); // Make the delta ten divisons big VEC_DIVSCALAR(m_Delta,m_Delta,10); m_eAction = OPENING; PlaySound("Sounds\\Ambient\\Project.wav",DFALSE); break; case OPENING: // Set the Rotation for the object. GetServerDE()->GetObjectPos(m_hObject, &ObjPos); if ((0.1f > Abs(ObjPos.x - m_EndPosition.x)) && (0.1f > Abs(ObjPos.y - m_EndPosition.y)) && (0.1f > Abs(ObjPos.z - m_EndPosition.z))) { m_eAction=OPEN; } else { VEC_SUB(ObjPos,ObjPos,m_Delta); GetServerDE()->MoveObject(m_hObject,&ObjPos); } break; case OPEN: break; case BEGINCLOSING: // get the direction the Door needs to move VEC_SUB(m_Delta,m_EndPosition,m_StartPosition); // Make the delta ten divisons big VEC_DIVSCALAR(m_Delta,m_Delta,10); // GetServerDE()->SetObjectFlags(m_hObject,FLAG_VISIBLE | FLAG_SOLID | FLAG_TOUCH_NOTIFY); m_eAction = CLOSING; PlaySound("Sounds\\Ambient\\Project.wav",DFALSE); break; case CLOSING: // Set the Position for the object. GetServerDE()->GetObjectPos(m_hObject, &ObjPos); if ((0.1f > Abs(ObjPos.x - m_StartPosition.x)) && (0.1f > Abs(ObjPos.y - m_StartPosition.y)) && (0.1f > Abs(ObjPos.z - m_StartPosition.z))) { m_eAction=CLOSED; } else { VEC_SUB(ObjPos,ObjPos,m_Delta); GetServerDE()->MoveObject(m_hObject,&ObjPos); } break; case LOCKED: break; case UNLOCKED: break; } GetServerDE()->SetNextUpdate(m_hObject, 0.1f); break; } // This is called when another object touches this object. // pData is an HOBJECT for the other object. // fData is the collision (stopping) force (based on masses and velocities). case MID_TOUCHNOTIFY: { //Let's set the door ready to open or close if (m_eAction == OPEN) m_eAction=BEGINCLOSING; if (m_eAction == CLOSED) m_eAction = BEGINOPENING; GetServerDE()->SetNextUpdate(m_hObject, 0.001f); GetServerDE()->CPrint("The door object was touched"); break; } } // Pass the message on down. return dwRet; } void cDoor::PlaySound(char *szSoundName, DBOOL bLoop) { DVector m_vSoundPos; DFLOAT m_fSoundRadius = 100.0f; CServerDE* pServerDE = GetServerDE(); if (!pServerDE) return; // Stop the last sound if there is one... if (m_sndLastSound) { pServerDE->KillSound(m_sndLastSound); m_sndLastSound = DNULL; } if (!szSoundName) return; // Now get the position where we should play the sound pServerDE->GetObjectPos(m_hObject,&m_vSoundPos); PlaySoundInfo playSoundInfo; PLAYSOUNDINFO_INIT(playSoundInfo); playSoundInfo.m_dwFlags = PLAYSOUND_3D; // Set the position of the sound... VEC_COPY(playSoundInfo.m_vPosition, m_vSoundPos); if (bLoop) { playSoundInfo.m_dwFlags |= PLAYSOUND_LOOP | PLAYSOUND_GETHANDLE; } strncpy(playSoundInfo.m_szSoundName, szSoundName, _MAX_PATH); playSoundInfo.m_hObject = m_hObject; playSoundInfo.m_fOuterRadius = m_fSoundRadius; playSoundInfo.m_fInnerRadius = m_fSoundRadius * 0.5f; pServerDE->PlaySound(&playSoundInfo); // Save the handle of the sound... if (bLoop) { m_sndLastSound = playSoundInfo.m_hSound; } else { m_sndLastSound = DNULL; } } // Expose the Door class for DEdit. BEGIN_CLASS(cDoor) ADD_VISIBLE_FLAG(1, 0) ADD_SOLID_FLAG(1, 0) ADD_VECTORPROP(StartPosition) ADD_VECTORPROP(EndPosition) ADD_LONGINTPROP(Flags, FLAG_SOLID) ADD_LONGINTPROP(CurrentState,0) ADD_LONGINTPROP(Key,0) END_CLASS_DEFAULT_FLAGS(cDoor, BaseClass, NULL, NULL, 0)
评论
    相关推荐
    • ltsdk242.zip
      LithTech Engine SDK 242
    • New3DMax.zip
      LithTech Engine 3dsMax Plugin
    • 易语言-DXTC图片算法加预览工具
      可查看Lithtech引擎下的.Dtx缩率图文件 例如:CrossFire 的缩率图 血兆2 的缩率图 无人永生2 的缩率图 等等很多游戏缩率图查看...
    • FlipCode网络编程库源码
      patches are what's used to create curved surfaces in Quake III, LithTech 2.0 and all the other big engines today. I'm currently using them to draw the background grid but I have plans to make some ...
    • lithtechSDK.rar
      LT引擎SDK,老引擎了,包含一些基本接口
    • Sample3.rar
      Samepl cointaining simple server code for multiplayer base
    • Sample4.rar
      sample containing basic door code from lithtech
    • Sample2.rar
      Sample 2 cointaing basic use of Litehtech
    • Sample1.rar
      Sample containing basic use of Litehtech engine
    • snowglobe-src-viewer-2.0.0-r0.tar.gz
      国外的开源游戏引擎,能够承载上千人,属于社交类的游戏