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"
"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)
}

View File

@ -39,9 +39,9 @@ pre {
<pre><code>package main
import (
&#34;bytes&#34;
&#34;fmt&#34;
&#34;image/color&#34;
&#34;io/ioutil&#34;
&#34;log&#34;
&#34;time&#34;
@ -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 = &lt;-seCh:
case seBytes = &lt;-seCh:
default:
}
}
@ -290,7 +272,12 @@ func main() {
log.Fatal(err)
return
}
seCh &lt;- s
b, err := ioutil.ReadAll(s)
if err != nil {
log.Fatal(err)
return
}
seCh &lt;- b
close(seCh)
}()
go func() {

View File

@ -46,7 +46,6 @@ import (
&#34;github.com/hajimehoshi/ebiten&#34;
&#34;github.com/hajimehoshi/ebiten/ebitenutil&#34;
&#34;github.com/hajimehoshi/ebiten/examples/common&#34;
)
const (
@ -119,7 +118,7 @@ Value: %0.2f [Z][X]`, hue, saturation, value)
func main() {
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 {
log.Fatal(err)
}

View File

@ -44,7 +44,7 @@ import (
&#34;math&#34;
&#34;github.com/hajimehoshi/ebiten&#34;
&#34;github.com/hajimehoshi/ebiten/examples/common&#34;
&#34;github.com/hajimehoshi/ebiten/ebitenutil&#34;
)
const (
@ -71,7 +71,7 @@ func update(screen *ebiten.Image) error {
func main() {
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 {
log.Fatal(err)
}

View File

@ -46,7 +46,7 @@ import (
&#34;math&#34;
&#34;github.com/hajimehoshi/ebiten&#34;
&#34;github.com/hajimehoshi/ebiten/examples/common&#34;
&#34;github.com/hajimehoshi/ebiten/ebitenutil&#34;
)
const (
@ -132,11 +132,11 @@ func min(a, b int) int {
func main() {
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 {
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 {
log.Fatal(err)
}

View File

@ -43,7 +43,7 @@ import (
&#34;log&#34;
&#34;github.com/hajimehoshi/ebiten&#34;
&#34;github.com/hajimehoshi/ebiten/examples/common&#34;
&#34;github.com/hajimehoshi/ebiten/ebitenutil&#34;
)
const (
@ -70,7 +70,7 @@ func update(screen *ebiten.Image) error {
func main() {
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 {
log.Fatal(err)
}

View File

@ -43,7 +43,7 @@ import (
&#34;log&#34;
&#34;github.com/hajimehoshi/ebiten&#34;
&#34;github.com/hajimehoshi/ebiten/examples/common&#34;
&#34;github.com/hajimehoshi/ebiten/ebitenutil&#34;
)
const (
@ -90,7 +90,7 @@ func update(screen *ebiten.Image) error {
func main() {
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 {
log.Fatal(err)
}

View File

@ -39,7 +39,6 @@ pre {
<pre><code>package main
import (
&#34;bytes&#34;
&#34;fmt&#34;
&#34;image/color&#34;
&#34;log&#34;
@ -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, &amp;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, &amp;stream{bytes.NewReader(n)})
p, err := audio.NewPlayerFromBytes(audioContext, n)
if err != nil {
return err
}

View File

@ -44,7 +44,7 @@ import (
&#34;math&#34;
&#34;github.com/hajimehoshi/ebiten&#34;
&#34;github.com/hajimehoshi/ebiten/examples/common&#34;
&#34;github.com/hajimehoshi/ebiten/ebitenutil&#34;
)
const (
@ -72,7 +72,7 @@ func update(screen *ebiten.Image) error {
func main() {
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 {
log.Fatal(err)
}

View File

@ -46,7 +46,6 @@ import (
&#34;github.com/hajimehoshi/ebiten&#34;
&#34;github.com/hajimehoshi/ebiten/ebitenutil&#34;
&#34;github.com/hajimehoshi/ebiten/examples/common&#34;
)
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 = &amp;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 &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
}
func main() {
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 {
log.Fatal(err)
}

View File

@ -55,6 +55,7 @@ pre {
</ul>
</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>
<h2>Features</h2>
@ -131,14 +132,6 @@ func main() {
<p>Run the <code>go run</code> command to start the
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>
<p>See <a href="https://github.com/hajimehoshi/ebiten/releases">GitHub releases page</a>.</p>