[erlang-questions] How to write a MMO game server in Erlang?

月忧茗 <>
Wed Feb 3 04:28:40 CET 2016


I try to using Erlang to implement my tiny mmo game server.

I know the skeleton of c++ version is like this:

int main()
{
    GameApp app;
    int interval = 50;  //50ms, 20 ticks per second.
    int sleep = 0;

    uint64_t tick_start, tick_end, tick_passed;
    while(true)
    {
        tick_start = CurrentTick();
        // all logic, timer will be drive in the app.tick
        app.tick(tick);
        tick_end = CurrentTick();
        tick_passed = tick_end - tick_start;

        sleep = interval - tick_passed;
        if (sleep < 0) sleep = 0;
        SleepMilliSeconds(sleep);

    }
}

But now, I have no idea about the Erlang version.

in the erlang world, one client is one process (maybe gen_server). the
process has it's own loop, and timer can use erlang:send_after or
erlang:start_timer .

I want to know how to implement a MMO server in erlang ?

consider this situation:

Player A VS Player B.

A cast a skill X to some direction, then X flying.

the server need to detect whether X is hit on B,

When hit, add X's debuff on B, debuff will remove after 3 seconds.

......

many things , many times , many sync ...

c++ has a signal tick,

But how about erlang ?






-- 
My GitHub
https://github.com/yueyoum
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160203/8d866cca/attachment.html>


More information about the erlang-questions mailing list