example/blocks: Use FillRect (imageEmpty is no longer needed)

This commit is contained in:
Hajime Hoshi 2015-01-18 00:05:15 +09:00
parent 26358f3e63
commit c892f84816

View File

@ -25,7 +25,6 @@ import (
) )
var ( var (
imageEmpty *ebiten.Image
imageGameBG *ebiten.Image imageGameBG *ebiten.Image
imageWindows *ebiten.Image imageWindows *ebiten.Image
imageGameover *ebiten.Image imageGameover *ebiten.Image
@ -67,12 +66,6 @@ func linesTextBoxPosition() (x, y int) {
func init() { func init() {
var err error var err error
imageEmpty, err = ebiten.NewImage(16, 16, ebiten.FilterNearest)
if err != nil {
panic(err)
}
imageEmpty.Fill(color.White)
// Background // Background
imageGameBG, _, err = ebitenutil.NewImageFromFile("images/gophers.jpg", ebiten.FilterLinear) imageGameBG, _, err = ebitenutil.NewImageFromFile("images/gophers.jpg", ebiten.FilterLinear)
if err != nil { if err != nil {
@ -127,12 +120,7 @@ func init() {
} }
func drawWindow(r *ebiten.Image, x, y, width, height int) error { func drawWindow(r *ebiten.Image, x, y, width, height int) error {
w, h := imageEmpty.Size() return r.FillRect(x, y, width, height, color.NRGBA{0, 0, 0, 0xc0})
op := &ebiten.DrawImageOptions{}
op.GeoM.Scale(float64(width)/float64(w), float64(height)/float64(h))
op.GeoM.Translate(float64(x), float64(y))
op.ColorM.Scale(0.0, 0.0, 0.0, 0.75)
return r.DrawImage(imageEmpty, op)
} }
var fontColor = color.NRGBA{0x40, 0x40, 0xff, 0xff} var fontColor = color.NRGBA{0x40, 0x40, 0xff, 0xff}