mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
doc: Update docs for Safari (#293)
This commit is contained in:
parent
a1e868b822
commit
8eba9cfc7f
@ -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)
|
||||
|
@ -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">
|
||||
|
@ -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 {
|
||||
|
BIN
docs/examples/_resources/audio/game.ogg
Normal file
BIN
docs/examples/_resources/audio/game.ogg
Normal file
Binary file not shown.
Binary file not shown.
@ -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
|
||||
|
||||
```
|
||||
|
@ -257,11 +257,11 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
oggF, err := ebitenutil.OpenFile("_resources/audio/ragtime.ogg")
|
||||
oggF, err := ebitenutil.OpenFile("_resources/audio/game.ogg")
|
||||
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 {
|
||||
|
@ -51,7 +51,8 @@ var (
|
||||
)
|
||||
|
||||
type Sprite struct {
|
||||
image *ebiten.Image
|
||||
imageWidth int
|
||||
imageHeight int
|
||||
x int
|
||||
y int
|
||||
vx int
|
||||
@ -64,18 +65,15 @@ func (s *Sprite) Update() {
|
||||
if s.x < 0 {
|
||||
s.x = -s.x
|
||||
s.vx = -s.vx
|
||||
} else if screenWidth <= s.x+s.imageWidth {
|
||||
s.x = 2*(screenWidth-s.imageWidth) - s.x
|
||||
s.vx = -s.vx
|
||||
}
|
||||
if s.y < 0 {
|
||||
s.y = -s.y
|
||||
s.vy = -s.vy
|
||||
}
|
||||
w, h := s.image.Size()
|
||||
if screenWidth <= s.x+w {
|
||||
s.x = 2*(screenWidth-w) - s.x
|
||||
s.vx = -s.vx
|
||||
}
|
||||
if screenHeight <= s.y+h {
|
||||
s.y = 2*(screenHeight-h) - s.y
|
||||
} else if screenHeight <= s.y+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 <= 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 + ebitenImageWidth, ss.y + 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 <= i {
|
||||
return 0, 0, 0, 0
|
||||
}
|
||||
@ -163,7 +161,8 @@ 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] = &Sprite{
|
||||
image: ebitenImage,
|
||||
imageWidth: w,
|
||||
imageHeight: h,
|
||||
x: x,
|
||||
y: y,
|
||||
vx: vx,
|
||||
|
@ -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">
|
||||
|
Loading…
Reference in New Issue
Block a user