Esempio n. 1
0
func loadTextures() []sprite.SubTex {
	a, err := app.Open("sprite.jpg")
	if err != nil {
		log.Fatal(err)
	}
	defer a.Close()

	img, _, err := image.Decode(a)
	if err != nil {
		log.Fatal(err)
	}
	t, err := eng.LoadTexture(img)
	if err != nil {
		log.Fatal(err)
	}

	return []sprite.SubTex{
		texBG:        sprite.SubTex{t, image.Rect(0, 0, 24, 860)},
		texButtonOff: sprite.SubTex{t, image.Rect(95, 243, 95+149, 243+149)},
		texButtonOn:  sprite.SubTex{t, image.Rect(95, 414, 95+149, 414+149)},
		texBrand:     sprite.SubTex{t, image.Rect(94, 31, 94+227, 31+88)},
		texModel:     sprite.SubTex{t, image.Rect(162, 120, 162+140, 120+90)},
		texOthers:    sprite.SubTex{t, image.Rect(162, 120, 162+140, 120+90)},
	}
}
Esempio n. 2
0
func start() {
	for i := 0; i < len(samples); i++ {
		src, err := app.Open(fmt.Sprintf("sample%d.wav", i))
		if err != nil {
			log.Fatal(err)
		}
		samples[i] = src
		p, err := audio.NewPlayer(src, 0, 0)
		if err != nil {
			log.Fatal(err)
		}
		players[i] = p
	}

	// player goroutine
	go func() {
		for {
			for i := 0; i < 4; i++ {
				for j := 0; j < 4; j++ {
					if pattern[index][i*4+j] {
						glow(i, j)
					}
				}
			}
			// bpm=140
			time.Sleep(time.Minute / 140)
			index = (index + 1) % len(pattern)
		}
	}()
}
Esempio n. 3
0
File: main.go Progetto: Miaque/mojo
func loadTextures() []sprite.SubTex {
	a, err := app.Open("waza-gophers.jpeg")
	if err != nil {
		log.Fatal(err)
	}
	defer a.Close()

	img, _, err := image.Decode(a)
	if err != nil {
		log.Fatal(err)
	}
	t, err := eng.LoadTexture(img)
	if err != nil {
		log.Fatal(err)
	}

	return []sprite.SubTex{
		texBooks:   sprite.SubTex{t, image.Rect(4, 71, 132, 182)},
		texFire:    sprite.SubTex{t, image.Rect(330, 56, 440, 155)},
		texGopherR: sprite.SubTex{t, image.Rect(152, 10, 152+140, 10+90)},
		texGopherL: sprite.SubTex{t, image.Rect(162, 120, 162+140, 120+90)},
	}
}