mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
examples/blocks: Use embedded resources (#552)
This commit is contained in:
parent
08beed4306
commit
d5d577c733
@ -15,6 +15,8 @@
|
||||
package blocks
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"image"
|
||||
"image/color"
|
||||
_ "image/jpeg"
|
||||
_ "image/png"
|
||||
@ -24,6 +26,7 @@ import (
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
"github.com/hajimehoshi/ebiten/examples/resources/images"
|
||||
"github.com/hajimehoshi/ebiten/inpututil"
|
||||
)
|
||||
|
||||
@ -69,11 +72,11 @@ func linesTextBoxPosition() (x, y int) {
|
||||
|
||||
func init() {
|
||||
// Background
|
||||
var err error
|
||||
imageGameBG, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterDefault)
|
||||
img, _, err := image.Decode(bytes.NewReader(images.Gophers_jpg))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
imageGameBG, _ = ebiten.NewImageFromImage(img, ebiten.FilterDefault)
|
||||
|
||||
// Windows
|
||||
imageWindows, _ = ebiten.NewImage(ScreenWidth, ScreenHeight, ebiten.FilterDefault)
|
||||
|
@ -15,21 +15,23 @@
|
||||
package blocks
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"image"
|
||||
_ "image/png"
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
rblocks "github.com/hajimehoshi/ebiten/examples/resources/images/blocks"
|
||||
)
|
||||
|
||||
var imageBlocks *ebiten.Image
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
imageBlocks, _, err = ebitenutil.NewImageFromFile("_resources/images/blocks/blocks.png", ebiten.FilterDefault)
|
||||
img, _, err := image.Decode(bytes.NewReader(rblocks.Blocks_png))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
imageBlocks, _ = ebiten.NewImageFromImage(img, ebiten.FilterDefault)
|
||||
|
||||
}
|
||||
|
||||
type Angle int
|
||||
|
@ -15,22 +15,24 @@
|
||||
package blocks
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"image"
|
||||
"image/color"
|
||||
_ "image/png"
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
rblocks "github.com/hajimehoshi/ebiten/examples/resources/images/blocks"
|
||||
"github.com/hajimehoshi/ebiten/inpututil"
|
||||
)
|
||||
|
||||
var imageBackground *ebiten.Image
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
imageBackground, _, err = ebitenutil.NewImageFromFile("_resources/images/blocks/background.png", ebiten.FilterDefault)
|
||||
img, _, err := image.Decode(bytes.NewReader(rblocks.Background_png))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
imageBackground, _ = ebiten.NewImageFromImage(img, ebiten.FilterDefault)
|
||||
}
|
||||
|
||||
type TitleScene struct {
|
||||
|
Loading…
Reference in New Issue
Block a user