Esempio n. 1
0
func main() {
	var err error
	gophersImage, _, err = common.AssetImage("gophers.jpg", ebiten.FilterNearest)
	if err != nil {
		log.Fatal(err)
	}
	fiveyearsImage, _, err = common.AssetImage("fiveyears.jpg", ebiten.FilterNearest)
	if err != nil {
		log.Fatal(err)
	}
	maskImage, err = ebiten.NewImage(screenWidth, screenHeight, ebiten.FilterNearest)
	if err != nil {
		log.Fatal(err)
	}

	as := image.Point{128, 128}
	a := image.NewAlpha(image.Rectangle{image.ZP, as})
	for j := 0; j < as.Y; j++ {
		for i := 0; i < as.X; i++ {
			r := as.X / 2
			d := math.Sqrt(float64((i-r)*(i-r) + (j-r)*(j-r)))
			b := uint8(max(0, min(0xff, 3*0xff-int(d*3*0xff)/r)))
			a.SetAlpha(i, j, color.Alpha{b})
		}
	}
	spotLightImage, err = ebiten.NewImageFromImage(a, ebiten.FilterNearest)
	if err != nil {
		log.Fatal(err)
	}
	if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Masking (Ebiten Demo)"); err != nil {
		log.Fatal(err)
	}
}
Esempio n. 2
0
func main() {
	var err error
	gophersImage, _, err = common.AssetImage("gophers.jpg", ebiten.FilterNearest)
	if err != nil {
		log.Fatal(err)
	}
	if err := ebiten.Run(update, screenWidth, screenHeight, 2, "HSV (Ebiten Demo)"); err != nil {
		log.Fatal(err)
	}
}
Esempio n. 3
0
func main() {
	var err error
	ebitenImage, _, err = common.AssetImage("ebiten.png", ebiten.FilterNearest)
	if err != nil {
		log.Fatal(err)
	}
	ebitenImageWidth, ebitenImageHeight = ebitenImage.Size()
	for i := range sprites.sprites {
		w, h := ebitenImage.Size()
		x, y := rand.Intn(screenWidth-w), rand.Intn(screenHeight-h)
		vx, vy := 2*rand.Intn(2)-1, 2*rand.Intn(2)-1
		sprites.sprites[i] = &Sprite{
			image: ebitenImage,
			x:     x,
			y:     y,
			vx:    vx,
			vy:    vy,
		}
	}
	if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Sprites (Ebiten Demo)"); err != nil {
		log.Fatal(err)
	}
}