示例#1
0
func main() {
	var err error
	gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterNearest)
	if err != nil {
		log.Fatal(err)
	}
	fiveyearsImage, _, err = ebitenutil.NewImageFromFile("_resources/images/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)
	}
}
示例#2
0
func init() {
	var err error
	imageBlocks, _, err = ebitenutil.NewImageFromFile("images/blocks/blocks.png", ebiten.FilterNearest)
	if err != nil {
		panic(err)
	}
}
示例#3
0
文件: main.go 项目: DrJosh9000/ebiten
func init() {
	var err error
	keyboardImage, _, err = ebitenutil.NewImageFromFile("images/keyboard/keyboard.png", ebiten.FilterNearest)
	if err != nil {
		log.Fatal(err)
	}
}
示例#4
0
func main() {
	var err error
	bgImage, _, err = ebitenutil.NewImageFromFile("_resources/images/tile.png", ebiten.FilterNearest)
	if err != nil {
		log.Fatal(err)
	}
	w, h := bgImage.Size()
	const repeat = 5
	repeatedBgImage, err = ebiten.NewImage(w*repeat, h*repeat, ebiten.FilterNearest)
	if err != nil {
		log.Fatal(err)
	}
	for j := 0; j < repeat; j++ {
		for i := 0; i < repeat; i++ {
			op := &ebiten.DrawImageOptions{}
			op.GeoM.Translate(float64(w*i), float64(h*j))
			if err := repeatedBgImage.DrawImage(bgImage, op); err != nil {
				log.Fatal(err)
			}
		}
	}
	groundImage, err = ebiten.NewImage(screenWidth, screenHeight, ebiten.FilterNearest)
	if err != nil {
		log.Fatal(err)
	}

	if err := ebiten.Run(update, screenWidth, screenHeight, 2, "infinite scroll"); err != nil {
		log.Fatal(err)
	}
}
示例#5
0
func init() {
	var err error
	imageBackground, _, err = ebitenutil.NewImageFromFile("_resources/images/blocks/background.png", ebiten.FilterNearest)
	if err != nil {
		panic(err)
	}
}
示例#6
0
func init() {
	dir := ""
	arcadeFontPath := filepath.Join(dir, "images", "arcadefont.png")

	arcadeFontImage, _, err := ebitenutil.NewImageFromFile(arcadeFontPath, ebiten.FilterNearest)
	if err != nil {
		panic(err)
	}
	ArcadeFont = &Font{arcadeFontImage, 32, 16, 8, 8}
}
示例#7
0
func main() {
	var err error
	ebitenImage, _, err = ebitenutil.NewImageFromFile("_resources/images/ebiten.png", ebiten.FilterNearest)
	if err != nil {
		log.Fatal(err)
	}
	if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Alpha Blending (Ebiten Demo)"); err != nil {
		log.Fatal(err)
	}
}
示例#8
0
文件: main.go 项目: DrJosh9000/ebiten
func main() {
	var err error
	gophersImage, _, err = ebitenutil.NewImageFromFile("images/gophers.jpg", ebiten.FilterNearest)
	if err != nil {
		log.Fatal(err)
	}
	if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Rotate (Ebiten Demo)"); err != nil {
		log.Fatal(err)
	}
}
示例#9
0
func main() {
	var err error
	gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterNearest)
	if err != nil {
		log.Fatal(err)
	}
	if err := ebiten.Run(update, initScreenWidth, initScreenHeight, initScreenScale, "Window Size (Ebiten Demo)"); err != nil {
		log.Fatal(err)
	}
}
示例#10
0
func init() {
	var err error
	// Background
	imageGameBG, _, err = ebitenutil.NewImageFromFile("images/gophers.jpg", ebiten.FilterLinear)
	if err != nil {
		panic(err)
	}

	// Windows
	imageWindows, err = ebiten.NewImage(ScreenWidth, ScreenHeight, ebiten.FilterNearest)
	if err != nil {
		panic(err)
	}
	// Windows: Field
	x, y := fieldWindowPosition()
	if err := drawWindow(imageWindows, x, y, fieldWidth, fieldHeight); err != nil {
		panic(err)
	}
	// Windows: Next
	x, y = nextWindowLabelPosition()
	if err := common.ArcadeFont.DrawTextWithShadow(imageWindows, "NEXT", x, y, 1, fontColor); err != nil {
		panic(err)
	}
	x, y = nextWindowPosition()
	if err := drawWindow(imageWindows, x, y, 5*blockWidth, 5*blockHeight); err != nil {
		panic(err)
	}
	// Windows: Score
	x, y = scoreTextBoxPosition()
	if err := drawTextBox(imageWindows, "SCORE", x, y, textBoxWidth()); err != nil {
		panic(err)
	}
	// Windows: Level
	x, y = levelTextBoxPosition()
	if err := drawTextBox(imageWindows, "LEVEL", x, y, textBoxWidth()); err != nil {
		panic(err)
	}
	// Windows: Lines
	x, y = linesTextBoxPosition()
	if err := drawTextBox(imageWindows, "LINES", x, y, textBoxWidth()); err != nil {
		panic(err)
	}

	// Gameover
	imageGameover, err = ebiten.NewImage(ScreenWidth, ScreenHeight, ebiten.FilterNearest)
	if err != nil {
		panic(err)
	}
	imageGameover.Fill(color.NRGBA{0x00, 0x00, 0x00, 0x80})
	y = (ScreenHeight - blockHeight) / 2
	if err := drawTextWithShadowCenter(imageGameover, "GAME OVER", 0, y, 1, color.White, ScreenWidth); err != nil {
		panic(err)
	}
}
示例#11
0
func main() {
	var err error
	gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterNearest)
	if err != nil {
		log.Fatal(err)
	}
	w, h := gophersImage.Size()
	gophersRenderTarget, err = ebiten.NewImage(w/mosaicRatio, h/mosaicRatio, ebiten.FilterNearest)
	if err != nil {
		log.Fatal(err)
	}
	if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Mosaic (Ebiten Demo)"); err != nil {
		log.Fatal(err)
	}
}
示例#12
0
func main() {
	var err error
	gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterNearest)
	if err != nil {
		log.Fatal(err)
	}
	w, h := gophersImage.Size()
	const repeat = 5
	repeatedGophersImage, err = ebiten.NewImage(w*repeat, h*repeat, ebiten.FilterNearest)
	if err != nil {
		log.Fatal(err)
	}
	for j := 0; j < repeat; j++ {
		for i := 0; i < repeat; i++ {
			op := &ebiten.DrawImageOptions{}
			op.GeoM.Translate(float64(w*i), float64(h*j))
			if err := repeatedGophersImage.DrawImage(gophersImage, op); err != nil {
				log.Fatal(err)
			}
		}
	}
	groundWidth := screenWidth + 70
	groundImage, err = ebiten.NewImage(groundWidth, screenHeight*2/3+50, ebiten.FilterNearest)
	if err != nil {
		log.Fatal(err)
	}
	const fogHeight = 8
	fogRGBA := image.NewRGBA(image.Rect(0, 0, groundWidth, fogHeight))
	for j := 0; j < fogHeight; j++ {
		a := uint32(float64(fogHeight-1-j) * 0xff / (fogHeight - 1))
		clr := skyColor
		r, g, b, oa := uint32(clr.R), uint32(clr.G), uint32(clr.B), uint32(clr.A)
		clr.R = uint8(r * a / oa)
		clr.G = uint8(g * a / oa)
		clr.B = uint8(b * a / oa)
		clr.A = uint8(a)
		for i := 0; i < groundWidth; i++ {
			fogRGBA.SetRGBA(i, j, clr)
		}
	}
	fogImage, err = ebiten.NewImageFromImage(fogRGBA, ebiten.FilterNearest)
	if err != nil {
		log.Fatal(err)
	}
	if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Air Ship (Ebiten Demo)"); err != nil {
		log.Fatal(err)
	}
}
示例#13
0
文件: font.go 项目: DrJosh9000/ebiten
func init() {
	dir := ""
	if runtime.GOARCH != "js" {
		// Get the path of this file (font.go).
		_, path, _, _ := runtime.Caller(0)
		path = filepath.Dir(path)
		dir = filepath.Join(path, "..")
	}
	arcadeFontPath := filepath.Join(dir, "images", "arcadefont.png")

	arcadeFontImage, _, err := ebitenutil.NewImageFromFile(arcadeFontPath, ebiten.FilterNearest)
	if err != nil {
		panic(err)
	}
	ArcadeFont = &Font{arcadeFontImage, 32, 16, 8, 8}
}
示例#14
0
文件: main.go 项目: DrJosh9000/ebiten
func main() {
	var err error
	ebitenImage, _, err = ebitenutil.NewImageFromFile("images/ebiten.png", ebiten.FilterNearest)
	if err != nil {
		log.Fatal(err)
	}
	tmpRenderTarget, err = ebiten.NewImage(screenWidth, screenHeight, ebiten.FilterNearest)
	if err != nil {
		log.Fatal(err)
	}
	//update := update
	//f, _ := os.Create("out.gif")
	//update = ebitenutil.RecordScreenAsGIF(update, f, 100)
	if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Alpha Blending (Ebiten Demo)"); err != nil {
		log.Fatal(err)
	}
}
示例#15
0
文件: main.go 项目: DrJosh9000/ebiten
func main() {
	var err error
	ebitenImage, _, err = ebitenutil.NewImageFromFile("images/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)
	}
}