Example #1
0
func draw() {
	if texs == nil {
		texs = loadTextures()
	}

	h := app.GetConfig().Height
	button = float32(h / 5)
	offset = button / 2

	now := clock.Time(time.Since(startClock) * 60 / time.Second)
	if now == lastClock {
		// TODO: figure out how to limit draw callbacks to 60Hz instead of
		// burning the CPU as fast as possible.
		// TODO: (relatedly??) sync to vblank?
		return
	}
	lastClock = now
	gl.ClearColor(1, 1, 1, 1)
	gl.Clear(gl.COLOR_BUFFER_BIT)

	cfg := app.GetConfig()
	board = &sprite.Node{}
	eng.Register(board)
	eng.SetTransform(board, f32.Affine{
		{1, 0, 0},
		{0, 1, 0},
	})

	n := newNode()
	eng.SetSubTex(n, texs[texBG])
	eng.SetTransform(n, f32.Affine{
		{float32(cfg.Width), 0, 0},
		{0, float32(cfg.Height), 0},
	})
	for i := 0; i < 4; i++ {
		for j := 0; j < 4; j++ {
			drawButton(i, j)
		}
	}

	drawBrandModel()
	eng.Render(board, now)
}
Example #2
0
File: main.go Project: Miaque/mojo
func draw() {
	if scene == nil {
		loadScene()
	}

	now := clock.Time(time.Since(start) * 60 / time.Second)
	if now == lastClock {
		// TODO: figure out how to limit draw callbacks to 60Hz instead of
		// burning the CPU as fast as possible.
		// TODO: (relatedly??) sync to vblank?
		return
	}
	lastClock = now

	gl.ClearColor(1, 1, 1, 1)
	gl.Clear(gl.COLOR_BUFFER_BIT)
	eng.Render(scene, now)
	debug.DrawFPS()
}
Example #3
0
File: main.go Project: stanim/karta
func main() {
	app.Run(app.Callbacks{
		Draw: func() {
			if scene == nil {
				loadScene(40)
			}

			now := clock.Time(time.Since(start) * 60 / time.Second)
			if now == lastClock {
				return
			}
			lastClock = now

			eng.Render(scene, now)
		},
		Touch: func(e event.Touch) {
			if e.Type != event.TouchStart {
				return
			}

			eng.SetSubTex(kn, loadTexture((int(e.Loc.X) * (int(e.Loc.Y/25) + 1))))
		},
	})
}
Example #4
0
	_ "image/jpeg"

	"golang.org/x/mobile/app"
	"golang.org/x/mobile/audio"
	"golang.org/x/mobile/event"
	"golang.org/x/mobile/f32"
	"golang.org/x/mobile/gl"
	"golang.org/x/mobile/sprite"
	"golang.org/x/mobile/sprite/clock"
	"golang.org/x/mobile/sprite/glsprite"
)

var (
	startClock = time.Now()
	lastClock  = clock.Time(-1)
	eng        = glsprite.Engine()

	texs []sprite.SubTex

	board *sprite.Node
)

var (
	buttons [4][4]bool
	pattern [8][16]bool
	index   int

	samples [16]io.Closer
	players [16]*audio.Player
)