Exemplo n.º 1
0
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)
}
Exemplo n.º 2
0
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")
}
Exemplo n.º 3
0
func main() {
	engi.Open("Hello", 1024, 640, true, NewGame())
}
Exemplo n.º 4
0
func main() {
	engi.Open("Botmark", 800, 600, false, NewGame())
}
Exemplo n.º 5
0
func main() {
	// タイトル, height, width, fullscreen, Gameオブジェクト
	engi.Open("Hello", 1024, 640, false, &Game{})
}
Exemplo n.º 6
0
func main() {
	engi.Open("Hello", 1024, 640, false, &Game{})
}
Exemplo n.º 7
0
func main() {
	engi.Open("Botmark", 800, 600, false, &Game{})
}