Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: a solution to develop multiply players game by WME  (Read 3962 times)

0 Members and 1 Guest are viewing this topic.

yaobifeng

  • Lurker
  • *
  • Karma: 1
  • Offline Offline
  • Gender: Male
  • Posts: 24
    • View Profile
a solution to develop multiply players game by WME
« on: August 14, 2008, 07:17:40 AM »

I use WME developed a  multiply players game.The server use JAVA +Tomcat+ SQL SERVER2000.player can login the server,chating each other,also can upon the game data to  server and query reports from server.player can see others moving,speaking in himself's client.here is the screenshot:
multiply player:

user login:

regist user:

scene1:

scene2:

scene3:


  • game background:    
        This is a business  simulation RPG game,players(3-6 players) set up some  companies,each play acts a duty such as CEO,CFO,CTO and so on.
    Each company will receive a sum of money at the first,then every need to do lots of things:hire office,buy productlines,invite employees,buy materials,design and develop new products,sell products........., all of the companies will compete each other.
  • game frame
        I decided to use WME to finish the game client.of course the game need a server program(i use java write some struts actions and use tomcat to run it,game data was stored into the sql server2000).
  • network
        The WME client program can connect to the JAVA web server?yeah,it seems impossible if we only use itself's ability.so we use delphi writen a DLL file.There is some functions in the DLL,one of them called http_get(url,result),ok,now we can call it in the game script by follow  steps:
    1.declare the dll function in the base.script:
    external "gui.dll" int http_get(string,string);//arg1:http url address;arg2:return value
    2.we can call it like this:
    var rt=new String(100);
    http_get("http://www.dead-code.ogr/test.jsp?arg=1&arg=2&arg=3...",rt);

    we send our client program's data by arg=1&arg=2&arg=3...,and the server will return the result in variable  rt,our server sometime return a XML string and sometime return a split string(ex:"123#456#abc#def").
    we call DLL  function to  parse XML string and call WEM's String.Split(..) to parse split string.String.By the way,String.Split(..) has  more high performace than DLL XML function.
  • GUI
        The WME itself's GUI is not strong,we use jsp web page(html,css,javascript....) to  implemented  most of the windows,the WME client open this page by call the DLL function http_webbrowser(url).This solution cause our game can only run in the window mode.........,but i think it's worthwhile.
  • multiply player
         client  side
        Our WME Client  store the players in a global array:
        actors["tom"]=Game.LoadActor3D("actors\....\p.act3d");
        We can get every actor by their name:
        var act=actors["tom"];
        server side
        We have a table to store all player's location,scene....,each WME Client  need to report it's latest status and  get the players list from server  at a certain time rate(such as every 100ms),

    var rt=new String(2000);
    http_get("http://...../LoginAction.do?p0=9&p1="+courseid+"&p2="+companyid+"&p3="+studentid+"&scene="+Scene.Name+"&actor="+actor.Name+"&x="+actor.X+"&y="+actor.Y,rt);   

    by parasing the string rt. our client program can know how many actors are online,each one's location,scene,who are speaking,speaking what.....
  • others
    how to display a custom text on the head of the actor?
    do it in the actor's script like this:

    var WinSubtitles;
    var tiptitle;
    while(1)
    {
    if(WinSubtitles==null)
    {
    WinSubtitles = Game.CreateWindow("subtitles_window");
    //WinSubtitles.SetImage("interface\bst\actor_card.tga");
    }
    if(tiptitle==null)
    {
    tiptitle= WinSubtitles.CreateStatic("speaker_name");
    tiptitle.SizeToFit();
    tiptitle.SetFont("fonts\arial_Í·²¿Ìáʾ-´Î.font");
    }
               // position the subtitles window
       WinSubtitles.X = this.X-Scene.OffsetX-32;
       WinSubtitles.Y = this.Y - this.Height-25;
       WinSubtitles.Width =100;
       WinSubtitles.Height = 45;
       WinSubtitles.Visible = this.Active;
       // position the speaker name
       tiptitle.X = 0;
       tiptitle.Y = 0;
       tiptitle.Width =WinSubtitles.Width;
       tiptitle.Height = WinSubtitles.Height;
       tiptitle.TextAlign = TAL_LEFT;
       tiptitle.VerticalAlign=VAL_TOP;
       tiptitle.Text =this.Caption;
      Sleep(20); 
    }

    how to use our cusutom talk method?
    do it in the actor's script like this:

    • var subtitle;
      var msgtext;
      method MsgText(msg,t)
      {
      var l=msg.Length;
      if(l>84) return;
      var tt=t;
      if(subtitle==null)
      subtitle = Game.CreateWindow("subtitles_window1");
      if(msgtext==null)
      msgtext= subtitle.CreateStatic("speaker_name1");
      msgtext.ParentNotify=true;

      msgtext.SetFont("fonts\arial_????-?.font");   
      msgtext.TextAlign = TAL_LEFT;
      msgtext.VerticalAlign=VAL_CENTER;
      subtitle.Width =310;
      subtitle.Height =230;
      msgtext.Width =275;
      msgtext.Height =285;

      msgtext.Text =ToString(msg);
      subtitle.SetImage("interface\bst\msg1.png");
      subtitle.Width =55;
      subtitle.Height =35;
      msgtext.Width =40;
      msgtext.Height =25;
      msgtext.X =6;
      msgtext.Y =6;
      subtitle.Visible = this.Active;
      subtitle.MoveBefore(WinSubtitles);
      while(tt)
      {
      subtitle.Y = this.Y - this.Height-subtitle.Height;
      subtitle.X = this.X-Scene.OffsetX-28;
      Sleep(20);
      tt=tt-20;
      }
      subtitle.Visible=false;
      }


Logged

mylesblasonato

  • Developer
  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 265
  • "Give up is to fail as sacrifice is to succeed"
    • View Profile
    • Royal Wins
Re: a solution to develop multiply players game by WME
« Reply #1 on: August 15, 2008, 01:13:57 AM »

Thanks for the info, you rock man. Maybe you can help me later with a multiplayer game. Keep up the great work.

Cheers ::beer
Myles Blasonato.
Logged
Lead Game Designer, Royal Wins.
@mylesblasonato
@royalwins
http://au.linkedin.com/pub/myles-blasonato/26/600/a38

odnorf

  • w00t?
  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 7
  • Offline Offline
  • Gender: Male
  • Posts: 1456
  • Lamp dog!
    • View Profile
Re: a solution to develop multiply players game by WME
« Reply #2 on: August 28, 2008, 11:23:38 AM »

I'd never expected to see a business simulation multi player game in wme (with a large addition of external code in this case). And the fact that you used wme for something which was not the primary design is impressive alone. Good work.
Logged
fl*p

Baron

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 37
    • View Profile
    • Portfolio
Re: a solution to develop multiply players game by WME
« Reply #3 on: September 26, 2008, 05:08:37 AM »

令人
 

Page created in 0.042 seconds with 20 queries.