Skip to content

Commit f4e5b4d

Browse files
committed
update data
1 parent f2c1cda commit f4e5b4d

File tree

4 files changed

+46
-1
lines changed

4 files changed

+46
-1
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package send
2+
3+
import (
4+
"fmt"
5+
)
6+
7+
// 发送坐标数据 --==--
8+
// 数据 X Y Z
9+
func Send_XYZ_Data(conn *websocket.Conn, strOpenID string, strRoomID string, OP_ULRDP string) {
10+
// 1 组装 发送数据的协议
11+
data := &Proto2.C2S_PlayerMove{
12+
Protocol: Proto.G_Snake_Proto, // 游戏主要协议
13+
Protocol2: Proto2.C2S_PlayerMoveProto2,
14+
OpenID: strOpenID, // 随机生产的数据,时间戳
15+
RoomID: strRoomID,
16+
OP_ULRDP: OP_ULRDP,
17+
}
18+
// 2 发送数据到服务器
19+
PlayerSendToServer(conn, data)
20+
}

第一季 从零开始写游戏服务器 第二期/最新课节--课程代码/class3/src/snake/tmain.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ func initNet() bool {
9191
// 处理数据的返回
9292
func GameServerReceive(ws *websocket.Conn) {
9393
for {
94-
fmt.Println("0900")
9594
var content string
9695
err := websocket.Message.Receive(ws, &content)
9796
if err != nil {

第一季 从零开始写游戏服务器 第二期/最新课节--课程代码/vender/src/LollipopGo/LollipopGo/match/match.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import (
1919
// 3 生产结果;匹配模块需要处理的
2020
// 4 实现方式:有一个匹配池子,每一个用户都是去池子里面匹配,成功返回结构
2121
// 5 匹配的池子包含很多因素:等级相近,金币相近等
22+
// 6 多线程匹配速度
23+
//*7 实现等级快速排序,多个goroutine去组合-->进入房间
2224

2325
type MatchMoudle interface {
2426
GetMatchResult()

第一季 从零开始写游戏服务器 第二期/最新课节--课程代码/vender/src/Proto/Proto2/Proto2Snake.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,34 @@ const (
77

88
C2S_PlayerEntryGameProto2 // C2S_PlayerEntryGameProto2 == 3 进入游戏
99
S2S_PlayerEntryGameProto2 // S2S_PlayerEntryGameProto2 == 4
10+
11+
C2S_PlayerMoveProto2 // C2S_PlayerMoveProto2 == 5 移动操作
12+
S2S_PlayerMoveProto2 // S2S_PlayerMoveProto2 == 6
13+
14+
S2S_PlayerMoveProto2 // S2S_PlayerMoveProto2 == 7 玩家死亡操作
1015
)
1116

1217
//------------------------------------------------------------------------------
1318

19+
// 移动操作
20+
type C2S_PlayerMove struct {
21+
Protocol int
22+
Protocol2 int
23+
OpenID string // 玩家的唯一的标识
24+
RoomID int // 房间ID
25+
OP_ULRDP string // 玩家操作的方式:移动的方向
26+
}
27+
28+
// 服务器广播给用户操作--同一个房间的,其他房间不广播
29+
type S2S_PlayerMove struct {
30+
Protocol int
31+
Protocol2 int
32+
OpenID string // 玩家的唯一的标识
33+
OP_ULRDP string // 玩家操作的方式:移动的方向
34+
}
35+
36+
//------------------------------------------------------------------------------
37+
1438
// 进入游戏匹配
1539
type C2S_PlayerEntryGame struct {
1640
Protocol int

0 commit comments

Comments
 (0)