doc: go generate

This commit is contained in:
Hajime Hoshi 2016-08-02 00:36:43 +09:00
parent d4caf20b0f
commit ef1e558ec6
15 changed files with 67 additions and 66 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -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
```

View File

@ -44,7 +44,7 @@ import (
"log" "log"
"github.com/hajimehoshi/ebiten" "github.com/hajimehoshi/ebiten"
"github.com/hajimehoshi/ebiten/examples/common" "github.com/hajimehoshi/ebiten/ebitenutil"
) )
const ( const (
@ -102,7 +102,7 @@ func update(screen *ebiten.Image) error {
func main() { func main() {
var err error var err error
ebitenImage, _, err = common.AssetImage("ebiten.png", ebiten.FilterNearest) ebitenImage, _, err = ebitenutil.NewImageFromFile("_resources/images/ebiten.png", ebiten.FilterNearest)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

View File

@ -39,9 +39,9 @@ pre {
<pre><code>package main <pre><code>package main
import ( import (
&#34;bytes&#34;
&#34;fmt&#34; &#34;fmt&#34;
&#34;image/color&#34; &#34;image/color&#34;
&#34;io/ioutil&#34;
&#34;log&#34; &#34;log&#34;
&#34;time&#34; &#34;time&#34;
@ -85,10 +85,9 @@ type Player struct {
var ( var (
audioContext *audio.Context audioContext *audio.Context
musicPlayer *Player musicPlayer *Player
seStream *wav.Stream seBytes []byte
sePlayer *audio.Player
musicCh = make(chan *Player) musicCh = make(chan *Player)
seCh = make(chan *wav.Stream) seCh = make(chan []byte)
mouseButtonState = map[ebiten.MouseButton]int{} mouseButtonState = map[ebiten.MouseButton]int{}
keyState = map[ebiten.Key]int{} keyState = map[ebiten.Key]int{}
volume128 = 128 volume128 = 128
@ -101,16 +100,8 @@ func playerBarRect() (x, y, w, h int) {
return return
} }
type SEStream struct {
*bytes.Reader
}
func (s *SEStream) Close() error {
return nil
}
func (p *Player) updateSE() error { func (p *Player) updateSE() error {
if seStream == nil { if seBytes == nil {
return nil return nil
} }
if !ebiten.IsKeyPressed(ebiten.KeyP) { if !ebiten.IsKeyPressed(ebiten.KeyP) {
@ -121,17 +112,8 @@ func (p *Player) updateSE() error {
if keyState[ebiten.KeyP] != 1 { if keyState[ebiten.KeyP] != 1 {
return nil return nil
} }
if sePlayer == nil { sePlayer, err := audio.NewPlayerFromBytes(audioContext, seBytes)
var err error if err != nil {
sePlayer, err = audio.NewPlayer(audioContext, seStream)
if err != nil {
return err
}
}
if sePlayer.IsPlaying() {
return nil
}
if err := sePlayer.Rewind(); err != nil {
return err return err
} }
return sePlayer.Play() return sePlayer.Play()
@ -211,9 +193,9 @@ func update(screen *ebiten.Image) error {
default: default:
} }
} }
if seStream == nil { if seBytes == nil {
select { select {
case seStream = &lt;-seCh: case seBytes = &lt;-seCh:
default: default:
} }
} }
@ -290,7 +272,12 @@ func main() {
log.Fatal(err) log.Fatal(err)
return return
} }
seCh &lt;- s b, err := ioutil.ReadAll(s)
if err != nil {
log.Fatal(err)
return
}
seCh &lt;- b
close(seCh) close(seCh)
}() }()
go func() { go func() {

View File

@ -46,7 +46,6 @@ import (
&#34;github.com/hajimehoshi/ebiten&#34; &#34;github.com/hajimehoshi/ebiten&#34;
&#34;github.com/hajimehoshi/ebiten/ebitenutil&#34; &#34;github.com/hajimehoshi/ebiten/ebitenutil&#34;
&#34;github.com/hajimehoshi/ebiten/examples/common&#34;
) )
const ( const (
@ -119,7 +118,7 @@ Value: %0.2f [Z][X]`, hue, saturation, value)
func main() { func main() {
var err error var err error
gophersImage, _, err = common.AssetImage(&#34;gophers.jpg&#34;, ebiten.FilterNearest) gophersImage, _, err = ebitenutil.NewImageFromFile(&#34;_resources/images/gophers.jpg&#34;, ebiten.FilterNearest)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

View File

@ -44,7 +44,7 @@ import (
&#34;math&#34; &#34;math&#34;
&#34;github.com/hajimehoshi/ebiten&#34; &#34;github.com/hajimehoshi/ebiten&#34;
&#34;github.com/hajimehoshi/ebiten/examples/common&#34; &#34;github.com/hajimehoshi/ebiten/ebitenutil&#34;
) )
const ( const (
@ -71,7 +71,7 @@ func update(screen *ebiten.Image) error {
func main() { func main() {
var err error var err error
gophersImage, _, err = common.AssetImage(&#34;gophers.jpg&#34;, ebiten.FilterNearest) gophersImage, _, err = ebitenutil.NewImageFromFile(&#34;_resources/images/gophers.jpg&#34;, ebiten.FilterNearest)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

View File

@ -46,7 +46,7 @@ import (
&#34;math&#34; &#34;math&#34;
&#34;github.com/hajimehoshi/ebiten&#34; &#34;github.com/hajimehoshi/ebiten&#34;
&#34;github.com/hajimehoshi/ebiten/examples/common&#34; &#34;github.com/hajimehoshi/ebiten/ebitenutil&#34;
) )
const ( const (
@ -132,11 +132,11 @@ func min(a, b int) int {
func main() { func main() {
var err error var err error
gophersImage, _, err = common.AssetImage(&#34;gophers.jpg&#34;, ebiten.FilterNearest) gophersImage, _, err = ebitenutil.NewImageFromFile(&#34;_resources/images/gophers.jpg&#34;, ebiten.FilterNearest)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
fiveyearsImage, _, err = common.AssetImage(&#34;fiveyears.jpg&#34;, ebiten.FilterNearest) fiveyearsImage, _, err = ebitenutil.NewImageFromFile(&#34;_resources/images/fiveyears.jpg&#34;, ebiten.FilterNearest)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

View File

@ -43,7 +43,7 @@ import (
&#34;log&#34; &#34;log&#34;
&#34;github.com/hajimehoshi/ebiten&#34; &#34;github.com/hajimehoshi/ebiten&#34;
&#34;github.com/hajimehoshi/ebiten/examples/common&#34; &#34;github.com/hajimehoshi/ebiten/ebitenutil&#34;
) )
const ( const (
@ -70,7 +70,7 @@ func update(screen *ebiten.Image) error {
func main() { func main() {
var err error var err error
gophersImage, _, err = common.AssetImage(&#34;gophers.jpg&#34;, ebiten.FilterNearest) gophersImage, _, err = ebitenutil.NewImageFromFile(&#34;_resources/images/gophers.jpg&#34;, ebiten.FilterNearest)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

View File

@ -43,7 +43,7 @@ import (
&#34;log&#34; &#34;log&#34;
&#34;github.com/hajimehoshi/ebiten&#34; &#34;github.com/hajimehoshi/ebiten&#34;
&#34;github.com/hajimehoshi/ebiten/examples/common&#34; &#34;github.com/hajimehoshi/ebiten/ebitenutil&#34;
) )
const ( const (
@ -90,7 +90,7 @@ func update(screen *ebiten.Image) error {
func main() { func main() {
var err error var err error
gophersImage, _, err = common.AssetImage(&#34;gophers.jpg&#34;, ebiten.FilterNearest) gophersImage, _, err = ebitenutil.NewImageFromFile(&#34;_resources/images/gophers.jpg&#34;, ebiten.FilterNearest)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

View File

@ -39,7 +39,6 @@ pre {
<pre><code>package main <pre><code>package main
import ( import (
&#34;bytes&#34;
&#34;fmt&#34; &#34;fmt&#34;
&#34;image/color&#34; &#34;image/color&#34;
&#34;log&#34; &#34;log&#34;
@ -104,22 +103,13 @@ func toBytes(l, r []int16) []byte {
return b return b
} }
type stream struct {
*bytes.Reader
}
func (s *stream) Close() error {
s.Reader = nil
return nil
}
func addNote(freq float64, vol float64) error { func addNote(freq float64, vol float64) error {
// TODO: Call Close method of *audio.Player. // TODO: Call Close method of *audio.Player.
// However, this works without Close because Close is automatically called when GC // However, this works without Close because Close is automatically called when GC
// collects a *audio.Player object. // collects a *audio.Player object.
f := int(freq) f := int(freq)
if n, ok := noteCache[f]; ok { if n, ok := noteCache[f]; ok {
p, err := audio.NewPlayer(audioContext, &amp;stream{bytes.NewReader(n)}) p, err := audio.NewPlayerFromBytes(audioContext, n)
if err != nil { if err != nil {
return err return err
} }
@ -140,7 +130,7 @@ func addNote(freq float64, vol float64) error {
} }
n := toBytes(l, r) n := toBytes(l, r)
noteCache[f] = n noteCache[f] = n
p, err := audio.NewPlayer(audioContext, &amp;stream{bytes.NewReader(n)}) p, err := audio.NewPlayerFromBytes(audioContext, n)
if err != nil { if err != nil {
return err return err
} }

View File

@ -44,7 +44,7 @@ import (
&#34;math&#34; &#34;math&#34;
&#34;github.com/hajimehoshi/ebiten&#34; &#34;github.com/hajimehoshi/ebiten&#34;
&#34;github.com/hajimehoshi/ebiten/examples/common&#34; &#34;github.com/hajimehoshi/ebiten/ebitenutil&#34;
) )
const ( const (
@ -72,7 +72,7 @@ func update(screen *ebiten.Image) error {
func main() { func main() {
var err error var err error
gophersImage, _, err = common.AssetImage(&#34;gophers.jpg&#34;, ebiten.FilterNearest) gophersImage, _, err = ebitenutil.NewImageFromFile(&#34;_resources/images/gophers.jpg&#34;, ebiten.FilterNearest)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

View File

@ -46,7 +46,6 @@ import (
&#34;github.com/hajimehoshi/ebiten&#34; &#34;github.com/hajimehoshi/ebiten&#34;
&#34;github.com/hajimehoshi/ebiten/ebitenutil&#34; &#34;github.com/hajimehoshi/ebiten/ebitenutil&#34;
&#34;github.com/hajimehoshi/ebiten/examples/common&#34;
) )
const ( const (
@ -122,7 +121,7 @@ func (s Sprites) Src(i int) (x0, y0, x1, y1 int) {
const ( const (
MinSprites = 0 MinSprites = 0
MaxSprites = 10000 MaxSprites = 50000
) )
var sprites = &amp;Sprites{make([]*Sprite, MaxSprites), 500} var sprites = &amp;Sprites{make([]*Sprite, MaxSprites), 500}
@ -155,13 +154,15 @@ func update(screen *ebiten.Image) error {
msg := fmt.Sprintf(`FPS: %0.2f msg := fmt.Sprintf(`FPS: %0.2f
Num of sprites: %d Num of sprites: %d
Press &lt;- or -&gt; to change the number of sprites`, ebiten.CurrentFPS(), sprites.Len()) Press &lt;- or -&gt; 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 return nil
} }
func main() { func main() {
var err error var err error
ebitenImage, _, err = common.AssetImage(&#34;ebiten.png&#34;, ebiten.FilterNearest) ebitenImage, _, err = ebitenutil.NewImageFromFile(&#34;_resources/images/ebiten.png&#34;, ebiten.FilterNearest)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

View File

@ -55,6 +55,7 @@ pre {
</ul> </ul>
</li> </li>
<li><a href="http://godoc.org/github.com/hajimehoshi/ebiten"><img src="https://godoc.org/github.com/hajimehoshi/ebiten?status.svg" alt="GoDoc Reference"></a></li> <li><a href="http://godoc.org/github.com/hajimehoshi/ebiten"><img src="https://godoc.org/github.com/hajimehoshi/ebiten?status.svg" alt="GoDoc Reference"></a></li>
<li><a href="https://github.com/hajimehoshi/ebiten/wiki">Wiki</a>
</ul> </ul>
<h2>Features</h2> <h2>Features</h2>
@ -131,14 +132,6 @@ func main() {
<p>Run the <code>go run</code> command to start the <p>Run the <code>go run</code> command to start the
game. There you have it, your first Ebiten game!</p> game. There you have it, your first Ebiten game!</p>
<h2>Apps created with Ebiten</h2>
<ul>
<li><a href="https://github.com/peterhellberg/plasma">Plasma</a> by Peter Hellberg</li>
<li><a href="https://github.com/hajimehoshi/go-inovation">go-inovation</a> by Hajime Hoshi</li>
<li><a href="https://github.com/martinkirsche/wired-logic">Wired Logic</a> by Martin Kirsche</li>
<li><a href="https://github.com/DrJosh9000/awakengine">AwakEngine</a> by Josh Deprez</li>
</ul>
<h2>Change Log</h2> <h2>Change Log</h2>
<p>See <a href="https://github.com/hajimehoshi/ebiten/releases">GitHub releases page</a>.</p> <p>See <a href="https://github.com/hajimehoshi/ebiten/releases">GitHub releases page</a>.</p>