mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 18:52:44 +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"
|
"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)
|
||||||
}
|
}
|
||||||
|
@ -39,9 +39,9 @@ pre {
|
|||||||
<pre><code>package main
|
<pre><code>package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"image/color"
|
"image/color"
|
||||||
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -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 = <-seCh:
|
case seBytes = <-seCh:
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -290,7 +272,12 @@ func main() {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
seCh <- s
|
b, err := ioutil.ReadAll(s)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
seCh <- b
|
||||||
close(seCh)
|
close(seCh)
|
||||||
}()
|
}()
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -46,7 +46,6 @@ import (
|
|||||||
|
|
||||||
"github.com/hajimehoshi/ebiten"
|
"github.com/hajimehoshi/ebiten"
|
||||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||||
"github.com/hajimehoshi/ebiten/examples/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
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("gophers.jpg", ebiten.FilterNearest)
|
gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterNearest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten"
|
"github.com/hajimehoshi/ebiten"
|
||||||
"github.com/hajimehoshi/ebiten/examples/common"
|
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
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("gophers.jpg", ebiten.FilterNearest)
|
gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterNearest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten"
|
"github.com/hajimehoshi/ebiten"
|
||||||
"github.com/hajimehoshi/ebiten/examples/common"
|
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
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("gophers.jpg", ebiten.FilterNearest)
|
gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterNearest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
fiveyearsImage, _, err = common.AssetImage("fiveyears.jpg", ebiten.FilterNearest)
|
fiveyearsImage, _, err = ebitenutil.NewImageFromFile("_resources/images/fiveyears.jpg", ebiten.FilterNearest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,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 (
|
||||||
@ -70,7 +70,7 @@ func update(screen *ebiten.Image) error {
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var err error
|
var err error
|
||||||
gophersImage, _, err = common.AssetImage("gophers.jpg", ebiten.FilterNearest)
|
gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterNearest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,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 (
|
||||||
@ -90,7 +90,7 @@ func update(screen *ebiten.Image) error {
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var err error
|
var err error
|
||||||
gophersImage, _, err = common.AssetImage("gophers.jpg", ebiten.FilterNearest)
|
gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterNearest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,6 @@ pre {
|
|||||||
<pre><code>package main
|
<pre><code>package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"image/color"
|
"image/color"
|
||||||
"log"
|
"log"
|
||||||
@ -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, &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, &stream{bytes.NewReader(n)})
|
p, err := audio.NewPlayerFromBytes(audioContext, n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten"
|
"github.com/hajimehoshi/ebiten"
|
||||||
"github.com/hajimehoshi/ebiten/examples/common"
|
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
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("gophers.jpg", ebiten.FilterNearest)
|
gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterNearest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,6 @@ import (
|
|||||||
|
|
||||||
"github.com/hajimehoshi/ebiten"
|
"github.com/hajimehoshi/ebiten"
|
||||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||||
"github.com/hajimehoshi/ebiten/examples/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
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 = &Sprites{make([]*Sprite, MaxSprites), 500}
|
var sprites = &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 <- or -> to change the number of sprites`, ebiten.CurrentFPS(), sprites.Len())
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
@ -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>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user