diff --git a/_docs/public/examples/_resources/images/ebiten.png b/_docs/public/examples/_resources/images/ebiten.png new file mode 100644 index 000000000..4ed07b852 Binary files /dev/null and b/_docs/public/examples/_resources/images/ebiten.png differ diff --git a/_docs/public/examples/_resources/images/fiveyears.jpg b/_docs/public/examples/_resources/images/fiveyears.jpg new file mode 100644 index 000000000..1c7f8f587 Binary files /dev/null and b/_docs/public/examples/_resources/images/fiveyears.jpg differ diff --git a/_docs/public/examples/_resources/images/gophers.jpg b/_docs/public/examples/_resources/images/gophers.jpg new file mode 100644 index 000000000..0cc956f10 Binary files /dev/null and b/_docs/public/examples/_resources/images/gophers.jpg differ diff --git a/_docs/public/examples/_resources/images/license.md b/_docs/public/examples/_resources/images/license.md new file mode 100644 index 000000000..0cd416aae --- /dev/null +++ b/_docs/public/examples/_resources/images/license.md @@ -0,0 +1,31 @@ +# License + +## ebiten.png + +``` +http://www.sozai-page.com/02_sozai/b/b04/b04_002/b04_002.html +``` + +## fiveyears.jpg + +``` +The Go gopher was designed by Renee French. (http://reneefrench.blogspot.com/) +The design is licensed under the Creative Commons 3.0 Attributions license. +Read this article for more details: https://blog.golang.org/gopher +``` + +## gophers.jpg + +``` +http://blog.golang.org/go-programming-language-turns-two + +Photograph by Chris Nokleberg +the Creative Commons Attribution 3.0 License +``` + +## Other image files + +``` +Copyright 2014 Hajime Hoshi +the Creative Commons Attribution 3.0 License +``` diff --git a/_docs/public/examples/alphablending.html b/_docs/public/examples/alphablending.html index d1c9e8578..633ca8f67 100644 --- a/_docs/public/examples/alphablending.html +++ b/_docs/public/examples/alphablending.html @@ -44,7 +44,7 @@ import ( "log" "github.com/hajimehoshi/ebiten" - "github.com/hajimehoshi/ebiten/examples/common" + "github.com/hajimehoshi/ebiten/ebitenutil" ) const ( @@ -102,7 +102,7 @@ func update(screen *ebiten.Image) error { func main() { var err error - ebitenImage, _, err = common.AssetImage("ebiten.png", ebiten.FilterNearest) + ebitenImage, _, err = ebitenutil.NewImageFromFile("_resources/images/ebiten.png", ebiten.FilterNearest) if err != nil { log.Fatal(err) } diff --git a/_docs/public/examples/audio.html b/_docs/public/examples/audio.html index c050a4e11..c12d84f5d 100644 --- a/_docs/public/examples/audio.html +++ b/_docs/public/examples/audio.html @@ -39,9 +39,9 @@ pre {
package main
import (
- "bytes"
"fmt"
"image/color"
+ "io/ioutil"
"log"
"time"
@@ -85,10 +85,9 @@ type Player struct {
var (
audioContext *audio.Context
musicPlayer *Player
- seStream *wav.Stream
- sePlayer *audio.Player
+ seBytes []byte
musicCh = make(chan *Player)
- seCh = make(chan *wav.Stream)
+ seCh = make(chan []byte)
mouseButtonState = map[ebiten.MouseButton]int{}
keyState = map[ebiten.Key]int{}
volume128 = 128
@@ -101,16 +100,8 @@ func playerBarRect() (x, y, w, h int) {
return
}
-type SEStream struct {
- *bytes.Reader
-}
-
-func (s *SEStream) Close() error {
- return nil
-}
-
func (p *Player) updateSE() error {
- if seStream == nil {
+ if seBytes == nil {
return nil
}
if !ebiten.IsKeyPressed(ebiten.KeyP) {
@@ -121,17 +112,8 @@ func (p *Player) updateSE() error {
if keyState[ebiten.KeyP] != 1 {
return nil
}
- if sePlayer == nil {
- var err error
- sePlayer, err = audio.NewPlayer(audioContext, seStream)
- if err != nil {
- return err
- }
- }
- if sePlayer.IsPlaying() {
- return nil
- }
- if err := sePlayer.Rewind(); err != nil {
+ sePlayer, err := audio.NewPlayerFromBytes(audioContext, seBytes)
+ if err != nil {
return err
}
return sePlayer.Play()
@@ -211,9 +193,9 @@ func update(screen *ebiten.Image) error {
default:
}
}
- if seStream == nil {
+ if seBytes == nil {
select {
- case seStream = <-seCh:
+ case seBytes = <-seCh:
default:
}
}
@@ -290,7 +272,12 @@ func main() {
log.Fatal(err)
return
}
- seCh <- s
+ b, err := ioutil.ReadAll(s)
+ if err != nil {
+ log.Fatal(err)
+ return
+ }
+ seCh <- b
close(seCh)
}()
go func() {
diff --git a/_docs/public/examples/hsv.html b/_docs/public/examples/hsv.html
index a1aa12dd0..5ab38b242 100644
--- a/_docs/public/examples/hsv.html
+++ b/_docs/public/examples/hsv.html
@@ -46,7 +46,6 @@ import (
"github.com/hajimehoshi/ebiten"
"github.com/hajimehoshi/ebiten/ebitenutil"
- "github.com/hajimehoshi/ebiten/examples/common"
)
const (
@@ -119,7 +118,7 @@ Value: %0.2f [Z][X]`, hue, saturation, value)
func main() {
var err error
- gophersImage, _, err = common.AssetImage("gophers.jpg", ebiten.FilterNearest)
+ gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterNearest)
if err != nil {
log.Fatal(err)
}
diff --git a/_docs/public/examples/hue.html b/_docs/public/examples/hue.html
index 2bdea6580..9f8078e13 100644
--- a/_docs/public/examples/hue.html
+++ b/_docs/public/examples/hue.html
@@ -44,7 +44,7 @@ import (
"math"
"github.com/hajimehoshi/ebiten"
- "github.com/hajimehoshi/ebiten/examples/common"
+ "github.com/hajimehoshi/ebiten/ebitenutil"
)
const (
@@ -71,7 +71,7 @@ func update(screen *ebiten.Image) error {
func main() {
var err error
- gophersImage, _, err = common.AssetImage("gophers.jpg", ebiten.FilterNearest)
+ gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterNearest)
if err != nil {
log.Fatal(err)
}
diff --git a/_docs/public/examples/masking.html b/_docs/public/examples/masking.html
index 6e9630449..ec0c4e67f 100644
--- a/_docs/public/examples/masking.html
+++ b/_docs/public/examples/masking.html
@@ -46,7 +46,7 @@ import (
"math"
"github.com/hajimehoshi/ebiten"
- "github.com/hajimehoshi/ebiten/examples/common"
+ "github.com/hajimehoshi/ebiten/ebitenutil"
)
const (
@@ -132,11 +132,11 @@ func min(a, b int) int {
func main() {
var err error
- gophersImage, _, err = common.AssetImage("gophers.jpg", ebiten.FilterNearest)
+ gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterNearest)
if err != nil {
log.Fatal(err)
}
- fiveyearsImage, _, err = common.AssetImage("fiveyears.jpg", ebiten.FilterNearest)
+ fiveyearsImage, _, err = ebitenutil.NewImageFromFile("_resources/images/fiveyears.jpg", ebiten.FilterNearest)
if err != nil {
log.Fatal(err)
}
diff --git a/_docs/public/examples/mosaic.html b/_docs/public/examples/mosaic.html
index f5d7edb61..a2386cd48 100644
--- a/_docs/public/examples/mosaic.html
+++ b/_docs/public/examples/mosaic.html
@@ -43,7 +43,7 @@ import (
"log"
"github.com/hajimehoshi/ebiten"
- "github.com/hajimehoshi/ebiten/examples/common"
+ "github.com/hajimehoshi/ebiten/ebitenutil"
)
const (
@@ -70,7 +70,7 @@ func update(screen *ebiten.Image) error {
func main() {
var err error
- gophersImage, _, err = common.AssetImage("gophers.jpg", ebiten.FilterNearest)
+ gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterNearest)
if err != nil {
log.Fatal(err)
}
diff --git a/_docs/public/examples/perspective.html b/_docs/public/examples/perspective.html
index 58a87d48b..037f47d34 100644
--- a/_docs/public/examples/perspective.html
+++ b/_docs/public/examples/perspective.html
@@ -43,7 +43,7 @@ import (
"log"
"github.com/hajimehoshi/ebiten"
- "github.com/hajimehoshi/ebiten/examples/common"
+ "github.com/hajimehoshi/ebiten/ebitenutil"
)
const (
@@ -90,7 +90,7 @@ func update(screen *ebiten.Image) error {
func main() {
var err error
- gophersImage, _, err = common.AssetImage("gophers.jpg", ebiten.FilterNearest)
+ gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterNearest)
if err != nil {
log.Fatal(err)
}
diff --git a/_docs/public/examples/piano.html b/_docs/public/examples/piano.html
index 500b59f74..ba0993258 100644
--- a/_docs/public/examples/piano.html
+++ b/_docs/public/examples/piano.html
@@ -39,7 +39,6 @@ pre {
package main
import (
- "bytes"
"fmt"
"image/color"
"log"
@@ -104,22 +103,13 @@ func toBytes(l, r []int16) []byte {
return b
}
-type stream struct {
- *bytes.Reader
-}
-
-func (s *stream) Close() error {
- s.Reader = nil
- return nil
-}
-
func addNote(freq float64, vol float64) error {
// TODO: Call Close method of *audio.Player.
// However, this works without Close because Close is automatically called when GC
// collects a *audio.Player object.
f := int(freq)
if n, ok := noteCache[f]; ok {
- p, err := audio.NewPlayer(audioContext, &stream{bytes.NewReader(n)})
+ p, err := audio.NewPlayerFromBytes(audioContext, n)
if err != nil {
return err
}
@@ -140,7 +130,7 @@ func addNote(freq float64, vol float64) error {
}
n := toBytes(l, r)
noteCache[f] = n
- p, err := audio.NewPlayer(audioContext, &stream{bytes.NewReader(n)})
+ p, err := audio.NewPlayerFromBytes(audioContext, n)
if err != nil {
return err
}
diff --git a/_docs/public/examples/rotate.html b/_docs/public/examples/rotate.html
index 745e49984..a09f5ad3c 100644
--- a/_docs/public/examples/rotate.html
+++ b/_docs/public/examples/rotate.html
@@ -44,7 +44,7 @@ import (
"math"
"github.com/hajimehoshi/ebiten"
- "github.com/hajimehoshi/ebiten/examples/common"
+ "github.com/hajimehoshi/ebiten/ebitenutil"
)
const (
@@ -72,7 +72,7 @@ func update(screen *ebiten.Image) error {
func main() {
var err error
- gophersImage, _, err = common.AssetImage("gophers.jpg", ebiten.FilterNearest)
+ gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterNearest)
if err != nil {
log.Fatal(err)
}
diff --git a/_docs/public/examples/sprites.html b/_docs/public/examples/sprites.html
index e82fe9f3d..463cc0070 100644
--- a/_docs/public/examples/sprites.html
+++ b/_docs/public/examples/sprites.html
@@ -46,7 +46,6 @@ import (
"github.com/hajimehoshi/ebiten"
"github.com/hajimehoshi/ebiten/ebitenutil"
- "github.com/hajimehoshi/ebiten/examples/common"
)
const (
@@ -122,7 +121,7 @@ func (s Sprites) Src(i int) (x0, y0, x1, y1 int) {
const (
MinSprites = 0
- MaxSprites = 10000
+ MaxSprites = 50000
)
var sprites = &Sprites{make([]*Sprite, MaxSprites), 500}
@@ -155,13 +154,15 @@ func update(screen *ebiten.Image) error {
msg := fmt.Sprintf(`FPS: %0.2f
Num of sprites: %d
Press <- or -> to change the number of sprites`, ebiten.CurrentFPS(), sprites.Len())
- ebitenutil.DebugPrint(screen, msg)
+ if err := ebitenutil.DebugPrint(screen, msg); err != nil {
+ return err
+ }
return nil
}
func main() {
var err error
- ebitenImage, _, err = common.AssetImage("ebiten.png", ebiten.FilterNearest)
+ ebitenImage, _, err = ebitenutil.NewImageFromFile("_resources/images/ebiten.png", ebiten.FilterNearest)
if err != nil {
log.Fatal(err)
}
diff --git a/_docs/public/index.html b/_docs/public/index.html
index a87f77be3..df9ae9459 100644
--- a/_docs/public/index.html
+++ b/_docs/public/index.html
@@ -55,6 +55,7 @@ pre {
+ Wiki
Features
@@ -131,14 +132,6 @@ func main() {
Run the go run
command to start the
game. There you have it, your first Ebiten game!
-Apps created with Ebiten
-
- - Plasma by Peter Hellberg
- - go-inovation by Hajime Hoshi
- - Wired Logic by Martin Kirsche
- - AwakEngine by Josh Deprez
-
-
Change Log
See GitHub releases page.