func main() { game := &Game{} game.EventSystem = lbricks.CreateEventSystem(100) signal := game.EventSystem.FromEvent("MouseEvent") signal.Filter(func(value interface{}) bool { return value.(lbricks.MouseEvent).Action == lbricks.LEFT_BUTTON_DOWN }). Subscribe(func(value interface{}) { on = true fmt.Println("From Subscribe True", value) }) signal2 := game.EventSystem.FromEvent("MouseEvent") signal2.Filter(func(value interface{}) bool { return value.(lbricks.MouseEvent).Action == lbricks.LEFT_BUTTON_UP }). Subscribe(func(value interface{}) { on = false fmt.Println("From Subscribe False", value) }) engi.Open("Botmark", 800, 600, false, game) }
func run(ig *agario.Game) { gameEvents := make(chan struct{}) quitChan := make(chan struct{}) g := &Game{ g: ig, quitChan: quitChan, } /*ai := &AI{ g: ig, }*/ ka := &keepAlive{ g: ig, } go handleGameEvents(gameEvents, ig) go engi.Open("agariobot", 1280, 800, false, g) lastTick := time.Now() mainLoop: for { select { case _, ok := <-quitChan: if !ok { break mainLoop } case <-gameEvents: dt := time.Now().Sub(lastTick) ig.Lock() ka.Update(dt) //ai.Update(dt) ig.Unlock() lastTick = time.Now() } } log.Printf("Gracefully stopped") }
func main() { engi.Open("Hello", 1024, 640, true, NewGame()) }
func main() { engi.Open("Botmark", 800, 600, false, NewGame()) }
func main() { // タイトル, height, width, fullscreen, Gameオブジェクト engi.Open("Hello", 1024, 640, false, &Game{}) }
func main() { engi.Open("Hello", 1024, 640, false, &Game{}) }
func main() { engi.Open("Botmark", 800, 600, false, &Game{}) }