Golang 游戏基本框架。
go get github.com/smartwalle/newbee
var room = newbee.NewRoom(1)
定义一个结构体,实现 newbee.Game 接口
type Game struct {
}
func (this *Game) GetId() int64 {}
func (this *Game) GetState() newbee.GameState {}
func (this *Game) TickInterval() time.Duration {}
func (this *Game) OnTick() {}
func (this *Game) OnMessage(player newbee.Player, message interface{}) {}
func (this *Game) OnDequeue(message interface{}) {}
func (this *Game) OnRunInRoom(room newbee.Room) {}
func (this *Game) OnJoinRoom(player newbee.Player) {}
func (this *Game) OnLeaveRoom(player newbee.Player) {}
func (this *Game) OnCloseRoom(room newbee.Room) {}
func (this *Game) OnPanic(room newbee.Room, err error) {}
var game = &Game{}
room.Run(game)
var player = &Player{} // Player 结构体需要实现 newbee.Player 接口
room.AddPlayer(player)