[WIP}NEW SDK SAMPLE : AppCppDemoNetwork

Share your creations, demos, games and movies

[WIP}NEW SDK SAMPLE : AppCppDemoNetwork

Postby Ezee » Wed Apr 13, 2016 6:17 am

Hi .
As i'm working on the network side of OgreKit , i managed to create a demo that will implement network .
The purpose is to show how to create a server or client app , and transmit gameObjects position changes ( to begin ...)
I use MSVC9 , so i provide a solution to use this demo .
Setup :
Configure CMake to use Enet , disable Unity Build !
I choosed to follow the Ogre3d file system management for paths , so you will have to declare two global var in your system's environment :
$(GameKitLIBS) (example : D:\GAMEKITLOCAL\BUILD\Bin\lib )
$(GameKitDEPS) (example : D:\GAMEKITLOCAL\BUILD\Dependencies\Source )

The demo ( WIP ) is here : https://github.com/Ezeer/gamekit/commit ... 3af1dd3b1f

I will use that thread to show the work in progress .
You can submit your ideas , wishes etc ... you could help .
;)

Task list :

_ Create a setup for Joystick(s)
_ Create a simple chat
_ implement a new NetPlayer ( class ? )
_ Implement game modes : Capture the banana , FreeForAll , CocoBomb etc ...
...
Ezee
 
Posts: 27
Joined: Sat Apr 02, 2016 9:52 pm

Re: [WIP}NEW SDK SAMPLE : AppCppDemoNetwork

Postby Ezee » Fri Apr 15, 2016 1:59 pm

Nice update !
I have made a simple communication framework :
Code: Select all
/// FRAMEWORK :
   ///Client ask to join a game first .
   ///When he receives clearance and when successfully loaded the level
   // he sends a JOINED status , the server then spawn the client in his scene
   /// while the client do the same for the server player .


At startup , the client ask to join :
Code: Select all
...
...
//Setup everything. Ogre, gk etc.
   eng.initialize();


   if (!eng.isInitialized())
   {
      gkPrintf("CppDemo: failed to initialize engine.\n");
      return 1;
   }

   {
      gkGameLevel game;
      
      switch(prefs.networkType)
   {
    case SERVER:
       game.loadLevel(GK_LEVEL_PICKUP);break;
     //client must request to join before loading
    case CLIENT:if(!game.canJoin)
             {
                gkNetworkManager::getSingletonPtr()->sendMessage("gkGameLevel","server","JOIN",REQUEST_JOIN);
                   while(!game.canJoin)
                {printf("Waiting for server acceptance ...\n");}
                 game.loadLevel(GK_LEVEL_PICKUP);
                  break;
             }
...
...
            


the clearance finish by a spawn of the client in the server scene :
Code: Select all
 //   client or server behavior
   switch(NetType)
   {
    case SERVER:
       switch(subject)
         {
            //JOIN
             case 0:
              //BODY READ
              //case REQUEST_JOIN
              if(message->m_body.compare(REQUEST_JOIN)==0)
              {
               gkNetworkManager::getSingletonPtr()->sendMessage("server","gkGameLevel","JOIN",CLEARANCE_JOIN);
                 break;
              }
               //case DONE_JOIN
              if(message->m_body.compare(DONE_JOIN)==0)
              {
                 //add the player
                 spawn();
               break;
              }
         }break;


client side of the code :
Code: Select all
case CLIENT:switch(subject)
         {
            //JOIN
            case 0://BODY READ
              if(message->m_body.compare(CLEARANCE_JOIN)==0)
              {
                 canJoin=true;
                   break;
              }
              break;

          case 1:break;
         }break;


I have defined some generic messages to use in that protocol:
Code: Select all
#define REQUEST_JOIN "request_join"
#define CLEARANCE_JOIN "clearance_join"
#define DONE_JOIN "done_join"


I will do the same for the chat mode , etc ...

Actually tested with 3 instances of the program on a single pc , works .
( but the movement update is not implemented yet , nor the animations states .
The relative commit is here : https://github.com/Ezeer/gamekit/commit ... 0144a7dafe
;)
Ezee
 
Posts: 27
Joined: Sat Apr 02, 2016 9:52 pm

WIPNEW SDK SAMPLE AppCppDemoNetwork

Postby ThomasTedsmall » Mon Dec 26, 2016 4:06 am

I have so many sample ideas, but I'm not good enough to produce them. :
ThomasTedsmall
 
Posts: 2
Joined: Thu Dec 15, 2016 6:07 pm
Location: Belize


Return to Showcase

Who is online

Users browsing this forum: No registered users and 1 guest

cron