Tencent cloud to the Guards, a person can develop sophisticated online games, Shenzhen Tencent cloud Sharon sent a report!

This article would like to thank "Yuri silver smile" from September 28 Shenzhen Tencent cloud "game developed ultra" sound, "" speed, "" Sharon sent a heavy message, the following Shawn focuses on individual developers surprise "MGOBE" online Battle engine.

First, what is the online battle engine

We look at the official presentation of Tencent cloud "online Battle engine":

Games online Battle engine (Mini Game Online Battle Engine, MGOBE) providing for the game room management, online matching, frame synchronization, state synchronization and other network communications services to help developers quickly build interactive multiplayer games. Developers do not need to focus on the underlying network architecture, network communications, server scaling capacity, operation and maintenance, etc., you can get access nearby, low-latency, high-performance real-time expansion of online gaming service, allows players to communicate on the network, war, freedom Chang play. MGOBE applies to turn-based, strategy class, real-time sessions (casual war, MOBA, FPS) and other games.

Second, the online gaming engine Quick Start

Then the less cost, we directly on the code, you know how cool.

1. Import SDK

// 导入 MGOBE.js
import "./js/libs/MGOBE.js";
// 获取 Room、Listener 对象
const { Room, Listener } = MGOBE;

file

Game H5 easy access SDK, is really too Easy.

2. Initialize monitor

Before using the API required to open MGOBE Tencent cloud usage rights get gameId, secretKey, url information, then it is possible to use the online gaming engine initialization code, as follows:

const gameInfo = {
     // 替换 为控制台上的“游戏ID”
     gameId: "xxxxxxxx",
     // 玩家 openId
     openId: 'openid_123_test',
     // 替换 为控制台上的“密钥”
     secretKey: 'BjU3QBZLFxxxxxxxxxxxxxxxxxx',
 };
 
 const config = {
     // 替换 为控制台上的“域名”
     url: 'xxxxxxxx.wxlagame.com',
     reconnectMaxTimes: 5,
     reconnectInterval: 1000,
     resendInterval: 1000,
     resendTimeout: 10000,
 };
 
// 初始化 Listener
Listener.init(gameInfo, config, event => {
     if (event.code === 0) {
         console.log("初始化成功");
         // 初始化成功之后才能调用其他 API
         // ...
     }
 });

3. Examples of the room, matching players

// 实例化 Room 对象
const room = new Room();
Listener.init(gameInfo, config, event => {
    if (event.code === MGOBE.ErrCode.EC_OK) {
        console.log("初始化成功");
        // 初始化后才能添加监听
        Listener.add(room);
    } else {
        console.log("初始化失败");
    }
});

//调用房间匹配 API
const playerInfo = {
    name: "Tom",
    customPlayerStatus: 1,
    customProfile: "https://xxx.com/icon.png",
};

const matchRoomPara = {
    playerInfo,
    maxPlayers: 5,
    roomType: "1",
};

room.matchRoom(matchRoomPara, event => {
    if (event.code !== 0) {
        console.log("匹配失败", event.code);
    }
});

// 广播:房间有新玩家加入
room.onJoinRoom = (event) => { 
    console.log("新玩家加入", event.data.joinPlayerId);
}
// 广播:房间有玩家退出
room.onLeaveRoom = (event) => {
    console.log("玩家退出", event.data.leavePlayerId);
}

4. The message communications within the room

//消息参数
const sendToClientPara = {
    recvType: MGOBE.ENUM.RecvType.ROOM_SOME,
    recvPlayerList: ["xxxxxxxx1", "xxxxxxxx2"],
    msg: "hello",
};

//发送到客户端 API
room.sendToClient(sendToClientPara, event => console.log(event));

//客户端接收消息 API
room.onRecvFromClient = (event) => {
    console.log("新消息", event.data.msg);
};

The frame synchronization

//开始帧同步
room.startFrameSync({}, event => {
    if (event.code === 0) {
        console.log("开始帧同步成功");
    }
});

//开始帧同步广播回调
room.onStartFrameSync = (event) => { 
    console.log("开始帧同步");
}

Message transmission frame

const frame = {cmd: "xxxxxxxx", id: "xxxxxxxx" };
const sendFramePara = { data: frame };
room.sendFrame(sendFramePara, event => console.log(event));

Room frame callback message broadcasting

room.onRecvFrame = event => {
    console.log("帧广播", event.data.frame);
};

State synchronization mechanism is slightly complicated point here is not started by the above, I do not know if you have not felt very excited about it?

Third, the application acceleration voice & multimedia

Sharon addition to online gaming engines, Tencent has also brought a cloud

Global Application Acceleration GAAP

Global Application Acceleration (Global Application Acceleration Platform, GAAP) rely on high-speed channel between global node, cluster forwarding and intelligent routing technology, users around the nearest access, through direct source station for high-speed channels, help solve business users worldwide access card Dayton excessive delays or problems. GAAP provides a graphical configuration interface, just a few minutes, you can create and use high-speed channel to access your service source station, and check the running path through the console.

file

The following is a live picture King "Silver laughing Yuri" brought back
file

Multimedia game engine About GME

Tencent cloud gaming multimedia engine (Gaming Multimedia Engine, GME) provides one-stop game voice solutions. Be optimized for different game scene depth, covering casual social, MOBA, MMORPG, FPS, and other types of games; multiplayer real-time voice, 3D location of voice, voice messaging and voice-to-text functions; full-featured, low access threshold, an SDK to meet the diverse needs of the game speech.

file
file

H5 full support, but also support Cocos2dx, Unity, Unreal engine, three, and seven platforms, fancy map can guess is that the seven platforms? Look icon, Shawn guess for a long time still to be guessed!

  1. Two desktop operating systems: Mac, Windows
  2. Two mobile operating systems: iOS, Android
  3. Three game console platforms: Nintendo switch, PS4, Xbox

file

Reply to [develop] Tencent cloud can view on MGOBE, GAAP, documentation GME three public cloud technology in number!

Fourth, there are surprises

Shawn here to get the news, Tencent cloud in October there were two salon

  • October 18: Beijing Railway Station
  • October 26: Shanghai Station

Interested partners can enroll in public concern number, thank you for your support!

file

Guess you like

Origin www.cnblogs.com/creator-star/p/11622245.html