doc: Update docs for Safari (#293)

This commit is contained in:
Hajime Hoshi 2016-11-27 00:11:23 +09:00
parent a1e868b822
commit 8eba9cfc7f
9 changed files with 40 additions and 27 deletions

View File

@ -6,13 +6,15 @@
A simple SNES-like 2D game library in Go
* [Web browsers (Chrome and Firefox on desktops)](https://github.com/hajimehoshi/ebiten/wiki/Web-Browsers) (powered by [GopherJS](http://gopherjs.org/))
* [Web browsers (Chrome, Firefox and Safari on desktops)](https://github.com/hajimehoshi/ebiten/wiki/Web-Browsers) (powered by [GopherJS](http://gopherjs.org/))
* [Windows](https://github.com/hajimehoshi/ebiten/wiki/Windows)
* [Mac OS X](https://github.com/hajimehoshi/ebiten/wiki/Mac-OS-X)
* [Linux](https://github.com/hajimehoshi/ebiten/wiki/Linux)
* [Android](https://github.com/hajimehoshi/ebiten/wiki/Android)
* [iOS](https://github.com/hajimehoshi/ebiten/wiki/iOS)
Note: Decoding Ogg/Vorbis and gamepads aren't available on Safari.
## Features
* 2D Graphics (Geometry/Color matrix transformation, Various composition modes, Offscreen rendering)

View File

@ -40,8 +40,9 @@
<dt>Mobiles</dt>
<dd><a href="https://github.com/hajimehoshi/ebiten/wiki/Android">Android</a>, <a href="https://github.com/hajimehoshi/ebiten/wiki/iOS">iOS</a></dd>
<dt>Web browsers</dt>
<dd><a href="https://github.com/hajimehoshi/ebiten/wiki/Web-Browsers">Chrome and Firefox on desktops</a> (powered by <a href="http://gopherjs.org/">GopherJS</a>)</dd>
<dd><a href="https://github.com/hajimehoshi/ebiten/wiki/Web-Browsers">Chrome, Firefox and Safari on desktops</a> (powered by <a href="http://gopherjs.org/">GopherJS</a>)</dd>
</dl>
<p><small>Note: Decoding Ogg/Vorbis and gamepads aren't available on Safari.</small></p>
<h2 id="features">Features</h2>
<dl class="dl-horizontal">

View File

@ -51,6 +51,8 @@ func (s *Stream) Size() int64 {
// Decode decodes Ogg/Vorbis data to playable stream.
//
// The sample rate must be same as that of audio context.
//
// This function returns error on Safari.
func Decode(context *audio.Context, src audio.ReadSeekCloser) (*Stream, error) {
decoded, channelNum, sampleRate, err := decode(src)
if err != nil {

Binary file not shown.

View File

@ -9,6 +9,14 @@ Recorded by Mike Koenig
Attribution 3.0: https://creativecommons.org/licenses/by/3.0/
```
## game.ogg
```
http://mart.kitunebi.com/music_act.html
Harpie's Feather (ハルピュイアの羽) by Napi
```
## ragtime.ogg
```

View File

@ -257,11 +257,11 @@ func main() {
if err != nil {
log.Fatal(err)
}
oggF, err := ebitenutil.OpenFile(&#34;_resources/audio/ragtime.ogg&#34;)
oggF, err := ebitenutil.OpenFile(&#34;_resources/audio/game.ogg&#34;)
if err != nil {
log.Fatal(err)
}
const sampleRate = 22050
const sampleRate = 44100
const bytesPerSample = 4 // TODO: This should be defined in audio package
audioContext, err = audio.NewContext(sampleRate)
if err != nil {

View File

@ -51,11 +51,12 @@ var (
)
type Sprite struct {
image *ebiten.Image
x int
y int
vx int
vy int
imageWidth int
imageHeight int
x int
y int
vx int
vy int
}
func (s *Sprite) Update() {
@ -64,18 +65,15 @@ func (s *Sprite) Update() {
if s.x &lt; 0 {
s.x = -s.x
s.vx = -s.vx
} else if screenWidth &lt;= s.x&#43;s.imageWidth {
s.x = 2*(screenWidth-s.imageWidth) - s.x
s.vx = -s.vx
}
if s.y &lt; 0 {
s.y = -s.y
s.vy = -s.vy
}
w, h := s.image.Size()
if screenWidth &lt;= s.x&#43;w {
s.x = 2*(screenWidth-w) - s.x
s.vx = -s.vx
}
if screenHeight &lt;= s.y&#43;h {
s.y = 2*(screenHeight-h) - s.y
} else if screenHeight &lt;= s.y&#43;s.imageHeight {
s.y = 2*(screenHeight-s.imageHeight) - s.y
s.vy = -s.vy
}
}
@ -85,17 +83,17 @@ type Sprites struct {
num int
}
func (s Sprites) Update() {
func (s *Sprites) Update() {
for _, sprite := range s.sprites {
sprite.Update()
}
}
func (s Sprites) Len() int {
func (s *Sprites) Len() int {
return s.num
}
func (s Sprites) Dst(i int) (x0, y0, x1, y1 int) {
func (s *Sprites) Dst(i int) (x0, y0, x1, y1 int) {
if s.num &lt;= i {
return 0, 0, 0, 0
}
@ -103,7 +101,7 @@ func (s Sprites) Dst(i int) (x0, y0, x1, y1 int) {
return ss.x, ss.y, ss.x &#43; ebitenImageWidth, ss.y &#43; ebitenImageHeight
}
func (s Sprites) Src(i int) (x0, y0, x1, y1 int) {
func (s *Sprites) Src(i int) (x0, y0, x1, y1 int) {
if s.num &lt;= i {
return 0, 0, 0, 0
}
@ -163,11 +161,12 @@ func main() {
x, y := rand.Intn(screenWidth-w), rand.Intn(screenHeight-h)
vx, vy := 2*rand.Intn(2)-1, 2*rand.Intn(2)-1
sprites.sprites[i] = &amp;Sprite{
image: ebitenImage,
x: x,
y: y,
vx: vx,
vy: vy,
imageWidth: w,
imageHeight: h,
x: x,
y: y,
vx: vx,
vy: vy,
}
}
if err := ebiten.Run(update, screenWidth, screenHeight, 2, &#34;Sprites (Ebiten Demo)&#34;); err != nil {

View File

@ -40,8 +40,9 @@
<dt>Mobiles</dt>
<dd><a href="https://github.com/hajimehoshi/ebiten/wiki/Android">Android</a>, <a href="https://github.com/hajimehoshi/ebiten/wiki/iOS">iOS</a></dd>
<dt>Web browsers</dt>
<dd><a href="https://github.com/hajimehoshi/ebiten/wiki/Web-Browsers">Chrome and Firefox on desktops</a> (powered by <a href="http://gopherjs.org/">GopherJS</a>)</dd>
<dd><a href="https://github.com/hajimehoshi/ebiten/wiki/Web-Browsers">Chrome, Firefox and Safari on desktops</a> (powered by <a href="http://gopherjs.org/">GopherJS</a>)</dd>
</dl>
<p><small>Note: Decoding Ogg/Vorbis and gamepads aren't available on Safari.</small></p>
<h2 id="features">Features</h2>
<dl class="dl-horizontal">