Documentation
¶
Index ¶
- Constants
- func IPToUInt32(ipnr net.IP) uint32
- func RandBetween(min, max int64) int64
- func RandBetweenUint32(min, max uint32) uint32
- func RandColor() uint32
- func RandPOINTFloat64(min, width, height float64) (X, Y float64)
- func SafeRandHeadFloat64(min, width, height float64) (X, Y float64)
- func TwoPointLen(a, b POINT) float64
- func UInt32ToIP(intIP uint32) net.IP
- type Circle
- type Food
- type MsgType
- type POINT
- type ReqGetIDMsg
- type RetGetIDMsg
- type RetOverMsg
- type RetSceneMsg
- type RetSnakeBody
- type RetTimeMsg
Constants ¶
View Source
const ( // FrameTime 20ms FrameTime float64 = 20 // SceneSpeed 像素每秒 SceneSpeed float64 = 200 // SceneSpeedUp 加速系数 SceneSpeedUp float64 = 1.6 // SceneWidth 场景的宽度 SceneWidth float64 = 800 // SceneHeight 场景高度 SceneHeight float64 = 800 )
场景信息 速度 宽度 高度
View Source
const ( FoodNum uint32 = 20 FoodEnergy int32 = 5 // EatFoodRadius EatFoodRadius float64 = 2 )
食物信息
View Source
const ( // SnakeRadius 蛇的半径 10px SnakeRadius float64 = 10 // SnakeTurnSpeed 蛇的转向速度 弧度/ms SnakeTurnSpeed = 0.5 )
蛇的信息
View Source
const (
BallFood uint32 = 0
)
View Source
const (
CommonRoom uint32 = 0
)
View Source
const (
// Task_TimeOut websocketTask 超时时间
Task_TimeOut = 20
)
连接信息
Variables ¶
This section is empty.
Functions ¶
func IPToUInt32 ¶
func RandBetweenUint32 ¶
RandBetweenUint32 产生[min max]间的随机数
func RandPOINTFloat64 ¶
RandPOINTFloat64 随机坐标float64
func SafeRandHeadFloat64 ¶
func UInt32ToIP ¶
Types ¶
type ReqGetIDMsg ¶
ReqGetIDMsg 客户请求 json 设备信息和ip地址 存在redis中
type RetSceneMsg ¶
type RetSceneMsg struct {
PlayerSnake []RetSnakeBody `json:"player_snake"`
OthersSnake []RetSnakeBody `json:"others_snake"`
FoodList []Food `json:"food_list"`
}
RetSceneMsg 服务器返回游戏场景
type RetSnakeBody ¶
type RetSnakeBody struct {
//color
Id uint32 `json:"id"`
Name string `json:"name"`
Direct float64 `json:"direct"`
Head POINT `json:"head"`
Body []POINT `json:"body"`
Score int32 `json:"score"`
Radius float64 `json:"radius"`
}
RetSnakeBody omitempty作用是在json数据结构转换时,当该字段的值为该字段类型的零值时,忽略该字段
type RetTimeMsg ¶
type RetTimeMsg struct {
Time uint64 `json:"time"`
}
Click to show internal directories.
Click to hide internal directories.