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 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) * [Windows](https://github.com/hajimehoshi/ebiten/wiki/Windows)
* [Mac OS X](https://github.com/hajimehoshi/ebiten/wiki/Mac-OS-X) * [Mac OS X](https://github.com/hajimehoshi/ebiten/wiki/Mac-OS-X)
* [Linux](https://github.com/hajimehoshi/ebiten/wiki/Linux) * [Linux](https://github.com/hajimehoshi/ebiten/wiki/Linux)
* [Android](https://github.com/hajimehoshi/ebiten/wiki/Android) * [Android](https://github.com/hajimehoshi/ebiten/wiki/Android)
* [iOS](https://github.com/hajimehoshi/ebiten/wiki/iOS) * [iOS](https://github.com/hajimehoshi/ebiten/wiki/iOS)
Note: Decoding Ogg/Vorbis and gamepads aren't available on Safari.
## Features ## Features
* 2D Graphics (Geometry/Color matrix transformation, Various composition modes, Offscreen rendering) * 2D Graphics (Geometry/Color matrix transformation, Various composition modes, Offscreen rendering)

View File

@ -40,8 +40,9 @@
<dt>Mobiles</dt> <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> <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> <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> </dl>
<p><small>Note: Decoding Ogg/Vorbis and gamepads aren't available on Safari.</small></p>
<h2 id="features">Features</h2> <h2 id="features">Features</h2>
<dl class="dl-horizontal"> <dl class="dl-horizontal">

View File

@ -51,6 +51,8 @@ func (s *Stream) Size() int64 {
// Decode decodes Ogg/Vorbis data to playable stream. // Decode decodes Ogg/Vorbis data to playable stream.
// //
// The sample rate must be same as that of audio context. // 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) { func Decode(context *audio.Context, src audio.ReadSeekCloser) (*Stream, error) {
decoded, channelNum, sampleRate, err := decode(src) decoded, channelNum, sampleRate, err := decode(src)
if err != nil { 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/ 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 ## ragtime.ogg
``` ```

View File

@ -257,11 +257,11 @@ func main() {
if err != nil { if err != nil {
log.Fatal(err) 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 { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
const sampleRate = 22050 const sampleRate = 44100
const bytesPerSample = 4 // TODO: This should be defined in audio package const bytesPerSample = 4 // TODO: This should be defined in audio package
audioContext, err = audio.NewContext(sampleRate) audioContext, err = audio.NewContext(sampleRate)
if err != nil { if err != nil {

View File

@ -51,7 +51,8 @@ var (
) )
type Sprite struct { type Sprite struct {
image *ebiten.Image imageWidth int
imageHeight int
x int x int
y int y int
vx int vx int
@ -64,18 +65,15 @@ func (s *Sprite) Update() {
if s.x &lt; 0 { if s.x &lt; 0 {
s.x = -s.x s.x = -s.x
s.vx = -s.vx 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 { if s.y &lt; 0 {
s.y = -s.y s.y = -s.y
s.vy = -s.vy s.vy = -s.vy
} } else if screenHeight &lt;= s.y&#43;s.imageHeight {
w, h := s.image.Size() s.y = 2*(screenHeight-s.imageHeight) - s.y
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
s.vy = -s.vy s.vy = -s.vy
} }
} }
@ -85,17 +83,17 @@ type Sprites struct {
num int num int
} }
func (s Sprites) Update() { func (s *Sprites) Update() {
for _, sprite := range s.sprites { for _, sprite := range s.sprites {
sprite.Update() sprite.Update()
} }
} }
func (s Sprites) Len() int { func (s *Sprites) Len() int {
return s.num 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 { if s.num &lt;= i {
return 0, 0, 0, 0 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 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 { if s.num &lt;= i {
return 0, 0, 0, 0 return 0, 0, 0, 0
} }
@ -163,7 +161,8 @@ func main() {
x, y := rand.Intn(screenWidth-w), rand.Intn(screenHeight-h) x, y := rand.Intn(screenWidth-w), rand.Intn(screenHeight-h)
vx, vy := 2*rand.Intn(2)-1, 2*rand.Intn(2)-1 vx, vy := 2*rand.Intn(2)-1, 2*rand.Intn(2)-1
sprites.sprites[i] = &amp;Sprite{ sprites.sprites[i] = &amp;Sprite{
image: ebitenImage, imageWidth: w,
imageHeight: h,
x: x, x: x,
y: y, y: y,
vx: vx, vx: vx,

View File

@ -40,8 +40,9 @@
<dt>Mobiles</dt> <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> <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> <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> </dl>
<p><small>Note: Decoding Ogg/Vorbis and gamepads aren't available on Safari.</small></p>
<h2 id="features">Features</h2> <h2 id="features">Features</h2>
<dl class="dl-horizontal"> <dl class="dl-horizontal">