コード例 #1
0
ファイル: main.go プロジェクト: tenntenn/gomoxy
func main() {
	var proxy *goproxy.ProxyHttpServer
	app.Main(func(a app.App) {
		var sz size.Event
		for e := range a.Events() {
			switch e := app.Filter(e).(type) {
			case lifecycle.Event:
				if e.Crosses(lifecycle.StageAlive) == lifecycle.CrossOn && proxy == nil {
					proxy = goproxy.NewProxyHttpServer()
					//proxy.Verbose = true
					re := regexp.MustCompile(`.*`)
					proxy.OnResponse(goproxy.UrlMatches(re)).DoFunc(
						func(res *http.Response, ctx *goproxy.ProxyCtx) *http.Response {
							if label != nil {
								label.Text = fmt.Sprintf("%s\n%s\n", ctx.Req.URL, label.Text)
								log.Println(ctx.Req.URL)
							}
							return res
						})
					go func() {
						log.Fatal(http.ListenAndServe(":8888", proxy))
					}()
				}
			case paint.Event:
				onPaint(sz)
				a.EndPaint(e)
			case size.Event:
				sz = e
			}
		}
	})
}
コード例 #2
0
ファイル: main.go プロジェクト: acsellers/ofs
func main() {
	flag.Parse()

	v = game.NewVault()
	v.PlaceRoom(9, 0, 1)
	v.PlaceRoom(9, 1, 1)
	v.PlaceRoom(10, 1, 2)

	// setup transparency for sprites
	gl.Disable(gl.DEPTH_TEST)
	gl.Enable(gl.BLEND)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)

	app.Main(func(a app.App) {
		var sz size.Event
		for e := range a.Events() {
			switch e := app.Filter(e).(type) {
			case size.Event:
				sz = e
			case paint.Event:
				onPaint(sz)
				a.EndPaint(e)
			}
		}
	})
}
コード例 #3
0
ファイル: testapp.go プロジェクト: rockxcn/mobile
func main() {
	app.Main(func(a app.App) {
		addr := "127.0.0.1:" + apptest.Port
		log.Printf("addr: %s", addr)

		conn, err := net.Dial("tcp", addr)
		if err != nil {
			log.Fatal(err)
		}
		defer conn.Close()
		log.Printf("dialled")
		comm := &apptest.Comm{
			Conn:   conn,
			Fatalf: log.Panicf,
			Printf: log.Printf,
		}

		comm.Send("hello_from_testapp")
		comm.Recv("hello_from_host")

		color := "red"
		sendPainting := false
		for e := range a.Events() {
			switch e := app.Filter(e).(type) {
			case lifecycle.Event:
				switch e.Crosses(lifecycle.StageVisible) {
				case lifecycle.CrossOn:
					comm.Send("lifecycle_visible")
					sendPainting = true
				case lifecycle.CrossOff:
					comm.Send("lifecycle_not_visible")
				}
			case size.Event:
				comm.Send("size", e.PixelsPerPt, e.Orientation)
			case paint.Event:
				if color == "red" {
					gl.ClearColor(1, 0, 0, 1)
				} else {
					gl.ClearColor(0, 1, 0, 1)
				}
				gl.Clear(gl.COLOR_BUFFER_BIT)
				a.EndPaint(e)
				if sendPainting {
					comm.Send("paint", color)
					sendPainting = false
				}
			case touch.Event:
				comm.Send("touch", e.Type, e.X, e.Y)
				if e.Type == touch.TypeEnd {
					if color == "red" {
						color = "green"
					} else {
						color = "red"
					}
					sendPainting = true
				}
			}
		}
	})
}
コード例 #4
0
ファイル: main.go プロジェクト: lovexiaov/gomobileapp
func main() {
	app.Main(func(a app.App) {
		var c size.Event
		for e := range a.Events() {
			switch e := app.Filter(e).(type) {
			case lifecycle.Event:
				switch e.Crosses(lifecycle.StageVisible) {
				case lifecycle.CrossOn:
					onStart()
				case lifecycle.CrossOff:
					onStop()
				}
			case size.Event:
				c = e
				touchLocX = float32(c.WidthPt / 1.5)
				touchLocY = float32(c.HeightPt / 1.5)
			case paint.Event:
				onPaint(c)
				a.EndPaint(e)
			case touch.Event:
				touchLocX = e.X / c.PixelsPerPt
				touchLocY = e.Y / c.PixelsPerPt

			}
		}
	})
}
コード例 #5
0
ファイル: game.go プロジェクト: joho/experiments
func main() {
	var conf config.Event
	app.Main(func(a app.App) {
		for e := range a.Events() {
			switch ee := app.Filter(e).(type) {
			case paint.Event:
				draw(conf)
				a.EndPaint(e.(paint.Event))
			case touch.Event:
				onTouch(ee, conf)
			case config.Event:
				conf = ee
			case lifecycle.Event:
				switch ee.Crosses(lifecycle.StageVisible) {
				case lifecycle.CrossOn:
					start()
				case lifecycle.CrossOff:
					// occasionally doesn't work and need to CTRL+C the console
					stop()
					return
				}
			}
		}
	})
}
コード例 #6
0
ファイル: main.go プロジェクト: lovexiaov/gomobileapp
func main() {
	e := Engine{}

	app.Main(func(a app.App) {
		var c size.Event
		for eve := range a.Events() {
			switch eve := app.Filter(eve).(type) {
			case lifecycle.Event:
				switch eve.Crosses(lifecycle.StageVisible) {
				case lifecycle.CrossOn:
					e.Start()
				case lifecycle.CrossOff:
					e.Stop()
				}
			case size.Event:
				c = eve
				e.touchx = float32(c.WidthPt / 2)
				e.touchy = float32(c.HeightPt / 2)
			case paint.Event:
				e.Draw(c)
				a.EndPaint(eve)
			case touch.Event:
				e.touchx = eve.X / c.PixelsPerPt
				e.touchy = eve.Y / c.PixelsPerPt
			}
		}
	})
}
コード例 #7
0
ファイル: main.go プロジェクト: paulhankin/mobile
func main() {
	app.Main(func(a app.App) {
		visible, sz := false, size.Event{}
		for e := range a.Events() {
			switch e := app.Filter(e).(type) {
			case lifecycle.Event:
				switch e.Crosses(lifecycle.StageVisible) {
				case lifecycle.CrossOn:
					visible = true
				case lifecycle.CrossOff:
					visible = false
				}
			case size.Event:
				sz = e
			case paint.Event:
				onPaint(sz)
				a.Publish()
				if visible {
					// Keep animating.
					a.Send(paint.Event{})
				}
			}
		}
	})
}
コード例 #8
0
ファイル: main.go プロジェクト: lomoalbert/gomobileapp
func main() {
	e := Engine{}

	app.Main(func(a app.App) {
		var c size.Event
		for eve := range a.Events() {
			switch eve := app.Filter(eve).(type) {
			case lifecycle.Event:
				switch eve.Crosses(lifecycle.StageVisible) {
				case lifecycle.CrossOn:
					e.Start()
				case lifecycle.CrossOff:
					e.Stop()
				}
			case size.Event:
				c = eve
				e.touchLoc = geom.Point{c.WidthPt / 2, c.HeightPt / 2}
			case paint.Event:
				e.Draw(c)
				a.EndPaint(eve)
			case touch.Event:
				e.touchLoc = geom.Point{geom.Pt(eve.X), geom.Pt(eve.Y)}
			}
		}
	})
}
コード例 #9
0
ファイル: main.go プロジェクト: rockxcn/mobile
func main() {
	app.Main(func(a app.App) {
		var sz size.Event
		for e := range a.Events() {
			switch e := app.Filter(e).(type) {
			case lifecycle.Event:
				switch e.Crosses(lifecycle.StageVisible) {
				case lifecycle.CrossOn:
					onStart()
				case lifecycle.CrossOff:
					onStop()
				}
			case size.Event:
				sz = e
				touchX = float32(sz.WidthPx / 2)
				touchY = float32(sz.HeightPx / 2)
			case paint.Event:
				onPaint(sz)
				a.EndPaint(e)
			case touch.Event:
				touchX = e.X
				touchY = e.Y
			}
		}
	})
}
コード例 #10
0
ファイル: main.go プロジェクト: lovexiaov/gomobileapp
func main() {
	defer func() {
		if err := recover(); err != nil {
			log.Println(err)
		}
	}()
	e := Engine{}
	app.Main(func(a app.App) {
		var c size.Event
		for eve := range a.Events() {
			switch eve := app.Filter(eve).(type) {
			case lifecycle.Event:
				switch eve.Crosses(lifecycle.StageVisible) {
				case lifecycle.CrossOn:
					e.Start()
				case lifecycle.CrossOff:
					e.Stop()
				}
			case size.Event:
				c = eve
				e.touchLoc = geom.Point{0, 0}
			case paint.Event:
				e.Draw(c)
				a.EndPaint(eve)
			case touch.Event:
				e.touchLoc = geom.Point{geom.Pt(eve.X), geom.Pt(eve.Y)}
			}
		}
	})
}
コード例 #11
0
ファイル: main.go プロジェクト: gitter-badger/bukkake
func main() {
	app.Main(func(a app.App) {
		var sz size.Event
		for e := range a.Events() {
			switch e := app.Filter(e).(type) {
			case lifecycle.Event:
				switch e.Crosses(lifecycle.StageVisible) {
				case lifecycle.CrossOn:
					onStart()
				case lifecycle.CrossOff:
					onStop()
				}
			case size.Event:
				sz = e
				resIndex = float32(sz.WidthPx) / float32(sz.HeightPx)
			case paint.Event:
				onPaint(sz)
				a.EndPaint(e)
			case touch.Event:
				eventType := e.Type.String()
				if eventType == "begin" {
					spin = !spin
				}
			}
		}
	})
}
コード例 #12
0
ファイル: main.go プロジェクト: shazow/linerage3d
func main() {
	log.SetOutput(os.Stdout)

	camera := NewQuatCamera()
	engine := Engine{
		camera:   camera,
		bindings: DefaultBindings(),
		scene:    NewScene(),
	}

	app.Main(func(a app.App) {
		var c config.Event
		for e := range a.Events() {
			switch e := app.Filter(e).(type) {
			case lifecycle.Event:
				switch e.Crosses(lifecycle.StageVisible) {
				case lifecycle.CrossOn:
					engine.Start()
				case lifecycle.CrossOff:
					engine.Stop()
				}
			case config.Event:
				engine.Config(e, c)
				c = e
			case paint.Event:
				engine.Draw(c)
				a.EndPaint(e)
			case touch.Event:
				engine.Touch(e, c)
			case key.Event:
				engine.Press(e, c)
			}
		}
	})
}
コード例 #13
0
ファイル: main.go プロジェクト: sunqb/mobile
func main() {
	app.Main(func(a app.App) {
		var c config.Event
		for e := range a.Events() {
			switch e := app.Filter(e).(type) {
			case config.Event:
				c = e
			case paint.Event:
				onPaint(c)
				a.EndPaint()
			}
		}
	})
}
コード例 #14
0
ファイル: animation.go プロジェクト: mccordnate/gogam
func main() {
	app.Main(func(a app.App) {
		var sz size.Event
		for e := range a.Events() {
			switch e := app.Filter(e).(type) {
			case size.Event:
				sz = e
			case paint.Event:
				onPaint(sz)
				a.EndPaint(e)
			case touch.Event:
				duck.MoveToTouch(e, eng)
			}
		}
	})
}
コード例 #15
0
ファイル: velocity.go プロジェクト: mccordnate/gogam
func main() {
	app.Main(func(a app.App) {
		var sz size.Event
		for e := range a.Events() {
			switch e := app.Filter(e).(type) {
			case size.Event:
				sz = e
			case paint.Event:
				onPaint(sz)
				a.EndPaint(e)
			case key.Event:
				move(e)
			}
		}
	})
}
コード例 #16
0
ファイル: testapp.go プロジェクト: monopole/mobile
func main() {
	app.Main(func(a app.App) {
		addr := "127.0.0.1:" + apptest.Port
		log.Printf("addr: %s", addr)

		conn, err := net.Dial("tcp", addr)
		if err != nil {
			log.Fatal(err)
		}
		defer conn.Close()
		log.Printf("dialled")
		comm := &apptest.Comm{
			Conn:   conn,
			Fatalf: log.Panicf,
			Printf: log.Printf,
		}

		comm.Send("hello_from_testapp")
		comm.Recv("hello_from_host")

		sendPainting := false
		var c config.Event
		for e := range a.Events() {
			switch e := app.Filter(e).(type) {
			case lifecycle.Event:
				switch e.Crosses(lifecycle.StageVisible) {
				case lifecycle.CrossOn:
					comm.Send("lifecycle_visible")
					sendPainting = true
				case lifecycle.CrossOff:
					comm.Send("lifecycle_not_visible")
				}
			case config.Event:
				c = e
				comm.Send("config", c.PixelsPerPt)
			case paint.Event:
				if sendPainting {
					comm.Send("paint")
					sendPainting = false
				}
				a.EndPaint(e)
			case touch.Event:
				comm.Send("touch", e.Type, e.Loc.X.Px(c.PixelsPerPt), e.Loc.Y.Px(c.PixelsPerPt))
			}
		}
	})
}
コード例 #17
0
ファイル: main.go プロジェクト: sunqb/mobile
func main() {
	// checkNetwork runs only once when the app first loads.
	go checkNetwork()

	app.Main(func(a app.App) {
		var c config.Event
		for e := range a.Events() {
			switch e := app.Filter(e).(type) {
			case config.Event:
				c = e
			case paint.Event:
				onDraw(c)
				a.EndPaint()
			}
		}
	})
}
コード例 #18
0
ファイル: main.go プロジェクト: pdxjohnny/mobile
func main() {
	RedirectStdout()

	app.Main(func(a app.App) {
		var sz size.Event
		for e := range a.Events() {
			switch e := app.Filter(e).(type) {
			case touch.Event:
				fmt.Println("touch.Event", e)
			case size.Event:
				sz = e
			case paint.Event:
				onDraw(sz)
				a.EndPaint(e)
			}
		}
	})
}
コード例 #19
0
ファイル: main.go プロジェクト: vanadium/croupier
func main() {
	app.Main(func(a app.App) {
		var sz size.Event
		for e := range a.Events() {
			switch e := app.Filter(e).(type) {
			case size.Event:
				sz = e
				windowSize[0] = float32(sz.WidthPx)
				windowSize[1] = float32(sz.HeightPx)
			case touch.Event:
				onTouch(e)
			case paint.Event:
				onPaint(sz)
				a.EndPaint(e)
			}
		}
	})
}
コード例 #20
0
ファイル: main.go プロジェクト: tendermint/mobile
func main() {
	app.Main(func(a app.App) {
		for e := range a.Events() {
			switch e := app.Filter(e).(type) {
			case lifecycle.Event:
				switch e.Crosses(lifecycle.StageVisible) {
				case lifecycle.CrossOn:
					onStart()
				case lifecycle.CrossOff:
					onStop()
				}
			case config.Event:
				cfg = e
			case paint.Event:
				onPaint()
				a.EndPaint()
			}
		}
	})
}
コード例 #21
0
ファイル: main.go プロジェクト: geraldstanje/slides
func main() {
	app.Main(func(a app.App) {
		for e := range a.Events() {
			switch e := app.Filter(e).(type) {
			case lifecycle.Event:
				switch e.Crosses(lifecycle.StageVisible) {
				case lifecycle.CrossOn:
					onStart()
				case lifecycle.CrossOff:
					onStop()
				}
			case config.Event:
				globalCfg = e // dimension change. move to the center.
				touchLoc = geom.Point{globalCfg.Width / 2, globalCfg.Height / 2}
			case paint.Event:
				onPaint(globalCfg)
				a.EndPaint()
			case touch.Event:
				onTouch(e)
			}
		}
	})
}
コード例 #22
0
ファイル: main.go プロジェクト: paulhankin/mobile
func main() {
	app.Main(func(a app.App) {
		visible, sz := false, size.Event{}
		for e := range a.Events() {
			switch e := app.Filter(e).(type) {
			case lifecycle.Event:
				switch e.Crosses(lifecycle.StageVisible) {
				case lifecycle.CrossOn:
					visible = true
					onStart()
				case lifecycle.CrossOff:
					visible = false
					onStop()
				}
			case size.Event:
				sz = e
				touchX = float32(sz.WidthPx / 2)
				touchY = float32(sz.HeightPx / 2)
			case paint.Event:
				onPaint(sz)
				a.Publish()
				if visible {
					// Drive the animation by preparing to paint the next frame
					// after this one is shown.
					//
					// TODO: is paint.Event the right thing to send? Should we
					// have a dedicated publish.Event type? Should App.Publish
					// take an optional event sender and send a publish.Event?
					a.Send(paint.Event{})
				}
			case touch.Event:
				touchX = e.X
				touchY = e.Y
			}
		}
	})
}
コード例 #23
0
ファイル: main.go プロジェクト: lovexiaov/gomobileapp
func main() {
	app.Main(func(a app.App) {
		var c size.Event
		for e := range a.Events() {
			switch e := app.Filter(e).(type) {
			case lifecycle.Event:
				switch e.Crosses(lifecycle.StageVisible) {
				case lifecycle.CrossOn:
					onStart()
				case lifecycle.CrossOff:
					onStop()
				}
			case size.Event:
				c = e
				touchLoc = geom.Point{c.WidthPt / 1.5, c.HeightPt / 1.5}
			case paint.Event:
				onPaint(c)
				a.EndPaint(e)
			case touch.Event:
				touchLoc = geom.Point{geom.Pt(e.X), geom.Pt(e.Y)}
			}
		}
	})
}
コード例 #24
0
ファイル: main.go プロジェクト: paulhankin/mobile
func main() {
	// checkNetwork runs only once when the app first loads.
	go checkNetwork()

	app.Main(func(a app.App) {
		det, sz := determined, size.Event{}
		for {
			select {
			case <-det:
				a.Send(paint.Event{})
				det = nil

			case e := <-a.Events():
				switch e := app.Filter(e).(type) {
				case size.Event:
					sz = e
				case paint.Event:
					onDraw(sz)
					a.Publish()
				}
			}
		}
	})
}
コード例 #25
0
ファイル: main.go プロジェクト: dr4ke616/gospeedtest
func main() {
	// check network speed runs only once when the app first loads.
	go func() {
		st := nw_speedtest.Speedtest{
			FileLocation: "http://download.thinkbroadband.com/10MB.zip",
			Verbos:       true,
		}
		result, _ := st.Start()
		speed_rate <- result
	}()

	app.Main(func(a app.App) {
		var c config.Event
		for e := range a.Events() {
			switch e := app.Filter(e).(type) {
			case config.Event:
				c = e
			case paint.Event:
				onDraw(c)
				a.EndPaint()
			}
		}
	})
}
コード例 #26
0
ファイル: main.go プロジェクト: tendermint/mobile
func main() {
	app.Main(func(a app.App) {
		var c config.Event
		for e := range a.Events() {
			switch e := app.Filter(e).(type) {
			case lifecycle.Event:
				switch e.Crosses(lifecycle.StageVisible) {
				case lifecycle.CrossOn:
					onStart()
				case lifecycle.CrossOff:
					onStop()
				}
			case config.Event:
				c = e
				touchLoc = geom.Point{c.Width / 2, c.Height / 2}
			case paint.Event:
				onPaint(c)
				a.EndPaint()
			case touch.Event:
				touchLoc = e.Loc
			}
		}
	})
}