Пример #1
0
func NewLocalEngine(game Game, frame_ms int, onCrash func(interface{}), logger *log.Logger) (*Engine, error) {
	server, err := core.MakeServer(game, frame_ms, onCrash, logger, nil)
	if err != nil {
		return nil, err
	}
	engine := &Engine{server}
	game.SetEngine(engine)
	engine.Unpause()
	return engine, nil
}
Пример #2
0
func NewHostEngine(game Game, frame_ms int, ip string, port int, onCrash func(interface{}), logger *log.Logger) (*Engine, error) {
	listener, err := net.Listen("tcp", fmt.Sprintf("%s:%d", ip, port))
	if err != nil {
		return nil, err
	}
	server, err := core.MakeServer(game, frame_ms, onCrash, logger, listener)
	if err != nil {
		return nil, err
	}
	engine := &Engine{server}
	game.SetEngine(engine)
	engine.Unpause()
	return engine, nil
}