mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 20:18:59 +01:00
doc: go generate
This commit is contained in:
parent
d4caf20b0f
commit
ef1e558ec6
BIN
_docs/public/examples/_resources/images/ebiten.png
Normal file
BIN
_docs/public/examples/_resources/images/ebiten.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
BIN
_docs/public/examples/_resources/images/fiveyears.jpg
Normal file
BIN
_docs/public/examples/_resources/images/fiveyears.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 31 KiB |
BIN
_docs/public/examples/_resources/images/gophers.jpg
Normal file
BIN
_docs/public/examples/_resources/images/gophers.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
31
_docs/public/examples/_resources/images/license.md
Normal file
31
_docs/public/examples/_resources/images/license.md
Normal 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
|
||||
```
|
@ -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)
|
||||
}
|
||||
|
@ -39,9 +39,9 @@ pre {
|
||||
<pre><code>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() {
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -39,7 +39,6 @@ pre {
|
||||
<pre><code>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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user